I want to avoid physically importing addresses into a wallet. I want to write a UTXO indexing system on a per-address basis.

I often wonder how a wallet can keep track of all of its addresses UTXOs, seeing as transaction outputs can become spent and are therefore no longer spendable.

My concept, as it stands, is to record every vout, of an incoming transaction, against its corresponding address.

So now we have a database of addresses, each with a relation to some txId and vout index that holds the address.

From there, gettxout can be used on each of an address's transactions corresponding to its vout index.

If gettxout responds empty the address's vout has been spent, so is not deemed spendable and does not contribute to calculating the address's balance.

If gettxout responds with a result the address's vout remains unspent, so is spendable and contributes to the address's balance.

This would obviously only work for addresses where this indexing approach has been implemented. Is this a good idea?

TLDR; how would one go about building a custom index, on top of a Bitcoin node, to track UTXOs, belonging to addresses, given that any vout can become spent?

  • I might do a longer answer tomorrow when I have time, but you should look into how electrumx structures its data to allow for fast querying across the entire utxo set Nov 13 '20 at 16:25
  • Looking forward to it.
    – Luka
    Nov 13 '20 at 17:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.