Skip to content

Commit

Permalink
descriptor: don't accept strings of the form tr(<key>,)
Browse files Browse the repository at this point in the history
  • Loading branch information
apoelstra committed Sep 1, 2024
1 parent 6401c22 commit 5147c6f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/descriptor/tr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -587,9 +587,6 @@ fn parse_tr_tree(s: &str) -> Result<expression::Tree, Error> {
return Err(Error::Unexpected("invalid taproot internal key".to_string()));
}
let internal_key = expression::Tree { name: key.name, args: vec![] };
if script.is_empty() {
return Ok(expression::Tree { name: "tr", args: vec![internal_key] });
}
let (tree, rest) = expression::Tree::from_slice_delim(script, 1, '{')?;
if rest.is_empty() {
Ok(expression::Tree { name: "tr", args: vec![internal_key, tree] })
Expand Down Expand Up @@ -770,6 +767,14 @@ mod tests {
desc.replace(&[' ', '\n'][..], "")
}

#[test]
fn regression_736() {
crate::Descriptor::<crate::DescriptorPublicKey>::from_str(
"tr(0000000000000000000000000000000000000000000000000000000000000002,)",
)
.unwrap_err();
}

#[test]
fn for_each() {
let desc = descriptor();
Expand Down

0 comments on commit 5147c6f

Please sign in to comment.