Skip to content

Commit

Permalink
descriptor: reject strings of the form "tr(<key>,)"
Browse files Browse the repository at this point in the history
Fixes #736
  • Loading branch information
apoelstra committed Sep 1, 2024
1 parent 00cac40 commit 67fdc50
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 8 additions & 0 deletions src/descriptor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2011,6 +2011,14 @@ pk(03f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8))";
Descriptor::<DescriptorPublicKey>::from_str("wsh(andor(pk(tpubDEN9WSToTyy9ZQfaYqSKfmVqmq1VVLNtYfj3Vkqh67et57eJ5sTKZQBkHqSwPUsoSskJeaYnPttHe2VrkCsKA27kUaN9SDc5zhqeLzKa1rr/0'/<0;1;2;3>/*),older(10000),pk(tpubD8LYfn6njiA2inCoxwM7EuN3cuLVcaHAwLYeups13dpevd3nHLRdK9NdQksWXrhLQVxcUZRpnp5CkJ1FhE61WRAsHxDNAkvGkoQkAeWDYjV/8/<0;1;2>/*)))").unwrap_err();
}

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

#[test]
fn regression_734() {
Descriptor::<DescriptorPublicKey>::from_str(
Expand Down
3 changes: 0 additions & 3 deletions src/descriptor/tr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -603,9 +603,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

0 comments on commit 67fdc50

Please sign in to comment.