pub struct Xpub {
pub network: NetworkKind,
pub depth: u8,
pub parent_fingerprint: Fingerprint,
pub child_number: ChildNumber,
pub public_key: PublicKey,
pub chain_code: ChainCode,
}Expand description
Extended public key
Fields§
§network: NetworkKindThe network kind this key is to be used on
depth: u8How many derivations this key is from the master (which is 0)
parent_fingerprint: FingerprintFingerprint of the parent key
child_number: ChildNumberChild number of the key used to derive from parent (0 for master)
public_key: PublicKeyPublic key
chain_code: ChainCodeChain code
Implementations§
Source§impl Xpub
impl Xpub
Sourcepub fn from_priv<C>(secp: &Secp256k1<C>, sk: &Xpriv) -> Xpubwhere
C: Signing,
pub fn from_priv<C>(secp: &Secp256k1<C>, sk: &Xpriv) -> Xpubwhere
C: Signing,
Derives a public key from a private key
Sourcepub fn to_pub(self) -> CompressedPublicKey
pub fn to_pub(self) -> CompressedPublicKey
Constructs ECDSA compressed public key matching internal public key representation.
Sourcepub fn to_x_only_pub(self) -> XOnlyPublicKey
pub fn to_x_only_pub(self) -> XOnlyPublicKey
Constructs BIP340 x-only public key for BIP-340 signatures and Taproot use matching the internal public key representation.
Sourcepub fn derive_pub<C, P>(
&self,
secp: &Secp256k1<C>,
path: &P,
) -> Result<Xpub, Error>
pub fn derive_pub<C, P>( &self, secp: &Secp256k1<C>, path: &P, ) -> Result<Xpub, Error>
Attempts to derive an extended public key from a path.
The path argument can be any type implementing AsRef<ChildNumber>, such as DerivationPath, for instance.
Sourcepub fn ckd_pub_tweak(
&self,
i: ChildNumber,
) -> Result<(SecretKey, ChainCode), Error>
pub fn ckd_pub_tweak( &self, i: ChildNumber, ) -> Result<(SecretKey, ChainCode), Error>
Compute the scalar tweak added to this key to get a child key
Sourcepub fn ckd_pub<C>(
&self,
secp: &Secp256k1<C>,
i: ChildNumber,
) -> Result<Xpub, Error>where
C: Verification,
pub fn ckd_pub<C>(
&self,
secp: &Secp256k1<C>,
i: ChildNumber,
) -> Result<Xpub, Error>where
C: Verification,
Public->Public child key derivation
Sourcepub fn decode(data: &[u8]) -> Result<Xpub, Error>
pub fn decode(data: &[u8]) -> Result<Xpub, Error>
Decoding extended public key from binary data according to BIP 32
Sourcepub fn identifier(&self) -> XKeyIdentifier
pub fn identifier(&self) -> XKeyIdentifier
Returns the HASH160 of the chaincode
Sourcepub fn fingerprint(&self) -> Fingerprint
pub fn fingerprint(&self) -> Fingerprint
Returns the first four bytes of the identifier
Trait Implementations§
Source§impl<Ctx> DerivableKey<Ctx> for Xpubwhere
Ctx: ScriptContext,
impl<Ctx> DerivableKey<Ctx> for Xpubwhere
Ctx: ScriptContext,
Source§fn into_extended_key(self) -> Result<ExtendedKey<Ctx>, KeyError>
fn into_extended_key(self) -> Result<ExtendedKey<Ctx>, KeyError>
self and turn it into an ExtendedKey
This can be used to get direct access to xprvs and xpubs for types that implement this trait,
like Mnemonic when the keys-bip39 feature is enabled. Read moreSource§fn into_descriptor_key(
self,
origin: Option<(Fingerprint, DerivationPath)>,
derivation_path: DerivationPath,
) -> Result<DescriptorKey<Ctx>, KeyError>
fn into_descriptor_key( self, origin: Option<(Fingerprint, DerivationPath)>, derivation_path: DerivationPath, ) -> Result<DescriptorKey<Ctx>, KeyError>
self and turn it into a DescriptorKey by adding the extra metadata, such as
key origin and derivation pathSource§impl<'de> Deserialize<'de> for Xpub
impl<'de> Deserialize<'de> for Xpub
Source§fn deserialize<D>(
deserializer: D,
) -> Result<Xpub, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<Xpub, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl From<&Xpub> for XKeyIdentifier
impl From<&Xpub> for XKeyIdentifier
Source§fn from(key: &Xpub) -> XKeyIdentifier
fn from(key: &Xpub) -> XKeyIdentifier
Source§impl<Ctx> From<Xpub> for ExtendedKey<Ctx>where
Ctx: ScriptContext,
impl<Ctx> From<Xpub> for ExtendedKey<Ctx>where
Ctx: ScriptContext,
Source§fn from(xpub: Xpub) -> ExtendedKey<Ctx>
fn from(xpub: Xpub) -> ExtendedKey<Ctx>
Source§impl From<Xpub> for XKeyIdentifier
impl From<Xpub> for XKeyIdentifier
Source§fn from(key: Xpub) -> XKeyIdentifier
fn from(key: Xpub) -> XKeyIdentifier
Source§impl InnerXKey for Xpub
impl InnerXKey for Xpub
Source§fn xkey_fingerprint<C>(&self, _secp: &Secp256k1<C>) -> Fingerprintwhere
C: Signing,
fn xkey_fingerprint<C>(&self, _secp: &Secp256k1<C>) -> Fingerprintwhere
C: Signing,
Source§fn can_derive_hardened() -> bool
fn can_derive_hardened() -> bool
Source§impl Ord for Xpub
impl Ord for Xpub
Source§impl PartialOrd for Xpub
impl PartialOrd for Xpub
Source§impl Serialize for Xpub
impl Serialize for Xpub
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
impl Copy for Xpub
impl Eq for Xpub
impl StructuralPartialEq for Xpub
Auto Trait Implementations§
impl Freeze for Xpub
impl RefUnwindSafe for Xpub
impl Send for Xpub
impl Sync for Xpub
impl Unpin for Xpub
impl UnwindSafe for Xpub
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.