<p>I'm experimenting with writing some Bitcoin software in Node.JS using the <a href="https://github.com/freewil/node-bitcoin" rel="nofollow">node-bitcoin</a> lib to talk directly to my own <code>bitcoind</code> via <code>JSON-RPC</code>, and I am trying to work out the best-practice way to recognise when a bitcoin payment has been received by an address.</p>

<p>The only way I can really think of doing is is as follows:</p>

<ol>
<li>a recipient provides the Bitcoin address they wish to receive payment to (presumes they have their own wallet already - else I could generate one for them)</li>
<li>My webpage generates a QR code in the proscribed format for a user's smartphone wallet app to scan.</li>
<li>The user scans the QR code and sends payment via their wallet app</li>
<li>I then assumed I could poll <code>getreceivedbyaddress</code> with the recipient's address until the transactions showed up, but <a href="https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_calls_list" rel="nofollow">the docs</a> explicitly state that this:</li>
</ol>

<blockquote>
  <p>Works only for addresses in the local wallet, external addresses will always show 0.</p>
</blockquote>

<p>So I assume the solution is to generate a new receiving address for the recipient rather than let them provide their own receiving address. Ideally in this situation I'd generate a new receiving address for each sale the recipient makes.</p>

<p>Then I can easily poll <code>getreceivedbyaddress</code>, analyse the raw transaction when I see it come in, and, assuming it all makes sense, ping a web-socket event to the webpage telling it to close the QR code and spit out a formal receipt.</p>

<p>Does that make sense or is there a preferred way to do this?</p>

CC BY-SA 3.0
2014-08-12T12:16:53.510Z
related: [How to know when a payment has been received by bitcoind?](http://bitcoin.stackexchange.com/a/7132/5406)
Murch
CC BY-SA 3.0
2014-08-12T12:33:42.157Z
Cool thanks!  I'll go read up on `-WalletNotify`
Dave Sag
CC BY-SA 3.0
2014-08-12T12:37:41.697Z
You're welcome. If the linked question answers your question completely, please kindly flag your own question as a duplicate.
Murch
CC BY-SA 3.0
2014-08-12T12:45:31.203Z
Good idea.  I've done that now.
Dave Sag
<bitcoind><json-rpc><payment><receiving>
Logical flow to check for receipt of a bitcoin payment
Dave Sag
# Logical flow to check for receipt of a bitcoin payment

(Asked by: username_0 on 2014-08-10)

I'm experimenting with writing some Bitcoin software in Node.JS using the [node-bitcoin](https://github.com/freewil/node-bitcoin) lib to talk directly to my own `bitcoind` via `JSON-RPC`, and I am trying to work out the best-practice way to recognise when a bitcoin payment has been received by an address.

The only way I can really think of doing is is as follows:

1. a recipient provides the Bitcoin address they wish to receive payment to (presumes they have their own wallet already - else I could generate one for them)
2. My webpage generates a QR code in the proscribed format for a user's smartphone wallet app to scan.
3. The user scans the QR code and sends payment via their wallet app
4. I then assumed I could poll `getreceivedbyaddress` with the recipient's address until the transactions showed up, but [the docs](https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_calls_list) explicitly state that this:

> Works only for addresses in the local wallet, external addresses will always show 0.

So I assume the solution is to generate a new receiving address for the recipient rather than let them provide their own receiving address. Ideally in this situation I'd generate a new receiving address for each sale the recipient makes.

Then I can easily poll `getreceivedbyaddress`, analyse the raw transaction when I see it come in, and, assuming it all makes sense, ping a web-socket event to the webpage telling it to close the QR code and spit out a formal receipt.

Does that make sense or is there a preferred way to do this?

**Tags:** bitcoind, json-rpc, payment, receiving

> **Comments:**
> **username_1**: related: [How to know when a payment has been received by bitcoind?](http://bitcoin.stackexchange.com/a/7132/5406)  
> **username_0**: Cool thanks!  I'll go read up on `-WalletNotify`  
> **username_1**: You're welcome. If the linked question answers your question completely, please kindly flag your own question as a duplicate.  
> **username_0**: Good idea.  I've done that now.  

---

## 0 answers

