I am building a website which involves in the processing of transactions of BTC. My current and most efficient plan to complete this would be to call these bitcoin-cli commands and process the data accordingly:
getblockcount - get block height
getblockhash blockheight-5 - get the block hash for the last 5 blocks
listsinceblock blockhash - list all transactions since then

I would run this order of commands every 5-10 seconds. I would like to know if this method wont screw me over at all (skipping transactions, etc). I might just be too paranoid about clients not getting what they paid for and just want a guaranteed method that no transactions slip by. I was hoping to call a method that can list all transactions since a certain time but that wasn't available. Now to the question:

Is this method CPU/Network intensive?
Is it a safe method?
What are my alternatives?

  • If you are getting the last 5 blocks and logging all transactions since then, why would you run this every 5-10 seconds? I think you'd be safe running it every N minutes. Are you storing this in a database?
    – m1xolyd1an
    Dec 13, 2016 at 3:18
  • It's possible, though unlikely, that more than 5 blocks could be mined in those 5-10 seconds. Dec 13, 2016 at 4:40
  • Despite that probability, I'd rather not take that risk.
    – Monstrum
    Dec 13, 2016 at 4:53
  • Please edit the title to summarize your question's topic.
    – Murch
    Jan 13, 2017 at 17:04

1 Answer 1


I have found the answer to my own question
To make sure every transaction goes through my script I have decided to use walletnotify. This is a feature of bitcoind and will run a bash script every time there is a new transaction with the transaction id. I was able to place this in my .bitcoin/bitcoin.conf file with the parameters like so:
walletnotify=/bin/echo %s | /bin/nc -U /root/nodejs.sock
I used netcat to bridge my requests from bash to NodeJS however you can use your %s transaction data any way you like.

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.