If I want to have a website that can credit bitcoins to a user's account when they deposit bitcoins, how can I have the website automatically detect when the bitcoins have been received into to the wallet address given to that customer (belonging to me), and consequently update the website to reflect their new balance automatically - without having to manually check my wallet.

I'm not interested in using existing payment services for this, but rather I'm interested in the coding principles required.

4 Answers 4


You'd have to get your hands wet with JSON-RPC and the bitcoind API. This way you can programmatically, and automatically run specific wallet functionality like sending coins to some address once a specific condition is met.

More specifically I suggest you look at the raw HTTP calls being sent to the bitcoind server.


If you're going to be running bitcoind, what you're looking for is the walletnotify configuration setting in bitcoin.conf.

If you enable walletnotify, you run an app like curl to post the data to a web page. The data that you'll receive is the transaction id of an incoming transaction for an address in your wallet. From that you can use bitcoind's json-rpc commands to get the address that received the transaction as well as other transaction details like the amount.

Walletnotify will execute twice. It will execute the first time that a transaction appears, and then will get called again when a block is published that includes the transaction. You can use either or both of these notifications depending on your needs.

This is the curl command that I use in walletnofify. You should make any changes for your own environment.

curl -X POST -H "Content-Type:application/json" -d '{"transactionId":"%s"}'
  • Nice reply, walletnotify is the way to go. How do you account for double spends and TX malleability? Commented Apr 23, 2014 at 8:38
  • Robert, in my bitcoin project, we notify users when a transaction is pending (when we get a notification via walletnotify), but we don't let them spend the coins until it has received six confirmations. At six confirmations, double-spends are unlikely, if not computationally impossible. In my understanding, TX malleability also becomes a non-issue, since we're waiting on a specific TX id to get the required 6 confirms. Once a TX starts adding confirms, it won't be changing its ID.
    – ChrisW
    Commented Apr 23, 2014 at 21:49
  • what is the %s? Is it Json data or hex?
    – Jus12
    Commented Nov 1, 2016 at 17:22
  • It's the literal transaction id, like this format: "ae73ea37093e304248bda79f92cc0f722c199d4d00f52af5f3726e100818643f". It's the Sha256 hash of the transaction data.
    – ChrisW
    Commented Nov 1, 2016 at 20:30


First you get a new bitcoin-adress from blockchain and on the same way you send them a callback url

The new bitcoin-adress you can send your custormer to pay

blockchain.info calls your callback procedure every time something changed in the payment-process. First time, when the customer send your bitcoins. In the Parameters you can find the amount of Bitcoins (in Satoshi = 1/100.000.000 BTC) and the number of confimations.

The Number of confirmations counting up every call from blockchain.ino to your callback procedure. The calls don't stop until you return ok...!

When you think you have enough confirmations you can mark your Payment as done and return ok The bitcoins booked on the bitcoin-address ($my_address) you send to blockchain.info in the first call.

This are only a few statements as you see in my link at hte beginning of my text.

blockchain.info calls your callbackprocedure with its own parameters and returns the parameter you send to blockchain.info. For this you can (not must) send your secret key. So you can detect spam-calls to your callback-funktion from other persons.

Regards heinz www.btcloc.com


Might be wise to wait until 3 or 4 new blocks have been created (after payment detected) before assuming the transaction to be trustworthy.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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