From ef617d5cae6bf2e64c18a334133724aec0360512 Mon Sep 17 00:00:00 2001 From: Scott Robinson Date: Mon, 24 Jul 2023 20:59:23 +1000 Subject: [PATCH] Simplify DescriptorPublicKey::from_str --- src/descriptor/key.rs | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/descriptor/key.rs b/src/descriptor/key.rs index b445739cc..56312d190 100644 --- a/src/descriptor/key.rs +++ b/src/descriptor/key.rs @@ -534,19 +534,8 @@ impl FromStr for DescriptorPublicKey { type Err = DescriptorKeyParseError; fn from_str(s: &str) -> Result { - // A "raw" public key without any origin is the least we accept. - if s.len() < 64 { - return Err(DescriptorKeyParseError( - "Key too short (<66 char), doesn't match any format", - )); - } - - let (key_part, origin) = parse_key_origin(s)?; - - if key_part.contains("pub") { - let (xpub, derivation_paths, wildcard) = - parse_xkey_deriv::(key_part)?; - if derivation_paths.len() > 1 { + if s.contains("pub") { + if s.contains("<") { DescriptorMultiExtendedPublicKey::from_str(s).map(Self::MultiXPub) } else { DescriptorExtendedPublicKey::from_str(s).map(Self::XPub)