Skip to main content

Module mining

Module mining 

Source

Structs§

BlockTemplate
BlockTemplate: Interface for mining software

Enums§

MiningResult
Result of mining attempt

Functions§

append_witness_commitment
BIP141: coinbase wtxid is 0, so appending the OP_RETURN does not change the witness root. Empty stacks when nested is None (legacy). Prefer append_witness_commitment_from_nested when mempool witnesses are known.
append_witness_commitment_from_nested
Same as append_witness_commitment, using per-tx per-input stacks. nested[i] is the witness for txs[i]. Coinbase wtxid stays 0.
calculate_merkle_root
Calculate merkle root using proper Bitcoin Merkle tree construction
calculate_merkle_root_from_tx_ids
Build merkle tree from pre-computed leaf hashes.
check_template_weight
Weight of coinbase + selected txs (empty stacks if none stored). Uses Bitcoin MAX_BLOCK_WEIGHT (4_000_000). Not an invented pool cap.
compute_merkle_root_and_mutated
Compute merkle root and CVE-2012-2459 mutation flag without aborting on mutation. Computes merkle root from leaves with optional mutation detection — always returns a root. Callers decide policy: CheckBlock rejects mutated blocks; ConnectBlock may skip the check for already-accepted blocks.
create_block_template
Create a block template for mining
create_block_template_declared
Stage 3b slice 1: miner-declared mempool subset. Resolves declared_txids, builds the Stage 3a template, and errors if the selected non-coinbase txids are not exactly that list (no silent skip). Empty declared_txids is coinbase-only. Spec-locked builders are unchanged. Overweight uses Bitcoin MAX_BLOCK_WEIGHT (not a pool-invented cap).
create_block_template_with_outputs
Same as create_block_template, then replace the coinbase and merkle root.
create_coinbase_with_outputs
Multi-output coinbase. Callers set values (subsidy + fees). Empty list is an error. Witness commitment is appended by create_block_template_with_outputs / Stratum.
create_new_block
CreateNewBlock: 𝒰𝒮 × 𝒯𝒳* → ℬ
create_new_block_with_time
CreateNewBlock variant that accepts an explicit block_time.
fit_payouts_to_reward
If payouts exceed subsidy+fees, error. Shortfall is added to the first output.
mine_block
MineBlock: ℬ × ℕ → ℬ × {success, failure}
resolve_declared_txs
Resolve named txids from a mempool list, in declaration order. Unknown or duplicate txids are errors. An empty list is allowed (coinbase-only).
sum_selected_fees
Fees of selected (non-coinbase) txs. Missing UTXOs count as 0 so empty-set tests still run.
template_block_version
Minimum header version check_bip90 accepts at height.