1

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?

1 Answer 1

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.

2
  • That is the problem, I cannot use a built-in wallet, I am creating a wallet system to my application. Commented Jan 4, 2020 at 23:04
  • 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
    Commented Jan 5, 2020 at 0:02

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.