I'm experimenting with writing some Bitcoin software in Node.JS using the 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 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?