Skip to main content

Module segwit

Module segwit 

Source

Functions§

calculate_block_weight
Calculate block weight for SegWit blocks
calculate_block_weight_from_nested
Calculate block weight from nested witnesses without flattening. Accepts &[Vec<Witness>] where each Vec<Witness> is one tx’s input witness stacks. Avoids allocating the flattened structure in the hot block validation path. Orange Paper 11.1.1: Weight(tx) = 4 × BaseSize + TotalSize
calculate_transaction_weight
Calculate transaction weight for SegWit Weight(tx) = 4 × |Serialize(tx ∖ witness)| + |Serialize(tx)|
compute_witness_merkle_root
Compute witness merkle root for block WitnessRoot = ComputeMerkleRoot({Hash(tx.witness) : tx ∈ block.transactions})
compute_witness_merkle_root_from_nested
Compute witness merkle root from nested witnesses without flattening. Accepts &[Vec<Witness>] where each Vec<Witness> is one tx’s input stacks. Avoids allocating flattened structure in block validation hot path. Orange Paper 11.1.4: WitnessRoot = ComputeMerkleRoot({wtxid : tx ∈ block.transactions})
is_segwit_transaction
Check if transaction is SegWit (v0) or Taproot (v1) based on outputs
validate_segwit_block
Validate SegWit block
validate_witness_commitment
Validate witness commitment in coinbase transaction.

Type Aliases§

Witness
Witness data: stack of witness elements (SegWit/Taproot)