Bitcoin Forum
November 09, 2024, 09:45:45 AM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Checking new transactions with only the public address  (Read 1190 times)
NicosKaralis (OP)
Sr. Member
****
Offline Offline

Activity: 416
Merit: 251


★777Coin.com★ Fun BTC Casino!


View Profile
March 17, 2015, 12:25:26 PM
 #1

I'm doing a little research on how to build a wallet on ios for bitcoins and some others altcoins.

I found about bread app and I really like the idea of a btc client on mobile that, to me, is much more safe than blockchain or other website wallets around.
The problem is bread is not very well updated and since I'm a developer I could build and add some more functionalities. There are many things I would add but one is giving me some problems to implement.

I wanted to send a push notification to tell the user that a new transaction has been detected, how could I create this?

Just for clarification, the app on the phone have all keys and they are not sent to the server, only the public address (if the user wants the notifications). In the server we have a process running to pool new transactions for that address, i already saw blockchain and chain.so api's to pool balance changes.

If my userbase gets to big I would have problems to pool that much data (api limits, timing and such)

Is there a better way to do it? maybe with a btc node?

P.S.:   Im using btc as example, in my wallet I would handle btc, doge, ltc and others.
P.S.2: English is not my first language so if I said anything you don't understand or anything wrong, please let me know.

EcuaMobi
Legendary
*
Offline Offline

Activity: 1876
Merit: 1475



View Profile
March 17, 2015, 12:34:36 PM
 #2

I'm guessing your mobile client won't handle the blockchain at all, right? Otherwise you could see new transactions there without a server.

To do it with a server you could install a full node and use the option
-walletnotify=<cmd>
Or -blocknotify=<cmd>
NicosKaralis (OP)
Sr. Member
****
Offline Offline

Activity: 416
Merit: 251


★777Coin.com★ Fun BTC Casino!


View Profile
March 17, 2015, 12:44:29 PM
 #3

I'm guessing your mobile client won't handle the blockchain at all, right? Otherwise you could see new transactions there without a server.
Yeah, my client will be a headless client so it will connect directly to the btc network, because of that the server don't have any information other than the public address

To do it with a server you could install a full node and use the option
-walletnotify=<cmd>
Or -blocknotify=<cmd>
Could you elaborate a little more? like an example? What is the "cmd"? Can I be notified about many addresses at the same time?



I already know how to do it, but ty anyway.

You can use Blocktrail.com and upgrade your API membership when your API limits are exceeding with other explorers.
I was hoping for a free solution, altcoins are open source after all

AFAIK you can't check balance of an address which you don't own(which isn't in your wallet) using Bitcoin core.
I already know that, but what about a transaction? I want to say "You received Y currency", rather then "You have X much"

EcuaMobi
Legendary
*
Offline Offline

Activity: 1876
Merit: 1475



View Profile
March 17, 2015, 01:15:27 PM
 #4

To do it with a server you could install a full node and use the option
-walletnotify=<cmd>
Or -blocknotify=<cmd>
Could you elaborate a little more? like an example? What is the "cmd"? Can I be notified about many addresses at the same time?

cmd is a command to call every time a new block or transaction is found. For example it can call your own script that receives the block or TX ID as parameter and acts accordingly.
It could query the DB to see if that block or transaction affects a registered address and then send the push notification if it does.

This may help:  https://bitcointalk.org/index.php?topic=448565.0
nuno12345
Sr. Member
****
Offline Offline

Activity: 276
Merit: 284


View Profile
March 17, 2015, 01:46:25 PM
 #5

1:
If your able to run a full node this can be accomplished very easily.
Setup apache, rpc and either bitcoin-abe or insight(recommended)
Make the ios app call the domain lets say each minute with the public address and current ios (stored) balance.
With php call abe/insight api to gather that address balance, if its different than the stored balance it means a new tx happened.
If above is true grab the transactions and return the latest transaction and balance back to the client.
Store this info on ios.

2:
If you cant run a full node you can use blockchain.info api to do it.
Instead of calling your own block explorer make the client call blockchain.info directly.
This will prevent you getting blocked since the client is calling blockchain, not your domain.

With 2nd option you have to do the "maths" on ios rather than on your domain.

Hope this helps.
EcuaMobi
Legendary
*
Offline Offline

Activity: 1876
Merit: 1475



View Profile
March 17, 2015, 01:50:23 PM
 #6

1:
If your able to run a full node this can be accomplished very easily.
Setup apache, rpc and either bitcoin-abe or insight(recommended)
Make the ios app call the domain lets say each minute with the public address and current ios (stored) balance.
With php call abe/insight api to gather that address balance, if its different than the stored balance it means a new tx happened.
If above is true grab the transactions and return the latest transaction and balance back to the client.
Store this info on ios.

2:
If you cant run a full node you can use blockchain.info api to do it.
Instead of calling your own block explorer make the client call blockchain.info directly.
This will prevent you getting blocked since the client is calling blockchain, not your domain.

With 2nd option you have to do the "maths" on ios rather than on your domain.

Hope this helps.

Calling any server (own or blockchain) every minute from the mobile is a terrible idea. It would drain the battery and nobody would use the app. Push notifications are the  solution as already suggested by OP.

It can be accomplished either with blocknotify (recommended, less resources used and faster notifications) or with a process that runs every minute or so but running on the server, not the app.

NicosKaralis (OP)
Sr. Member
****
Offline Offline

Activity: 416
Merit: 251


★777Coin.com★ Fun BTC Casino!


View Profile
March 17, 2015, 01:56:24 PM
 #7

If you cant run a full node you can use blockchain.info api to do it.
Instead of calling your own block explorer make the client call blockchain.info directly.
This will prevent you getting blocked since the client is calling blockchain, not your domain.
This wont help me, i want to send a push from the server, meaning the server get all the processing

Make the ios app call the domain lets say each minute with the public address and current ios (stored) balance.
With php call abe/insight api to gather that address balance, if its different than the stored balance it means a new tx happened.
If above is true grab the transactions and return the latest transaction and balance back to the client.
Store this info on ios.
First the app is not required to be running all the time
second from what I found on a very fast search insight is an API the same way blockchain.info is, meaning I could get API restrictions


To do it with a server you could install a full node and use the option
-walletnotify=<cmd> or -blocknotify=<cmd>
From what I can tell this is the optimal way, you get all tx and check if they have a known address.
Will check on that and post results later

EcuaMobi
Legendary
*
Offline Offline

Activity: 1876
Merit: 1475



View Profile
March 17, 2015, 02:37:00 PM
 #8


Make the ios app call the domain lets say each minute with the public address and current ios (stored) balance.
With php call abe/insight api to gather that address balance, if its different than the stored balance it means a new tx happened.
If above is true grab the transactions and return the latest transaction and balance back to the client.
Store this info on ios.
First the app is not required to be running all the time
second from what I found on a very fast search insight is an API the same way blockchain.info is, meaning I could get API restrictions


@NicosKaralis so that you know nuno12345 was suggesting you to install your own instance of insight (https://github.com/bitpay/insight-api)
That way you wouldn't have any API restrictions (unless you set them for yourself Tongue).
You could call the API from localhost.

DannyHamilton
Legendary
*
Offline Offline

Activity: 3486
Merit: 4832



View Profile
March 17, 2015, 02:52:48 PM
 #9

Run a full node on your server (such as Bitcoin Core or bitcoind).

The server will receive all relayed transactions even before they are confirmed.

If you configure walletnotify, then you'll be able to execute a program to send out the alert or to update a database.

The server will also receive all relayed blocks as they are solved.

If you configure blocknotify, then you'll be able to execute a program to send out an alert or update a database with information about the number of confirmations on the transactions.

NicosKaralis (OP)
Sr. Member
****
Offline Offline

Activity: 416
Merit: 251


★777Coin.com★ Fun BTC Casino!


View Profile
March 17, 2015, 03:14:30 PM
 #10

@NicosKaralis so that you know nuno12345 was suggesting you to install your own instance of insight (https://github.com/bitpay/insight-api)
That way you wouldn't have any API restrictions (unless you set them for yourself Tongue).
You could call the API from localhost.
Sounds ok, will look into it

Run a full node on your server (such as Bitcoin Core or bitcoind).

The server will receive all relayed transactions even before they are confirmed.

If you configure walletnotify, then you'll be able to execute a program to send out the alert or to update a database.

The server will also receive all relayed blocks as they are solved.

If you configure blocknotify, then you'll be able to execute a program to send out an alert or update a database with information about the number of confirmations on the transactions.
Quick question, how much space do I need for that?
Would I need all blockchain? Or can I just get the transactions created after?

Muhammed Zakir
Hero Member
*****
Offline Offline

Activity: 560
Merit: 509


I prefer Zakir over Muhammed when mentioning me!


View Profile WWW
March 17, 2015, 04:05:59 PM
 #11

Quick question, how much space do I need for that?
Would I need all blockchain? Or can I just get the transactions created after?

Approximately 30+ GB. If you run Bitcoin core, you need full block chain data.

NicosKaralis (OP)
Sr. Member
****
Offline Offline

Activity: 416
Merit: 251


★777Coin.com★ Fun BTC Casino!


View Profile
March 17, 2015, 04:08:52 PM
 #12

Approximately 30+ GB. If you run Bitcoin core, you need full block chain data.

I don't need the full block chain data, only the transactions created after the script started running and even so i don't need to save them on disk, is it possible?

EcuaMobi
Legendary
*
Offline Offline

Activity: 1876
Merit: 1475



View Profile
March 17, 2015, 04:13:15 PM
 #13

Approximately 30+ GB. If you run Bitcoin core, you need full block chain data.

I don't need the full block chain data, only the transactions created after the script started running and even so i don't need to save them on disk, is it possible?

The only way to do this is by querying an external API. You will need t estimate the number of queries you'll be making and make sure there no restrictions to limit you.
You could query several different APIs to reduce the chance of reaching the limit.
DannyHamilton
Legendary
*
Offline Offline

Activity: 3486
Merit: 4832



View Profile
March 17, 2015, 04:22:58 PM
 #14

I don't need the full block chain data, only the transactions created after the script started running and even so i don't need to save them on disk, is it possible?

I'm not aware of any stand alone programs that will handle this for you.  It could probably be accomplished with a custom written SPV wallet.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!