Skip to content

Commit 73473b5

Browse files
committed
Merge #833: backport #830 to rust-miniscript 10.x
780d6bc bump version to 10.2.2 (Andrew Poelstra) 29808ae descriptor: add unit tests for constructing multipath keys (Andrew Poelstra) b41daad DefiniteDescriptorKey: disallow multipath keys (Andrew Poelstra) Pull request description: Just the logic fix; the error refactoring doesn't apply. ACKs for top commit: sanket1729: tACK 780d6bc. Tree-SHA512: 97ba6bd8c475650da03614e4f8477f568d984c71c09ba2cf4141e80a1facba70d8067f9a0a70fb614e66d0663c3653608f6b7a2df456bb5668adc14eebfb9e2c
2 parents c585c27 + 780d6bc commit 73473b5

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "miniscript"
3-
version = "10.2.1"
3+
version = "10.2.2"
44
authors = ["Andrew Poelstra <apoelstra@wpsoftware.net>, Sanket Kanjalkar <sanket1729@gmail.com>"]
55
license = "CC0-1.0"
66
homepage = "https://github.com/rust-bitcoin/rust-miniscript/"

src/descriptor/key.rs

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,7 @@ impl DefiniteDescriptorKey {
10581058
///
10591059
/// Returns `None` if the key contains a wildcard
10601060
fn new(key: DescriptorPublicKey) -> Option<Self> {
1061-
if key.has_wildcard() {
1061+
if key.has_wildcard() || key.is_multipath() {
10621062
None
10631063
} else {
10641064
Some(Self(key))
@@ -1092,7 +1092,7 @@ impl FromStr for DefiniteDescriptorKey {
10921092
fn from_str(s: &str) -> Result<Self, Self::Err> {
10931093
let inner = DescriptorPublicKey::from_str(s)?;
10941094
DefiniteDescriptorKey::new(inner).ok_or(DescriptorKeyParseError(
1095-
"cannot parse key with a wilcard as a DerivedDescriptorKey",
1095+
"cannot parse multi-path keys or keys with a wilcard as a DerivedDescriptorKey",
10961096
))
10971097
}
10981098
}
@@ -1190,7 +1190,7 @@ mod test {
11901190
DescriptorKeyParseError, DescriptorMultiXKey, DescriptorPublicKey, DescriptorSecretKey,
11911191
MiniscriptKey, Wildcard,
11921192
};
1193-
use crate::prelude::*;
1193+
use crate::{prelude::*, DefiniteDescriptorKey};
11941194

11951195
#[test]
11961196
fn parse_descriptor_key_errors() {
@@ -1571,4 +1571,23 @@ mod test {
15711571
let public_key = DescriptorPublicKey::from_str(desc).unwrap();
15721572
assert_tokens(&public_key, &[Token::String(desc)]);
15731573
}
1574+
1575+
#[test]
1576+
fn definite_keys() {
1577+
// basic xpub
1578+
let desc = "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8"
1579+
.parse::<DescriptorPublicKey>()
1580+
.unwrap();
1581+
assert!(DefiniteDescriptorKey::new(desc).is_some());
1582+
// xpub with wildcard
1583+
let desc = "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8/*"
1584+
.parse::<DescriptorPublicKey>()
1585+
.unwrap();
1586+
assert!(DefiniteDescriptorKey::new(desc).is_none());
1587+
// multipath xpub
1588+
let desc = "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8/<0;1>"
1589+
.parse::<DescriptorPublicKey>()
1590+
.unwrap();
1591+
assert!(DefiniteDescriptorKey::new(desc).is_none());
1592+
}
15741593
}

0 commit comments

Comments
 (0)