Struct bitcoin::util::bip32::ExtendedPrivKey
source · pub struct ExtendedPrivKey {
pub network: Network,
pub depth: u8,
pub parent_fingerprint: Fingerprint,
pub child_number: ChildNumber,
pub private_key: SecretKey,
pub chain_code: ChainCode,
}
Expand description
Extended private key
Fields§
§network: Network
The network 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 (0 for master)
child_number: ChildNumber
Child number of the key used to derive from parent (0 for master)
private_key: SecretKey
Private key
chain_code: ChainCode
Chain code
Implementations§
source§impl ExtendedPrivKey
impl ExtendedPrivKey
sourcepub fn new_master(
network: Network,
seed: &[u8]
) -> Result<ExtendedPrivKey, Error>
pub fn new_master( network: Network, seed: &[u8] ) -> Result<ExtendedPrivKey, Error>
Construct a new master key from a seed value
sourcepub fn to_priv(self) -> PrivateKey
pub fn to_priv(self) -> PrivateKey
Constructs ECDSA compressed private key matching internal secret key representation.
sourcepub fn to_keypair<C: Signing>(self, secp: &Secp256k1<C>) -> KeyPair
pub fn to_keypair<C: Signing>(self, secp: &Secp256k1<C>) -> KeyPair
Constructs BIP340 keypair for Schnorr signatures and Taproot use matching the internal secret key representation.
sourcepub fn derive_priv<C: Signing, P: AsRef<[ChildNumber]>>(
&self,
secp: &Secp256k1<C>,
path: &P
) -> Result<ExtendedPrivKey, Error>
pub fn derive_priv<C: Signing, P: AsRef<[ChildNumber]>>( &self, secp: &Secp256k1<C>, path: &P ) -> Result<ExtendedPrivKey, Error>
Attempts to derive an extended private key from a path.
The path
argument can be both of type DerivationPath
or Vec<ChildNumber>
.
sourcepub fn ckd_priv<C: Signing>(
&self,
secp: &Secp256k1<C>,
i: ChildNumber
) -> Result<ExtendedPrivKey, Error>
pub fn ckd_priv<C: Signing>( &self, secp: &Secp256k1<C>, i: ChildNumber ) -> Result<ExtendedPrivKey, Error>
Private->Private child key derivation
sourcepub fn decode(data: &[u8]) -> Result<ExtendedPrivKey, Error>
pub fn decode(data: &[u8]) -> Result<ExtendedPrivKey, Error>
Decoding extended private key from binary data according to BIP 32
sourcepub fn identifier<C: Signing>(&self, secp: &Secp256k1<C>) -> XpubIdentifier
pub fn identifier<C: Signing>(&self, secp: &Secp256k1<C>) -> XpubIdentifier
Returns the HASH160 of the public key belonging to the xpriv
sourcepub fn fingerprint<C: Signing>(&self, secp: &Secp256k1<C>) -> Fingerprint
pub fn fingerprint<C: Signing>(&self, secp: &Secp256k1<C>) -> Fingerprint
Returns the first four bytes of the identifier
Trait Implementations§
source§impl Clone for ExtendedPrivKey
impl Clone for ExtendedPrivKey
source§fn clone(&self) -> ExtendedPrivKey
fn clone(&self) -> ExtendedPrivKey
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ExtendedPrivKey
impl Debug for ExtendedPrivKey
source§impl<'de> Deserialize<'de> for ExtendedPrivKey
impl<'de> Deserialize<'de> for ExtendedPrivKey
source§fn deserialize<D>(deserializer: D) -> Result<ExtendedPrivKey, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<ExtendedPrivKey, D::Error>where D: Deserializer<'de>,
source§impl Display for ExtendedPrivKey
impl Display for ExtendedPrivKey
source§impl FromStr for ExtendedPrivKey
impl FromStr for ExtendedPrivKey
source§impl PartialEq<ExtendedPrivKey> for ExtendedPrivKey
impl PartialEq<ExtendedPrivKey> for ExtendedPrivKey
source§fn eq(&self, other: &ExtendedPrivKey) -> bool
fn eq(&self, other: &ExtendedPrivKey) -> bool
self
and other
values to be equal, and is used
by ==
.