<p>It's possible to do this externally, but it's tricky to get right and might cause of loss of funds if you don't.</p>
<ul>
<li><p>You need to correctly identify transactions you can spend. This is relatively trivial with P2PKH addresses, but a little more involved if using more exotic script types. You need to understand rules like transaction maturity before considering a UTXO to be spendable.</p>
</li>
<li><p>You need to correctly handle reorganizations if a transaction changes its confirmation state or is invalidated by a change in its confirmation state and an alternative is included.</p>
</li>
<li><p>You need to manually walk every single block to find old transactions, or use the UTXO scanning feature to find ones which may be unspent. This is very time consuming and requires full retention of all blocks since genesis (or at the very least, the birthdate of the wallet). Repeating this if you want to monitor a new address with potentially old entries.</p>
</li>
<li><p>You need confidence that your code is correctly accounting, which is only something you can ensure.</p>
</li>
</ul>
<p>It's easier to use the built in wallet which handles all of this correctly, really.</p>

CC BY-SA 4.0
2020-01-04T23:04:02.897Z
That is the problem, I cannot use a built-in wallet, I am creating a wallet system to my application.
Allan Romanato
CC BY-SA 4.0
2020-01-05T00:02:07.617Z
Why can't you use the built in wallet? There's tools like watch only keys which be used for almost any application, if you don't want the wallet itself managing funds, it can at least handle UTXO identification and reoragnisations.
Claris
CC BY-SA 4.0
2020-01-04T08:40:58.917Z
2022-05-23T16:52:05.840Z
2022-05-23T16:52:05.840Z
Claris
<p>I have some generated Bitcoin addresses which I want to monitor for newly received transactions, I have a full node but I don't want to import those addresses to the node's wallet. I don't want to use any external service API like block.io or blockchain.com, I am working on my own code.</p>

<p>I want to keep this list of addresses in an external DB (MySql or Mongo) and I want to keep track of them until they receive let's say n confirmations.</p>

<p>I know I can user -blocknotify to receive information of newly mined blocks and with this new block I can scrape the transactions and look for the addresses I monitor. But how can I guarantee I will have all the UTXOs?</p>

<p>If the address is newly generated with the last block I can create my local DB with addresses information. But what should I do if I import (on my database, not Bitcoin Core wallet) an old address which had already been used, how can I check for UTXOs?</p>

<p>Also, how can I check if any of these monitored addresses have unconfirmed transactions?</p>

<bitcoin-core><transactions><blockchain><address>
How to monitor Bitcoin address for new transactions?
Allan Romanato
# How to monitor Bitcoin address for new transactions?

(Asked by: username_0 on 2020-01-04)

I have some generated Bitcoin addresses which I want to monitor for newly received transactions, I have a full node but I don't want to import those addresses to the node's wallet. I don't want to use any external service API like block.io or blockchain.com, I am working on my own code.

I want to keep this list of addresses in an external DB (MySql or Mongo) and I want to keep track of them until they receive let's say n confirmations.

I know I can user -blocknotify to receive information of newly mined blocks and with this new block I can scrape the transactions and look for the addresses I monitor. But how can I guarantee I will have all the UTXOs?

If the address is newly generated with the last block I can create my local DB with addresses information. But what should I do if I import (on my database, not Bitcoin Core wallet) an old address which had already been used, how can I check for UTXOs?

Also, how can I check if any of these monitored addresses have unconfirmed transactions?

**Tags:** bitcoin-core, transactions, blockchain, address


---

## 1 answers

### Answer by username_1 on 2020-01-04. Score: 1

It's possible to do this externally, but it's tricky to get right and might cause of loss of funds if you don't.

* You need to correctly identify transactions you can spend. This is relatively trivial with P2PKH addresses, but a little more involved if using more exotic script types. You need to understand rules like transaction maturity before considering a UTXO to be spendable.
* You need to correctly handle reorganizations if a transaction changes its confirmation state or is invalidated by a change in its confirmation state and an alternative is included.
* You need to manually walk every single block to find old transactions, or use the UTXO scanning feature to find ones which may be unspent. This is very time consuming and requires full retention of all blocks since genesis (or at the very least, the birthdate of the wallet). Repeating this if you want to monitor a new address with potentially old entries.
* You need confidence that your code is correctly accounting, which is only something you can ensure.

It's easier to use the built in wallet which handles all of this correctly, really.

> **Comments:**
> **username_0**: That is the problem, I cannot use a built-in wallet, I am creating a wallet system to my application.  
> **username_1**: Why can't you use the built in wallet? There's tools like watch only keys which be used for almost any application, if you don't want the wallet itself managing funds, it can at least handle UTXO identification and reoragnisations.  

---

