Skip to content

Commit

Permalink
derive: support merkle root production for a single-leaf tap trees
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Dec 24, 2023
1 parent 49fea91 commit 4a234b9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions derive/src/taptree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,11 @@ impl TapTree {
}

pub fn merkle_root(&self) -> TapNodeHash {
// TODO: implement TapTree::merkle_root
todo!()
if self.0.len() == 1 {
TapLeafHash::with_leaf_script(&self.0[0].script).into()
} else {
todo!("implement TapTree::merkle_root for trees with more than one leaf")
}
}

pub fn into_vec(self) -> Vec<LeafInfo> { self.0 }
Expand Down

0 comments on commit 4a234b9

Please sign in to comment.