1

I'd like to implement a very simple address monitoring feature on a site I'm working on. I'd like to just be able to say "Listen to this address on the testnet for money to come in", and update the HTML on the page when BTC comes in. I realize Blockchain.info provides a websocket for precisely this, but doesn't provide it for use on testnet3.

I'm sure I'm overlooking something obvious. Any help is greatly appreciated.

  • Added info about SoChain - you might want to check it out. – Mikko Ohtamaa Sep 10 '14 at 10:25
1

Usually you do this on the wallet service you are using. They provide server-to-server notification callbacks when the address receives transactions. Then you parse this transaction and let your on server to notify JavaScript clients.

EDIT: SoChain offers no-authentication, WebSockets, API to monitor Bitcoin addresses in real-time. You can use this on cliet-side JavaScript directly:

https://chain.so/api#realtime-balance-updates

I don't know if any pure client-side JavaScript APIs exist with notification feature - you always need to set up webhooks to some server, or be directly connected to bitcoind.

Also there is the issue of confirmation level - when you consider the transaction to be received, how many confirmations you demand for it. You'll usually end up getting several notifications per each new confirmation.

I have done this in my open source project Liberty Music Store using blockchain.info.

For inspiration, see the relevant blockchain.info webhook code which then forwards this information to JavaScript through Redis pub-sub listener pattern (though in this case it does using HTTP long poll instead of WebSockets for Android 2.3 compatibility):

https://github.com/miohtama/LibertyMusicStore/blob/master/tatianastore/blockchain.py#L110

https://github.com/miohtama/LibertyMusicStore/blob/master/tatianastore/static/main.js#L102

https://github.com/miohtama/LibertyMusicStore/blob/master/tatianastore/signals.py#L28

https://github.com/miohtama/LibertyMusicStore/blob/master/tatianastore/storefront.py#L253

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.