1
So, I found that in the original Bitcoin client there was a member variable vSpent in the class CWalletTX, however it appears that this is no longer the case in the new version. I know that the new Bitcoin client uses UTXO DB to store the unspent transactions. My question is that since LevelDB is a key-value database, and the UTXO key is derived from transaction outpoint, how does the client find the Txs that belongs to the wallet owner? Does it iterate over all unspent transactions and find those containing the public key of the receiver?
Thanks. Does this mean that most transaction operations only happen within the wallet DB? – Yangrui – 2017-02-16T21:33:33.733
What are 'transaction operations' ? – Pieter Wuille – 2017-02-16T23:37:45.337
Such as spending some coins, calculating the balance. I'm a bit confused by the IsMine method of a transaction. It returns Solver(scriptPubKey, scriptSig) result. Does this mean that before spending a transaction, it must be checked against all keys in the wallet? – Yangrui – 2017-02-17T09:46:11.550
Wallet operations like spending coins and calculating the balance only look at the list of wallet transactions and keys. As said, that's independent from the validation part. The UTXO set is only used for checking whether blocks and transactions are valid. Yes, IsMine checks against all wallet keys, but there are very fast indexes for that. – Pieter Wuille – 2017-02-17T17:28:04.887