<p>If number of addresses in your local wallet is not too high, you can search all transactions (in and out) and filter them to seperate addresses which is not in the database. If you have a large number of addresses in the local wallet, this may not be helpful for your case due to very high number of "string comparisons". (In this case, just use another wallet for the ones in the DB).</p>

<ol>
<li><p>If this is the first time for monitoring, start searching from
Block-0 (genesis) "getblockhash n" RPC command will give you hash of
n'th block. Use 1 to get hash of the block which is just after the
Genesis-Block. Then use "getblockheader"</p>

<p>getblockhash 1</p></li>
<li><p>Use the result with "getblockheader" RPC command. This will give
you header of a block which includes "previousblockhash" variable.</p>

<p>getblockheader 'blockhash'</p></li>
<li><p>Use 'previousblockhash' variable from the result you got at
previous step. "listsinceblock" RPC command will return all
transactions since given block. (Attention: transactions in the
given block are not included!)</p>

<p>listsinceblock 'previousblockhash'</p></li>
<li>After you finish your job on transactions which are returned from
"listsinceblock 'blockhash'", save the last block hash you achieved
(and you don't want to search again) into the db or a file.</li>
<li>Next time, get the block hash you saved and go to step 3.</li>
</ol>

<p>This way, you will only monitor new transactions. If you want to update old transactions (number of confirmations etc.), you need to search from the first block every time. In that case, you would just want to use walletnotify or blocknotify.</p>

CC BY-SA 4.0
2021-08-03T00:52:00.270Z
Hey, this is exactly what I am trying to do, store deposit transactions for each unique user address from the output received from `listsinceblock`. I would like to ask, when computing the sum of deposits for each unique user address, does one consider transactions only of category `receive` and `generate` and ignore all other transactions categories like `orphan`, `immature` and `send`?
philosopher
CC BY-SA 3.0
2017-10-26T22:47:07.850Z
2017-10-26T23:00:05.760Z
2017-10-26T23:00:05.760Z
uykusuzessek
<p>You could import all of those keys into a wallet using a very long password that you will never use again. Then, you could make bitcoind handle keeping track of all of those addresses and their balances, while not being able to spend any of them. The rest can be handled through the <a href="https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_calls_list" rel="nofollow">JSON RPC API</a>. It might not be the neatest way of doing things, but it should work.</p>

CC BY-SA 3.0
2012-08-21T18:45:53.813Z
that is more or less the same thing I said. I could bomb bitcoind with RPC calls but I was looking for a neater way.
curiosity
CC BY-SA 3.0
2012-08-21T16:08:43.677Z
2012-08-21T16:08:43.677Z
ThePiachu
<p>If you want to just monitor large number public address, you can try <a href="https://www.blockonomics.co/blockonomics" rel="nofollow noreferrer">blockonomics wallet watcher</a>. It is optimized to watch large number of address. In addition to this:</p>

<ul>
<li>You can get email notification of transactions</li>
<li>Tag Addresses to group them</li>
<li>See history of transactions</li>
</ul>

CC BY-SA 3.0
2017-10-03T08:43:30.000Z
2017-10-03T08:43:30.000Z
dark knight
<p>I have written a program in Python3 that allows you to search for any address on bitcoin core whether it belongs to your wallet or not.</p>
<p>Here is the github link:</p>
<p><a href="https://github.com/ORP967/Bitcoin_Core_RPC_par_address" rel="nofollow noreferrer">https://github.com/ORP967/Bitcoin_Core_RPC_par_address</a></p>
<p>Let me know what you think or if you have any improvements you might have.</p>

CC BY-SA 4.0
2022-01-23T23:22:23.393Z
2022-01-23T23:22:23.393Z
ORP967
<p>I am basically doing the same thing for bitcoinmonitor.net. I have a database of addresses to monitor and get notifications from bitcoind for any incoming transaction.</p>

<p>I maintain a patchset for bitcoind which allows setting an url which will be called with any incoming unconfirmed transaction, including transaction details in a json object. Also for any new accepted block a (different) url can be set up to be called with details on the new block.</p>

<p>So you will get a notification for any incoming unconfirmed transaction, then you can match this with the monitored addresses in your database.
If you want to trigger actions after a certain number of confirmations you need to hook up to the new block event.</p>

<p>Check <a href="https://github.com/TripleSpeeder/bitcoin">https://github.com/TripleSpeeder/bitcoin</a> for my bitcoind fork. I try to keep it more or less in sync with the current stable official client. This is running stable with bitcoinmonitor.net for around 10 months now.</p>

CC BY-SA 3.0
2012-08-23T20:07:19.993Z
really nice job. thanks. I just did diff with bitcoin repository and patch looks really promising.
curiosity
CC BY-SA 3.0
2012-08-28T07:37:44.280Z
Thanks :-) Note that my custom "getanytransaction" rpc method is deprecated. Upcoming official 0.7 client will include a new method "getrawtransaction" which will do basically the same (see https://bitcointalk.org/index.php?topic=89725.0).
TripleSpeeder
CC BY-SA 3.0
2015-05-18T05:49:46.297Z
*“I try to keep it more or less in sync with the current stable official client.”* – Sorry to say so, but the problem with aging answers like this one are things like *[This branch is 3502 commits behind bitcoin:master]*
e-sushi
CC BY-SA 3.0
2012-08-23T09:31:55.917Z
2012-08-23T09:31:55.917Z
TripleSpeeder
<p>I have around 20000 generated addresses which I want to monitor for new transactions. More addresses should probably come. Customers should use every address only once but I would like to monitor already used addresses if some of them decide to transfer coins to "used" addresses.</p>

<p>These addresses are not in the online wallet, I have only addresses in the databases. Private keys are held offline.</p>

<p>That means that I do not want to monitor addresses from the local wallet but the addresses from databases.</p>

<p>A command should executed after a transaction is received (with enough confirmations). There are some monitor services which can send an email or call url after receiving a transaction for an address on the watchlist. </p>

<p>I would like to implement the same feature for my application without depending on external service.</p>

<p>I saw some questions and answers like:</p>

<p><a href="https://bitcoin.stackexchange.com/questions/1725/how-to-know-there-is-a-new-transaction">How to know there is a new transaction?</a> or
  <a href="https://bitcoin.stackexchange.com/questions/4265/monitor-all-transactions-on-bitcoin-network-api">Monitor all transactions on bitcoin network - API</a></p>

<p>But what would be the most efficient way to do this? Is there a perl/php compatible way to do that?</p>

<p>One of topics from above links to <a href="https://bitcointalk.org/index.php?topic=89725.0" rel="noreferrer">https://bitcointalk.org/index.php?topic=89725.0</a> where Gavin is talking about some new features but I did  not get how could I or whether I can use anything of this to monitor a high number of addresses. Sending every minute a batch RPC call with a few thousands addresses to bitcoind is probably not a solution :-(.</p>

<p>I hope that there is a elegant way to monitor the whole information stream (all incoming transactions and other incoming information) and react if it matches what I need. </p>

CC BY-SA 4.0
2018-08-04T00:39:39.293Z
I would start with an external service, and then build and run a bitcoin node when you need to. We've used https://www.blockchainwebhooks.com/ and https://www.blockcypher.com/, both have been very reliable and offer free plans
sizzlecookie
<transactions><development><json-rpc><scalability>
how to monitor +20,000 addresses for new received transactions?
curiosity
# how to monitor +20,000 addresses for new received transactions?

(Asked by: username_0 on 2012-08-20)

I have around 20000 generated addresses which I want to monitor for new transactions. More addresses should probably come. Customers should use every address only once but I would like to monitor already used addresses if some of them decide to transfer coins to "used" addresses.

These addresses are not in the online wallet, I have only addresses in the databases. Private keys are held offline.

That means that I do not want to monitor addresses from the local wallet but the addresses from databases.

A command should executed after a transaction is received (with enough confirmations). There are some monitor services which can send an email or call url after receiving a transaction for an address on the watchlist.

I would like to implement the same feature for my application without depending on external service.

I saw some questions and answers like:

[How to know there is a new transaction?](https://bitcoin.stackexchange.com/questions/1725/how-to-know-there-is-a-new-transaction) or
[Monitor all transactions on bitcoin network - API](https://bitcoin.stackexchange.com/questions/4265/monitor-all-transactions-on-bitcoin-network-api)

But what would be the most efficient way to do this? Is there a perl/php compatible way to do that?

One of topics from above links to <https://bitcointalk.org/index.php?topic=89725.0> where Gavin is talking about some new features but I did not get how could I or whether I can use anything of this to monitor a high number of addresses. Sending every minute a batch RPC call with a few thousands addresses to bitcoind is probably not a solution :-(.

I hope that there is a elegant way to monitor the whole information stream (all incoming transactions and other incoming information) and react if it matches what I need.

**Tags:** transactions, development, json-rpc, scalability

> **Comments:**
> **username_1**: I would start with an external service, and then build and run a bitcoin node when you need to. We've used https://www.blockchainwebhooks.com/ and https://www.blockcypher.com/, both have been very reliable and offer free plans  

---

## 5 answers

### Answer by username_7 on 2012-08-23. Score: 17 | Accepted answer

I am basically doing the same thing for bitcoinmonitor.net. I have a database of addresses to monitor and get notifications from bitcoind for any incoming transaction.

I maintain a patchset for bitcoind which allows setting an url which will be called with any incoming unconfirmed transaction, including transaction details in a json object. Also for any new accepted block a (different) url can be set up to be called with details on the new block.

So you will get a notification for any incoming unconfirmed transaction, then you can match this with the monitored addresses in your database.
If you want to trigger actions after a certain number of confirmations you need to hook up to the new block event.

Check <https://github.com/username_7/bitcoin> for my bitcoind fork. I try to keep it more or less in sync with the current stable official client. This is running stable with bitcoinmonitor.net for around 10 months now.

> **Comments:**
> **username_0**: really nice job. thanks. I just did diff with bitcoin repository and patch looks really promising.  
> **username_7**: Thanks :-) Note that my custom "getanytransaction" rpc method is deprecated. Upcoming official 0.7 client will include a new method "getrawtransaction" which will do basically the same (see https://bitcointalk.org/index.php?topic=89725.0).  
> **username_8**: *“I try to keep it more or less in sync with the current stable official client.”* – Sorry to say so, but the problem with aging answers like this one are things like *[This branch is 3502 commits behind bitcoin:master]*  

---

### Answer by username_2 on 2017-10-26. Score: 1

If number of addresses in your local wallet is not too high, you can search all transactions (in and out) and filter them to seperate addresses which is not in the database. If you have a large number of addresses in the local wallet, this may not be helpful for your case due to very high number of "string comparisons". (In this case, just use another wallet for the ones in the DB).

1. If this is the first time for monitoring, start searching from
   Block-0 (genesis) "getblockhash n" RPC command will give you hash of
   n'th block. Use 1 to get hash of the block which is just after the
   Genesis-Block. Then use "getblockheader"

   getblockhash 1
2. Use the result with "getblockheader" RPC command. This will give
   you header of a block which includes "previousblockhash" variable.

   getblockheader 'blockhash'
3. Use 'previousblockhash' variable from the result you got at
   previous step. "listsinceblock" RPC command will return all
   transactions since given block. (Attention: transactions in the
   given block are not included!)

   listsinceblock 'previousblockhash'
4. After you finish your job on transactions which are returned from
   "listsinceblock 'blockhash'", save the last block hash you achieved
   (and you don't want to search again) into the db or a file.
5. Next time, get the block hash you saved and go to step 3.

This way, you will only monitor new transactions. If you want to update old transactions (number of confirmations etc.), you need to search from the first block every time. In that case, you would just want to use walletnotify or blocknotify.

> **Comments:**
> **username_3**: Hey, this is exactly what I am trying to do, store deposit transactions for each unique user address from the output received from `listsinceblock`. I would like to ask, when computing the sum of deposits for each unique user address, does one consider transactions only of category `receive` and `generate` and ignore all other transactions categories like `orphan`, `immature` and `send`?  

---

### Answer by username_4 on 2012-08-21. Score: 1

You could import all of those keys into a wallet using a very long password that you will never use again. Then, you could make bitcoind handle keeping track of all of those addresses and their balances, while not being able to spend any of them. The rest can be handled through the [JSON RPC API](https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_calls_list). It might not be the neatest way of doing things, but it should work.

> **Comments:**
> **username_0**: that is more or less the same thing I said. I could bomb bitcoind with RPC calls but I was looking for a neater way.  

---

### Answer by username_5 on 2017-10-03. Score: 0

If you want to just monitor large number public address, you can try [blockonomics wallet watcher](https://www.blockonomics.co/blockonomics). It is optimized to watch large number of address. In addition to this:

* You can get email notification of transactions
* Tag Addresses to group them
* See history of transactions


---

### Answer by username_6 on 2022-01-23. Score: 0

I have written a program in Python3 that allows you to search for any address on bitcoin core whether it belongs to your wallet or not.

Here is the github link:

<https://github.com/username_6/Bitcoin_Core_RPC_par_address>

Let me know what you think or if you have any improvements you might have.


---

