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
vout index that holds the address.
From there, gettxout can be used on each of an address’s transactions corresponding to its
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.
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?