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?

1 Answer 1


The wallet is to a large extent separate from the rest of the node software. One of the reasons for this is because of the (slow) progress towards a working SPV mode. This means the wallet cannot depend on access to the UTXO set, as it won't be available in non-validating nodes.

However, it isn't needed. The wallet maintains an index of all input prevouts inside the wallet. Every output that is seen in a block, is to a wallet address, and which is not in this index as the input for another wallet transaction, is spendable.

  • Thanks. Does this mean that most transaction operations only happen within the wallet DB?
    – Yangrui
    Feb 16, 2017 at 21:33
  • What are 'transaction operations' ? Feb 16, 2017 at 23:37
  • 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
    Feb 17, 2017 at 9:46
  • 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. Feb 17, 2017 at 17:28

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.