fn to_public<C: Signing>(
        &self,
        secp: &Secp256k1<C>,
    ) -> Result<DescriptorXKey<bip32::ExtendedPubKey>, DescriptorKeyParseError> {
        let unhardened = self
            .derivation_path
            .into_iter()
            .rev()
            .take_while(|c| c.is_normal())
            .count();
        let last_hardened_idx = self.derivation_path.len() - unhardened;

        let hardened_path = &self.derivation_path[..last_hardened_idx];
        let unhardened_path = &self.derivation_path[last_hardened_idx..];

        let xprv = self
            .xkey
            .derive_priv(secp, &hardened_path)
            .map_err(|_| DescriptorKeyParseError("Unable to derive the hardened steps"))?;
        let xpub = bip32::ExtendedPubKey::from_priv(secp, &xprv);

        let origin = match &self.origin {
            Some((fingerprint, path)) => Some((
                *fingerprint,
                path.into_iter()
                    .chain(hardened_path.iter())
                    .cloned()
                    .collect(),
            )),
            None => {
                if hardened_path.is_empty() {
                    None
                } else {
                    Some((self.xkey.fingerprint(secp), hardened_path.into()))
                }
            }
        };

        Ok(DescriptorXKey {
            origin,
            xkey: xpub,
            derivation_path: unhardened_path.into(),
            wildcard: self.wildcard,
        })
    }
/// Returns the public version of this key, applying all the hardened derivation steps on the
/// private key before turning it into a public key.
///
/// If the key already has an origin, the derivation steps applied will be appended to the path
/// already present, otherwise this key will be treated as a master key and an origin will be
/// added with this key's fingerprint and the derivation steps applied.
Returns the public version of this key, applying all the hardened derivation steps on the
private key before turning it into a public key.

If the key already has an origin, the derivation steps applied will be appended to the path
already present, otherwise this key will be treated as a master key and an origin will be
added with this key's fingerprint and the derivation steps applied.
Returns the public version of this key applying all the hardened derivation steps on the private key before turning it into a public key . If the key already has an origin the derivation steps applied will be appended to the path already present otherwise this key will be treated as a master key and an origin will be added with this key ' s fingerprint and the derivation steps applied .
fn to_public<C: Signing>(
        &self,
        secp: &Secp256k1<C>,
    ) -> Result<DescriptorXKey<bip32::ExtendedPubKey>, DescriptorKeyParseError> {
        let unhardened = self
            .derivation_path
            .into_iter()
            .rev()
            .take_while(|c| c.is_normal())
            .count();
        let last_hardened_idx = self.derivation_path.len() - unhardened;
        let hardened_path = &self.derivation_path[..last_hardened_idx];
        let unhardened_path = &self.derivation_path[last_hardened_idx..];
        let xprv = self
            .xkey
            .derive_priv(secp, &hardened_path)
            .map_err(|_| DescriptorKeyParseError("Unable to derive the hardened steps"))?;
        let xpub = bip32::ExtendedPubKey::from_priv(secp, &xprv);
        let origin = match &self.origin {
            Some((fingerprint, path)) => Some((
                *fingerprint,
                path.into_iter()
                    .chain(hardened_path.iter())
                    .cloned()
                    .collect(),
            )),
            None => {
                if hardened_path.is_empty() {
                    None
                } else {
                    Some((self.xkey.fingerprint(secp), hardened_path.into()))
                }
            }
        };
        Ok(DescriptorXKey {
            origin,
            xkey: xpub,
            derivation_path: unhardened_path.into(),
            wildcard: self.wildcard,
        })
    }
fn to_public < C : Signing > ( & self , secp : & Secp256k1 < C > , ) -> Result < DescriptorXKey < bip32 :: ExtendedPubKey > , DescriptorKeyParseError > { let unhardened = self . derivation_path . into_iter ( ) . rev ( ) . take_while ( | c | c . is_normal ( ) ) . count ( ) ; let last_hardened_idx = self . derivation_path . len ( ) - unhardened ; let hardened_path = & self . derivation_path [ .. last_hardened_idx ] ; let unhardened_path = & self . derivation_path [ last_hardened_idx .. ] ; let xprv = self . xkey . derive_priv ( secp , & hardened_path ) . map_err ( | _ | DescriptorKeyParseError ( " " ) ) ? ; let xpub = bip32 :: ExtendedPubKey :: from_priv ( secp , & xprv ) ; let origin = match & self . origin { Some ( ( fingerprint , path ) ) => Some ( ( * fingerprint , path . into_iter ( ) . chain ( hardened_path . iter ( ) ) . cloned ( ) . collect ( ) , ) ) , None => { if hardened_path . is_empty ( ) { None } else { Some ( ( self . xkey . fingerprint ( secp ) , hardened_path . into ( ) ) ) } } } ; Ok ( DescriptorXKey { origin , xkey : xpub , derivation_path : unhardened_path . into ( ) , wildcard : self . wildcard , } ) }
Returns the public version of this key, applying all the hardened derivation steps on the
private key before turning it into a public key.
Returns the public version of this key applying all the hardened derivation steps on the private key before turning it into a public key .
&self
secp
&Secp256k1<C>
&self
secp
&Secp256k1<C>