pub fn apply_transaction(
tx: &Transaction,
utxo_set: HashMap<OutPoint, Arc<UTXO>, FxBuildHasher>,
height: u64,
) -> Result<(HashMap<OutPoint, Arc<UTXO>, FxBuildHasher>, Vec<UndoEntry>), ConsensusError>Expand description
ApplyTransaction (Orange Paper 5.3.2)
For transaction tx and UTXO set us:
- If tx is coinbase: us’ = us ∪ {(tx.id, i) ↦ tx.outputs[i] : i ∈ [0, |tx.outputs|)}
- Otherwise: us’ = (us \ {i.prevout : i ∈ tx.inputs}) ∪ {(tx.id, i) ↦ tx.outputs[i] : i ∈ [0, |tx.outputs|)}
- Return us’
This function computes the transaction ID internally.
For batch operations, use apply_transaction_with_id instead.
Returns both the new UTXO set and undo entries for all UTXO changes.