Take the 2-minute tour ×
Bitcoin Stack Exchange is a question and answer site for Bitcoin crypto-currency enthusiasts. It's 100% free, no registration required.

I want to create a website which involves the creation of a new single-use address that a user would send bitcoins to. I'd like to know programmatically when the user has sent bitcoins to the address so the website can post a "thank you" note (or do whatever else). What is the best way to do this?

The flow would be:

  1. Website creates and shows user a new single-use address and says, "send bitcoins here"
  2. User sends bitcoins to the address
  3. As soon as the address receives bitcoins, the website says "thank you for sending 0.3 BTC!"

I suppose I could poll the address in question every few minutes, but this is problematic because the user may abandon the website after step 1 (i.e., never send any bitcoins), so the website might end up polling forever.

I am using the official bitcoind client now, but I'm open to using something else.

I understand Blockchain.info provides an API to get push notifications on a given address activity, but I'd rather not rely on a third-party service.

share|improve this question
    
I'd be really interested if there is a push method but I don't believe there is any support for this at this time built into the client. –  Jay West Jan 19 '13 at 4:15
    
@JayWest at this time there is no push method. At the current time the only option is to create the illusion for the end user that push notification is occurring by using a background process to continually pull data from bitcoind (either getreceivedbyaddress or listtransactions depending on the usage. –  DeathAndTaxes Jan 22 '13 at 2:04
add comment

3 Answers

up vote 5 down vote accepted

Beginning with v0.6.0 of the Bitcoin.org client was -BlockNotify. Beginning with v0.8.2 of the Bitcoin.org client was -WalletNotify which provides transaction-level notification.

share|improve this answer
    
0.8.2 supports -walletnotify. Thank you, Stephen! –  Sanjay Jun 21 '13 at 0:31
add comment

listsinceblock is more convinient - it can be used incrementally.

share|improve this answer
1  
Is this in the mainline client? –  Nick ODell Mar 27 '13 at 22:12
1  
Or listunspent 6 144 to get unspent (6-)confirmed transactions from the last 24 hours (e.g. if you move incoming transaction to a offline wallet after "registering" them). –  Nicolai Mar 28 '13 at 0:32
add comment

You might want to do amortized polling: use listtransactions to poll the latest transactions over all accounts. So instead of issuing one poll for every account you do it for all of them at the same time. This combined with a timeout to slow down polling if no payment will be received should work fine.

share|improve this answer
    
Thanks, cdecker. I'm going to wait and see if anyone responds with a push method to do this (rather than polling). –  Sanjay Jan 16 '13 at 18:26
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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