Skip to content

Commit 9c55ad3

Browse files
author
Scott Robinson
committed
Simplify DescriptorPublicKey::from_str
1 parent 687fd4e commit 9c55ad3

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

src/descriptor/key.rs

+2-13
Original file line numberDiff line numberDiff line change
@@ -534,19 +534,8 @@ impl FromStr for DescriptorPublicKey {
534534
type Err = DescriptorKeyParseError;
535535

536536
fn from_str(s: &str) -> Result<Self, Self::Err> {
537-
// A "raw" public key without any origin is the least we accept.
538-
if s.len() < 64 {
539-
return Err(DescriptorKeyParseError(
540-
"Key too short (<66 char), doesn't match any format",
541-
));
542-
}
543-
544-
let (key_part, origin) = parse_key_origin(s)?;
545-
546-
if key_part.contains("pub") {
547-
let (xpub, derivation_paths, wildcard) =
548-
parse_xkey_deriv::<bip32::ExtendedPubKey>(key_part)?;
549-
if derivation_paths.len() > 1 {
537+
if s.contains("pub") {
538+
if s.contains("<") {
550539
DescriptorMultiExtendedPublicKey::from_str(s).map(Self::MultiXPub)
551540
} else {
552541
DescriptorExtendedPublicKey::from_str(s).map(Self::XPub)

0 commit comments

Comments
 (0)