1

How can I check if a bitcoin address received a new transaction programmatically?

Here is an example of the API call, but I can't figure out how to get the value of the new transation in API response:

https://blockchain.info/rawaddr/1De2yKR7q95R1CV9PhmxA3kcYVa25mDaqj

0

On a bash shell prompt, assuming you have curl and jq installed:

curl https://blockchain.info/rawaddr/1De2yKR7q95R1CV9PhmxA3kcYVa25mDaqj | jq -r '.txs | .[] | .hash' | head -1

This will give you the most recent txid this address has appeared in.

| improve this answer | |
0

You can set up a bitcoin-core node to watch for new transactions, and notify you of them.

This is a preferable solution, since you won't have to trust anyone to supply you with the correct info (what if they lie, or are incorrect?), and you will retain your privacy (why dox yourself with respect to which addresses you are interested in, to the API provider and anyone else listening in on your connection?).

You can set the command -walletnotify=<cmd> in your bitcoin.conf file, and write a bash script to alert you of the transaction in question, in your preferred manner (write to a log file, send an alert email, blink a light, etc).

For a slightly more in-depth walkthrough of setting this up, see this question: How do I use walletnotify?

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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