<p><strong>I have found the answer to my own question</strong><br />
To make sure every transaction goes through my script I have decided to use <code>walletnotify</code>. This is a feature of <code>bitcoind</code> 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 <code>.bitcoin/bitcoin.conf</code> file with the parameters like so:<br />
<code>walletnotify=/bin/echo %s | /bin/nc -U /root/nodejs.sock</code><br />
I used netcat to bridge my requests from bash to NodeJS however you can use your <code>%s</code> transaction data any way you like.</p>

CC BY-SA 3.0
2016-12-13T03:33:46.407Z
2016-12-13T03:33:46.407Z
Monstrum
<p>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: <br/>
<code>getblockcount</code> - get block height <br />
<code>getblockhash blockheight-5</code> - get the block hash for the last 5 blocks <br />
<code>listsinceblock blockhash</code> - list all transactions since then<br></p>

<p>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: <br /></p>

<p>Is this method CPU/Network intensive?<br/>
Is it a safe method?<br />
What are my alternatives?</p>

CC BY-SA 3.0
2016-12-13T03:18:32.943Z
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
CC BY-SA 3.0
2016-12-13T04:40:04.153Z
It's possible, though unlikely, that more than 5 blocks could be mined in those 5-10 seconds.
Nate Eldredge
CC BY-SA 3.0
2016-12-13T04:53:19.567Z
Despite that probability, I'd rather not take that risk.
Monstrum
CC BY-SA 3.0
2017-01-13T17:04:53.280Z
Please edit the title to summarize your question's topic.
Murch
<bitcoind><development>
Trying to find an efficient method to process all transactions directed to my BTC address
Monstrum
# Trying to find an efficient method to process all transactions directed to my BTC address

(Asked by: username_0 on 2016-12-13)

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?

**Tags:** bitcoind, development

> **Comments:**
> **username_1**: 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?  
> **username_2**: It's possible, though unlikely, that more than 5 blocks could be mined in those 5-10 seconds.  
> **username_0**: Despite that probability, I'd rather not take that risk.  
> **username_3**: Please edit the title to summarize your question's topic.  

---

## 1 answers

### Answer by username_0 on 2016-12-13. Score: 1 | Accepted answer

**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.


---

