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.
calculate_transaction_weight
Calculate transaction weight for SegWit BIP141: Weight(tx) = 3 × BaseSize(tx) + TotalSize(tx)
compute_witness_merkle_root
Compute witness merkle root for block (legacy flat witness layout).
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
transaction_weight_from_stacks
Weight of one transaction: 3 × stripped size + total size.
validate_segwit_block
Validate SegWit block
validate_witness_commitment
Validate witness commitment in coinbase transaction.
witness_commitment_script
BIP141 coinbase OP_RETURN: OP_RETURN 0x24 0xaa21a9ed || sha256d(root || nonce).

Type Aliases§

Witness
Witness Data: 𝒲 = 𝕊* (stack of witness elements)