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: NetworkKind
The network kind this key is to be used on
depth: u8
How many derivations this key is from the master (which is 0)
parent_fingerprint: Fingerprint
Fingerprint of the parent key
child_number: ChildNumber
Child number of the key used to derive from parent (0 for master)
public_key: PublicKey
Public key
chain_code: ChainCode
Chain code
Implementations§
source§impl Xpub
impl Xpub
sourcepub fn from_priv<C: Signing>(secp: &Secp256k1<C>, sk: &Xpriv) -> Xpub
pub fn from_priv<C: Signing>(secp: &Secp256k1<C>, sk: &Xpriv) -> Xpub
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: Verification, P: AsRef<[ChildNumber]>>(
&self,
secp: &Secp256k1<C>,
path: &P,
) -> Result<Xpub, Error>
pub fn derive_pub<C: Verification, P: AsRef<[ChildNumber]>>( &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: Verification>(
&self,
secp: &Secp256k1<C>,
i: ChildNumber,
) -> Result<Xpub, Error>
pub fn ckd_pub<C: Verification>( &self, secp: &Secp256k1<C>, i: ChildNumber, ) -> Result<Xpub, Error>
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<'de> Deserialize<'de> for Xpub
impl<'de> Deserialize<'de> for Xpub
source§fn deserialize<D>(deserializer: D) -> Result<Xpub, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Xpub, D::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 From<Xpub> for XKeyIdentifier
impl From<Xpub> for XKeyIdentifier
source§fn from(key: Xpub) -> XKeyIdentifier
fn from(key: Xpub) -> XKeyIdentifier
source§impl Ord for Xpub
impl Ord for Xpub
source§impl PartialEq for Xpub
impl PartialEq for Xpub
source§impl PartialOrd for Xpub
impl PartialOrd for Xpub
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moreimpl 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: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)