Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "miniscript"
version = "11.2.1"
version = "11.2.2"
authors = ["Andrew Poelstra <apoelstra@wpsoftware.net>, Sanket Kanjalkar <sanket1729@gmail.com>"]
license = "CC0-1.0"
homepage = "https://github.com/rust-bitcoin/rust-miniscript/"
Expand Down
25 changes: 22 additions & 3 deletions src/descriptor/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1038,7 +1038,7 @@ impl DefiniteDescriptorKey {
///
/// Returns `None` if the key contains a wildcard
fn new(key: DescriptorPublicKey) -> Option<Self> {
if key.has_wildcard() {
if key.has_wildcard() || key.is_multipath() {
None
} else {
Some(Self(key))
Expand Down Expand Up @@ -1072,7 +1072,7 @@ impl FromStr for DefiniteDescriptorKey {
fn from_str(s: &str) -> Result<Self, Self::Err> {
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",
))
}
}
Expand Down Expand Up @@ -1150,7 +1150,7 @@ mod test {
DescriptorKeyParseError, DescriptorMultiXKey, DescriptorPublicKey, DescriptorSecretKey,
MiniscriptKey, Wildcard,
};
use crate::prelude::*;
use crate::{prelude::*, DefiniteDescriptorKey};

#[test]
fn parse_descriptor_key_errors() {
Expand Down Expand Up @@ -1498,4 +1498,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::<DescriptorPublicKey>()
.unwrap();
assert!(DefiniteDescriptorKey::new(desc).is_some());
// xpub with wildcard
let desc = "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8/*"
.parse::<DescriptorPublicKey>()
.unwrap();
assert!(DefiniteDescriptorKey::new(desc).is_none());
// multipath xpub
let desc = "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8/<0;1>"
.parse::<DescriptorPublicKey>()
.unwrap();
assert!(DefiniteDescriptorKey::new(desc).is_none());
}
}
Loading