fn transparent_spend_chain_order(
    spend: OutPoint,
    spend_tx_index_in_block: usize,
    block_new_outputs: &HashMap<OutPoint, OrderedUtxo>,
    non_finalized_chain_unspent_utxos: &HashMap<OutPoint, OrderedUtxo>,
    non_finalized_chain_spent_utxos: &HashSet<OutPoint>,
    finalized_state: &ZebraDb,
) -> Result<OrderedUtxo, ValidateContextError>
Expand description

Check that transparent spends occur in chain order.

Because we are in the non-finalized state, we need to check spends within the same block, spent non-finalized UTXOs, and unspent non-finalized and finalized UTXOs.

“Any input within this block can spend an output which also appears in this block (assuming the spend is otherwise valid). However, the TXID corresponding to the output must be placed at some point before the TXID corresponding to the input. This ensures that any program parsing block chain transactions linearly will encounter each output before it is used as an input.”

https://developer.bitcoin.org/reference/block_chain.html#merkle-trees

“each output of a particular transaction can only be used as an input once in the block chain. Any subsequent reference is a forbidden double spend- an attempt to spend the same satoshis twice.”

https://developer.bitcoin.org/devguide/block_chain.html#introduction

§Consensus

Every non-null prevout MUST point to a unique UTXO in either a preceding block, or a previous transaction in the same block.

https://zips.z.cash/protocol/protocol.pdf#txnconsensus