<p>You'd have to get your hands wet with <a href="http://json-rpc.org/" rel="nofollow">JSON-RPC</a> and the <a href="https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_calls_list" rel="nofollow">bitcoind API</a>. This way you can programmatically, and automatically run specific wallet functionality like sending coins to some address once a specific condition is met.</p>

<p>More specifically I suggest you look at the <a href="https://en.bitcoin.it/wiki/API_reference_%28JSON-RPC%29#Command_line_.28cURL.29" rel="nofollow">raw HTTP calls</a> being sent to the bitcoind server. </p>

CC BY-SA 3.0
2014-01-30T14:03:49.277Z
2014-01-30T14:09:00.720Z
2014-01-30T14:09:00.720Z
Luca Matteis
<p>If you're going to be running bitcoind, what you're looking for is the walletnotify <a href="https://en.bitcoin.it/wiki/Running_Bitcoin" rel="nofollow">configuration setting</a> in bitcoin.conf.</p>

<p>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.</p>

<p>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.</p>

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

<pre><code>curl -X POST -H "Content-Type:application/json" -d '{"transactionId":"%s"}' http://127.0.0.1:81/api/v1/transactions
</code></pre>

CC BY-SA 3.0
2014-04-23T08:38:14.540Z
Nice reply, walletnotify is the way to go. How do you account for double spends and TX malleability?
Robert-Reinder Nederhoed
CC BY-SA 3.0
2014-04-23T21:49:43.627Z
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
CC BY-SA 3.0
2016-11-01T17:22:58.043Z
what is the %s? Is it Json data or hex?
Jus12
CC BY-SA 3.0
2016-11-01T20:30:42.453Z
It's the literal transaction id, like this format: "ae73ea37093e304248bda79f92cc0f722c199d4d00f52af5f3726e100818643f".  It's the Sha256 hash of the transaction data.
ChrisW
CC BY-SA 3.0
2014-01-30T21:27:44.207Z
2014-01-30T21:27:44.207Z
ChrisW
<p><a href="http://blockchain.info/de/api/api_receive" rel="nofollow">http://blockchain.info/de/api/api_receive</a></p>

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

<p>The new bitcoin-adress you can send your custormer to pay</p>

<p>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.</p>

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

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

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

<p>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.</p>

<p>Regards heinz
www.btcloc.com</p>

CC BY-SA 3.0
2014-01-30T17:13:33.070Z
2014-01-30T17:13:33.070Z
Heinz
<p>Might be wise to wait until 3 or 4 new blocks have been created (after payment detected) before assuming the transaction to be trustworthy.</p>

CC BY-SA 3.0
2014-01-30T18:05:38.633Z
2014-01-30T18:05:38.633Z
CovTom
<p>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.</p>

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

<websites>
How can a website detect when bitcoins have been deposited?
Kenshin
# How can a website detect when bitcoins have been deposited?

(Asked by: username_0 on 2014-01-30)

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.

**Tags:** websites


---

## 4 answers

### Answer by username_1 on 2014-01-30. Score: 1 | Accepted answer

You'd have to get your hands wet with [JSON-RPC](http://json-rpc.org/) and the [bitcoind API](https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_calls_list). 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](https://en.bitcoin.it/wiki/API_reference_%28JSON-RPC%29#Command_line_.28cURL.29) being sent to the bitcoind server.


---

### Answer by username_2 on 2014-01-30. Score: 4

If you're going to be running bitcoind, what you're looking for is the walletnotify [configuration setting](https://en.bitcoin.it/wiki/Running_Bitcoin) 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"}' http://127.0.0.1:81/api/v1/transactions

```

> **Comments:**
> **username_3**: Nice reply, walletnotify is the way to go. How do you account for double spends and TX malleability?  
> **username_2**: 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.  
> **username_4**: what is the %s? Is it Json data or hex?  
> **username_2**: It's the literal transaction id, like this format: "ae73ea37093e304248bda79f92cc0f722c199d4d00f52af5f3726e100818643f".  It's the Sha256 hash of the transaction data.  

---

### Answer by username_5 on 2014-01-30. Score: 2

<http://blockchain.info/de/api/api_receive>

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 username_5
www.btcloc.com


---

### Answer by username_6 on 2014-01-30. Score: 2

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


---

