From b41daadd7b42cf3627f57c24f5bb278a8ff2d12e Mon Sep 17 00:00:00 2001 From: Andrew Poelstra Date: Wed, 2 Jul 2025 16:19:28 +0000 Subject: [PATCH 1/3] DefiniteDescriptorKey: disallow multipath keys When deriving keys we refuse to allow multipath keys. We should forbid them when directly constructing them at all. --- src/descriptor/key.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/descriptor/key.rs b/src/descriptor/key.rs index 7bad264d7..c47921440 100644 --- a/src/descriptor/key.rs +++ b/src/descriptor/key.rs @@ -1058,7 +1058,7 @@ impl DefiniteDescriptorKey { /// /// Returns `None` if the key contains a wildcard fn new(key: DescriptorPublicKey) -> Option { - if key.has_wildcard() { + if key.has_wildcard() || key.is_multipath() { None } else { Some(Self(key)) @@ -1092,7 +1092,7 @@ impl FromStr for DefiniteDescriptorKey { fn from_str(s: &str) -> Result { let inner = DescriptorPublicKey::from_str(s)?; DefiniteDescriptorKey::new(inner).ok_or(DescriptorKeyParseError( - "cannot parse key with a wilcard as a DerivedDescriptorKey", + "cannot parse multi-path keys or keys with a wilcard as a DerivedDescriptorKey", )) } } From 29808ae706d87747d03f8507ec90461d612c3452 Mon Sep 17 00:00:00 2001 From: Andrew Poelstra Date: Wed, 2 Jul 2025 16:01:35 +0000 Subject: [PATCH 2/3] descriptor: add unit tests for constructing multipath keys --- src/descriptor/key.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/descriptor/key.rs b/src/descriptor/key.rs index c47921440..ac27202c2 100644 --- a/src/descriptor/key.rs +++ b/src/descriptor/key.rs @@ -1190,7 +1190,7 @@ mod test { DescriptorKeyParseError, DescriptorMultiXKey, DescriptorPublicKey, DescriptorSecretKey, MiniscriptKey, Wildcard, }; - use crate::prelude::*; + use crate::{prelude::*, DefiniteDescriptorKey}; #[test] fn parse_descriptor_key_errors() { @@ -1571,4 +1571,23 @@ mod test { let public_key = DescriptorPublicKey::from_str(desc).unwrap(); assert_tokens(&public_key, &[Token::String(desc)]); } + + #[test] + fn definite_keys() { + // basic xpub + let desc = "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8" + .parse::() + .unwrap(); + assert!(DefiniteDescriptorKey::new(desc).is_some()); + // xpub with wildcard + let desc = "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8/*" + .parse::() + .unwrap(); + assert!(DefiniteDescriptorKey::new(desc).is_none()); + // multipath xpub + let desc = "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8/<0;1>" + .parse::() + .unwrap(); + assert!(DefiniteDescriptorKey::new(desc).is_none()); + } } From 780d6bc49836751c15150e42e9c795b144fcc018 Mon Sep 17 00:00:00 2001 From: Andrew Poelstra Date: Wed, 2 Jul 2025 17:23:45 +0000 Subject: [PATCH 3/3] bump version to 10.2.2 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 5bcbd6233..929b508f5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "miniscript" -version = "10.2.1" +version = "10.2.2" authors = ["Andrew Poelstra , Sanket Kanjalkar "] license = "CC0-1.0" homepage = "https://github.com/rust-bitcoin/rust-miniscript/"