Skip to main content

p2sh_sigop_count

Function p2sh_sigop_count 

Source
pub fn p2sh_sigop_count(tx: &Transaction, spent_outputs: &[Output]) -> u32
Expand description

Returns the total number of P2SH sigops across all inputs of tx.

Mirrors zcashd’s GetP2SHSigOpCount().

Coinbase transactions always return zero, matching zcashd’s early-return for tx.IsCoinBase(). Callers are therefore permitted to pass an empty spent_outputs slice for coinbase transactions (which is what the block-verifier does, since coinbase inputs have no previous output).

§Correctness

For non-coinbase transactions, spent_outputs.len() must equal the number of transparent inputs in tx. If the lengths differ, zip() silently truncates the longer iterator, causing an incorrect (undercount) result.