how to do address callbacks?

0

I'm building a webapp that needs to update account info and send a message when an account's address gets a deposit, and/or confirm withdrawals.

I'm not sure what the best way to do this is. Would you have a separate application keep sending API calls to blockchain.info until a new transaction comes through? Then initiate the right callback function?

Using blockchain.info seems flimsy since it's a 3rd party service. How would you do this monitoring the bitcoin network? It seems like using any bitcoin client would rely on some commandline action. Would the best way be continuing to send the commandline action out until the returned data is different, and then initiate the callback? Is there a better design pattern that I am missing?

John

Posted 2013-07-29T01:21:30.467

Reputation: 539

Are you trying to tell your user when their money has entered their wallet? Shouldn't their wallet tell them that?Izzy 2013-07-30T11:54:59.747

The wallet may know bitcoin has been received, but how would the wallet know to email / notify the specific user? A callback on the address is needed.John 2013-07-30T14:56:10.813

Answers

3

If you rely on bitcoind and JSON-RPC API you could try launching daemon with -walletnotify option.

bitcoind -daemon -waletnotify="process-txn.sh %s"

This will call process-txn.sh with transaction id on the input. Then you can query the daemon for transaction details.

Michał Rudnicki

Posted 2013-07-29T01:21:30.467

Reputation: 141

Doesn't walletnotify work only for addresses registered? How to get all transactions? Clearly the node receives it. Bitcoinj allows it.Jus12 2016-11-01T17:20:41.427

1

I have built an open source service that does exactly this. Every time a new address is generated, it's associated with an account in a database. The Bitcoin client is running using the optional -walletnotify command to notify the database about the new transaction. When the database receives a new transaction, the account associated with that address can be notified.

Check out https://bitlab.co/wallet to see a demo of this in action. Also, the source for the back-end is available at https://github.com/bitlabco/bitlab-nodejs

Bitlab.co

Posted 2013-07-29T01:21:30.467

Reputation: 724