Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: Vantix on May 28, 2013, 01:26:27 PM



Title: Bitcoind transaction notification
Post by: Vantix on May 28, 2013, 01:26:27 PM
What is the best way to get an HTTP callback when bitcoind client receive an input/output transaction?

Thank you all


Title: Re: Bitcoind transaction notification
Post by: Stephen Gornick on May 28, 2013, 02:05:14 PM
What is the best way to get an HTTP callback when bitcoind client receive an input/output transaction?

Thank you all

The Bitcoin-Qt/bitcoind client does not have any callback, so the main method employed currently is to poll the client to discover new transactions (using listsinceblock).

BitcoinJ does support this with a PeerEventListener interface:
 - http://bitcoin.stackexchange.com/a/8133/153

Also, BitsOfProof possibly supports a callback for new transactions as well.

[Edit: And most payment processors, e.g., BitPay,  provide this within their API.]

[Edit2: And you can configure Blockchain.info/wallet to notify you:
 - http://blockchain.info/wallet/payment-notifications ]


Title: Re: Bitcoind transaction notification
Post by: Zeilap on May 28, 2013, 02:16:52 PM
Actually, there are two command line switches -blocknotify and -walletnotify which will call a command when a block is found and when transactions arrive.

Honestly, I would avoid using listsinceblock, it doesn't behave as you'd expect and it'll come back to bite you.


Title: Re: Bitcoind transaction notification
Post by: kjj on May 28, 2013, 02:22:27 PM
The 8.2 release candidates include a -walletnotify option that can run a process when a transaction that affects the wallet is seen.  It would be fairly simple to write a script for that to call curl or wget to create a HTTP callback.

If your bitcoind is busy (or will be some day), or if the callback server is unreliable, it would be wiser to do it in two stages.  The -walletnotify could drop an entry into a database, and a second process could read those entries and execute the calls.  The reason is that the -walletnotify process needs to return promptly to avoid runaway processes.


Title: Re: Bitcoind transaction notification
Post by: Stephen Gornick on May 28, 2013, 02:26:18 PM
Actually, there are two command line switches -blocknotify and -walletnotify which will call a command when a block is found and when transactions arrive.

Ah, thanks for that!

Here's more info on it:

How to use Walletnotify?
 - http://bitcointalk.org/index.php?topic=203438.0