Trying to find an efficient method to process all transactions directed to my BTC address

0

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?

Monstrum

Posted 2016-12-13T00:52:45.673

Reputation: 1 021

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 2016-12-13T03:18:32.943

It's possible, though unlikely, that more than 5 blocks could be mined in those 5-10 seconds.Nate Eldredge 2016-12-13T04:40:04.153

Despite that probability, I'd rather not take that risk.Monstrum 2016-12-13T04:53:19.567

Please edit the title to summarize your question's topic.Murch 2017-01-13T17:04:53.280

Answers

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.

Monstrum

Posted 2016-12-13T00:52:45.673

Reputation: 1 021