1

I know that the current UTXO set is the set of all unspent transaction outputs in the blockchain that is equal to the total number of all bitcoins mined currently and that each UTXO has a reference to its input UTXO that was unlocked to create it. I'm interested in understanding how Bitcoin establishes that each UTXO is proper initially before it begins to operate on further blocks. I assume this is a necessary initial step for any node syncing to the network in order to trust any future assumptions and validation on future UTXOs.

How are unspent TX output values verified? Does the bitcoin software walk back all UTXOs from the current UTXO set all the way to their coinbase block for "properness"?

Is there a way to walk forwards from the genesis block to compute the value of each UTXO as the UTXO set changes each block?

1 Answer 1

1

A transaction will consume some previously existing UTXOs as inputs, and it will create some new UTXOs as outputs. One of the checks to ensure the transaction is valid is ensuring that the value of the outputs is equal to or less than the value of the inputs (in most cases, it is less than, as the difference in value is claimed by the miner as the transaction fee).

So with each new transaction, nodes will check that the inputs are valid (ie, they are pre-existing UTXOs), and that the outputs do not sum to a larger value than those inputs.

Is there a way to walk forwards from the genesis block to compute the value of each UTXO as the UTXO set changes each block?

That is precisely how full nodes gain an accurate view of the network state (the UTXO set). Starting from block 1 (not the genesis block), nodes will create a 'UTXO set', which will be updated with each new valid block that the node hears about. This allows the node to maintain a UTXO set, that is used to validate new transactions/blocks.

3
  • Interesting. I would have thought it was the other way around, where a UTXO would have been calculated walking backwards as that is the only reference any node would have starting with the UTXO and the reference of the previous transaction(s) to compute the current UTXO, not the other way around (since going forwards can only be done once) but going backwards is always available.
    – LeanMan
    Commented Nov 5, 2021 at 2:24
  • 2
    @LeanMan it is simply more efficient to work forwards once and keep a continuously updated UTXO set, than it is to work backwards for each new transaction a node hears about. Especially in the (not uncommon) case where a UTXO may have a shared history with a massive number of previous outputs! Each node's 'reference point' is the genesis block that is hardcoded in, and it is from there that the node can work to independently figure out the state of the network.
    – chytrik
    Commented Nov 5, 2021 at 2:49
  • I was thinking that too. Thanks for the confirm!
    – LeanMan
    Commented Nov 5, 2021 at 3:29

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.