fn parse_xpub_deriv(
        key_deriv: &str,
    ) -> Result<(bip32::ExtendedPubKey, bip32::DerivationPath, bool), DescriptorKeyParseError> {
        let mut key_deriv = key_deriv.split('/');
        let xpub_str = key_deriv.next().ok_or(DescriptorKeyParseError(
            "No key found after origin description",
        ))?;
        let xpub = bip32::ExtendedPubKey::from_str(xpub_str)
            .map_err(|_| DescriptorKeyParseError("Error while parsing xpub."))?;

        let mut is_wildcard = false;
        let derivation_path = key_deriv
            .filter_map(|p| {
                if !is_wildcard && p == "*" {
                    is_wildcard = true;
                    None
                } else if !is_wildcard && p == "*'" {
                    Some(Err(DescriptorKeyParseError(
                        "Hardened derivation is currently not supported.",
                    )))
                } else if is_wildcard {
                    Some(Err(DescriptorKeyParseError(
                        "'*' may only appear as last element in a derivation path.",
                    )))
                } else {
                    Some(bip32::ChildNumber::from_str(p).map_err(|_| {
                        DescriptorKeyParseError("Error while parsing key derivation path")
                    }))
                }
            })
            .collect::<Result<bip32::DerivationPath, _>>()?;

        if (&derivation_path).into_iter().all(|c| c.is_normal()) {
            Ok((xpub, derivation_path, is_wildcard))
        } else {
            Err(DescriptorKeyParseError(
                "Hardened derivation is currently not supported.",
            ))
        }
    }
/// Parse an extended public key concatenated to a derivation path.
Parse an extended public key concatenated to a derivation path.
Parse an extended public key concatenated to a derivation path .
fn parse_xpub_deriv(
        key_deriv: &str,
    ) -> Result<(bip32::ExtendedPubKey, bip32::DerivationPath, bool), DescriptorKeyParseError> {
        let mut key_deriv = key_deriv.split('/');
        let xpub_str = key_deriv.next().ok_or(DescriptorKeyParseError(
            "No key found after origin description",
        ))?;
        let xpub = bip32::ExtendedPubKey::from_str(xpub_str)
            .map_err(|_| DescriptorKeyParseError("Error while parsing xpub."))?;
        let mut is_wildcard = false;
        let derivation_path = key_deriv
            .filter_map(|p| {
                if !is_wildcard && p == "*" {
                    is_wildcard = true;
                    None
                } else if !is_wildcard && p == "*'" {
                    Some(Err(DescriptorKeyParseError(
                        "Hardened derivation is currently not supported.",
                    )))
                } else if is_wildcard {
                    Some(Err(DescriptorKeyParseError(
                        "'*' may only appear as last element in a derivation path.",
                    )))
                } else {
                    Some(bip32::ChildNumber::from_str(p).map_err(|_| {
                        DescriptorKeyParseError("Error while parsing key derivation path")
                    }))
                }
            })
            .collect::<Result<bip32::DerivationPath, _>>()?;
        if (&derivation_path).into_iter().all(|c| c.is_normal()) {
            Ok((xpub, derivation_path, is_wildcard))
        } else {
            Err(DescriptorKeyParseError(
                "Hardened derivation is currently not supported.",
            ))
        }
    }
fn parse_xpub_deriv ( key_deriv : & str , ) -> Result < ( bip32 :: ExtendedPubKey , bip32 :: DerivationPath , bool ) , DescriptorKeyParseError > { let mut key_deriv = key_deriv . split ( '/' ) ; let xpub_str = key_deriv . next ( ) . ok_or ( DescriptorKeyParseError ( " " , ) ) ? ; let xpub = bip32 :: ExtendedPubKey :: from_str ( xpub_str ) . map_err ( | _ | DescriptorKeyParseError ( " " ) ) ? ; let mut is_wildcard = false ; let derivation_path = key_deriv . filter_map ( | p | { if ! is_wildcard && p == " " { is_wildcard = true ; None } else if ! is_wildcard && p == " " { Some ( Err ( DescriptorKeyParseError ( " " , ) ) ) } else if is_wildcard { Some ( Err ( DescriptorKeyParseError ( " " , ) ) ) } else { Some ( bip32 :: ChildNumber :: from_str ( p ) . map_err ( | _ | { DescriptorKeyParseError ( " " ) } ) ) } } ) . collect :: < Result < bip32 :: DerivationPath , _ > > ( ) ? ; if ( & derivation_path ) . into_iter ( ) . all ( | c | c . is_normal ( ) ) { Ok ( ( xpub , derivation_path , is_wildcard ) ) } else { Err ( DescriptorKeyParseError ( " " , ) ) } }
Parse an extended public key concatenated to a derivation path.
Parse an extended public key concatenated to a derivation path .
key_deriv
&str
key_deriv
&str