Skip to main content

check_tx_inputs

Function check_tx_inputs 

Source
pub fn check_tx_inputs<U>(
    tx: &Transaction,
    utxo_set: &U,
    height: u64,
) -> Result<(ValidationResult, i64), ConsensusError>
where U: UtxoLookup,
Expand description

Spec-locked to Orange Paper Section 5.1: CheckTxInputs

CheckTxInputs: 𝒯𝒳 × 𝒰𝒮 × ℕ → {valid, invalid} × ℤ

For transaction tx with UTXO set us at height h:

  1. If tx is coinbase: return (valid, 0)
  2. If tx is not coinbase: ∀i ∈ ins: ¬i.prevout.IsNull() (Orange Paper Section 5.1, rule 6)
  3. Let total_in = Σᵢ us(i.prevout).value
  4. Let total_out = Σₒ o.value
  5. If total_in < total_out: return (invalid, 0)
  6. Return (valid, total_in - total_out)