Skip to content

Commit 6d8ed86

Browse files
committed
Fix tr descriptor parsing bug
Tr::from_str works correctly, but the descriptor::from_str() for taproot does not work correctly. This is because of a special case impl for FromTree of tr descriptors as they contain both { and ( braces.
1 parent c1b516c commit 6d8ed86

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/descriptor/mod.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -740,8 +740,14 @@ where
740740

741741
fn from_str(s: &str) -> Result<Descriptor<Pk>, Error> {
742742
let desc_str = verify_checksum(s)?;
743-
let top = expression::Tree::from_str(desc_str)?;
744-
expression::FromTree::from_tree(&top)
743+
// tr tree parsing has special code
744+
if desc_str.starts_with("tr") {
745+
let tr = Tr::from_str(desc_str)?;
746+
Ok(Descriptor::Tr(tr))
747+
} else {
748+
let top = expression::Tree::from_str(desc_str)?;
749+
expression::FromTree::from_tree(&top)
750+
}
745751
}
746752
}
747753

0 commit comments

Comments
 (0)