pub enum TapTree {
Leaf(TapLeaf),
Branch(Box<TapTree>, Box<TapTree>),
}Expand description
A node in the Taproot Merkle tree.
Variants§
Leaf(TapLeaf)
A leaf node containing a script.
Branch(Box<TapTree>, Box<TapTree>)
A branch node with two children.
Implementations§
Source§impl TapTree
impl TapTree
Sourcepub fn merkle_root(&self) -> [u8; 32]
pub fn merkle_root(&self) -> [u8; 32]
Compute the merkle root hash of this tree node.
- Leaf:
tagged_hash("TapLeaf", ...) - Branch:
tagged_hash("TapBranch", sort(left, right))
Sourcepub fn merkle_proof(&self, target_leaf: &TapLeaf) -> Option<Vec<[u8; 32]>>
pub fn merkle_proof(&self, target_leaf: &TapLeaf) -> Option<Vec<[u8; 32]>>
Compute the merkle proof (path) for a specific leaf.
Returns Some(path) where path is a list of 32-byte hashes,
or None if the leaf is not found in this tree.
Sourcepub fn leaf_count(&self) -> usize
pub fn leaf_count(&self) -> usize
Count the total number of leaves in this tree.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TapTree
impl RefUnwindSafe for TapTree
impl Send for TapTree
impl Sync for TapTree
impl Unpin for TapTree
impl UnsafeUnpin for TapTree
impl UnwindSafe for TapTree
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more