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

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)