Skip to content

Commit 8212b9c

Browse files
committed
Add breaking test testing x-only keys in non-tr descriptors
This commit can be re-arranged to check that this fails before the fix
1 parent 7ef4fdc commit 8212b9c

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/descriptor/mod.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1721,4 +1721,19 @@ pk(03f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8))";
17211721
let descriptor: Descriptor<DescriptorPublicKey> = descriptor_str.parse().unwrap();
17221722
assert_eq!(descriptor.to_string(), "sh(wsh(pk(xpub6ERApfZwUNrhLCkDtcHTcxd75RbzS1ed54G1LkBUHQVHQKqhMkhgbmJbZRkrgZw4koxb5JaHWkY4ALHY2grBGRjaDMzQLcgJvLJuZZvRcEL)))#6c6hwr22");
17231723
}
1724+
1725+
#[test]
1726+
fn test_xonly_keys() {
1727+
let comp_key = "0308c0fcf8895f4361b4fc77afe2ad53b0bd27dcebfd863421b2b246dc283d4103";
1728+
let x_only_key = "08c0fcf8895f4361b4fc77afe2ad53b0bd27dcebfd863421b2b246dc283d4103";
1729+
1730+
// Both x-only keys and comp keys allowed in tr
1731+
Descriptor::<DescriptorPublicKey>::from_str(&format!("tr({})", comp_key)).unwrap();
1732+
Descriptor::<DescriptorPublicKey>::from_str(&format!("tr({})", x_only_key)).unwrap();
1733+
1734+
// Only compressed keys allowed in wsh
1735+
Descriptor::<DescriptorPublicKey>::from_str(&format!("wsh(pk({}))", comp_key)).unwrap();
1736+
Descriptor::<DescriptorPublicKey>::from_str(&format!("wsh(pk({}))", x_only_key))
1737+
.unwrap_err();
1738+
}
17241739
}

0 commit comments

Comments
 (0)