diff --git a/src/util/psbt/map/output.rs b/src/util/psbt/map/output.rs index 84dc3cd1..3842bb23 100644 --- a/src/util/psbt/map/output.rs +++ b/src/util/psbt/map/output.rs @@ -135,18 +135,18 @@ impl TapTree { self.0.branch()[0].as_ref().expect("from_inner only parses is_complete builders") } - /// Converts a [`TaprootBuilder`] into a tree if it is complete binary tree. + /// Constructs [`TapTree`] from a [`TaprootBuilder`] if it is complete binary tree. /// /// # Returns - /// A [`TapTree`] iff the `inner` builder is complete, otherwise return [`IncompleteTapTree`] - /// error with the content of incomplete builder `inner` instance. - pub fn from_inner(inner: TaprootBuilder) -> Result { - if !inner.is_finalized() { - Err(IncompleteTapTree::NotFinalized(inner)) - } else if inner.has_hidden_nodes() { - Err(IncompleteTapTree::HiddenParts(inner)) + /// A [`TapTree`] iff the `builder` is complete, otherwise return [`IncompleteTapTree`] + /// error with the content of incomplete `builder` instance. + pub fn from_builder(builder: TaprootBuilder) -> Result { + if !builder.is_finalized() { + Err(IncompleteTapTree::NotFinalized(builder)) + } else if builder.has_hidden_nodes() { + Err(IncompleteTapTree::HiddenParts(builder)) } else { - Ok(TapTree(inner)) + Ok(TapTree(builder)) } } diff --git a/src/util/psbt/serialize.rs b/src/util/psbt/serialize.rs index 3c946ec7..09fc8c7a 100644 --- a/src/util/psbt/serialize.rs +++ b/src/util/psbt/serialize.rs @@ -393,14 +393,14 @@ mod tests { let mut builder = compose_taproot_builder(0x51, &[2, 2, 2]); builder = builder.add_leaf_with_ver(3, Script::from_hex("b9").unwrap(), LeafVersion::from_consensus(0xC2).unwrap()).unwrap(); builder = builder.add_hidden_node(3, sha256::Hash::default()).unwrap(); - assert!(TapTree::from_inner(builder.clone()).is_err()); + assert!(TapTree::from_builder(builder.clone()).is_err()); } #[test] fn taptree_roundtrip() { let mut builder = compose_taproot_builder(0x51, &[2, 2, 2, 3]); builder = builder.add_leaf_with_ver(3, Script::from_hex("b9").unwrap(), LeafVersion::from_consensus(0xC2).unwrap()).unwrap(); - let tree = TapTree::from_inner(builder).unwrap(); + let tree = TapTree::from_builder(builder).unwrap(); let tree_prime = TapTree::deserialize(&tree.serialize()).unwrap(); assert_eq!(tree, tree_prime); }