Skip to main content

compute_spends_root

Function compute_spends_root 

Source
pub fn compute_spends_root(spend_bundles: &[SpendBundle]) -> Bytes32
Expand description

Spends root (header spends_root, SPEC §3.3) — Merkle root over ordered spend-bundle leaf digests.

Normative: HSH-003. Algorithm: empty slice → EMPTY_ROOT; else a binary Merkle tree (chia_sdk_types::MerkleTree::new) over leaves SHA-256(bundle.to_bytes()) in slice order (block order). Tagged hashing inside the tree follows HSH-007 using the same chia-sdk-types implementation.

Equivalence: For valid in-memory bundles, SHA-256(to_bytes()) matches SpendBundle::name because Chia’s streamable hash() hashes the same serialized bytes (Streamable::hash).

Callers: crate::L2Block::compute_spends_root delegates here so block bodies and standalone bundle slices share one definition.