pub struct Xpriv {
pub network: NetworkKind,
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: NetworkKind
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§
§impl Xpriv
impl Xpriv
pub fn new_master(
network: impl Into<NetworkKind>,
seed: &[u8]
) -> Result<Xpriv, Error>
pub fn new_master( network: impl Into<NetworkKind>, seed: &[u8] ) -> Result<Xpriv, Error>
Construct a new master key from a seed value
pub fn to_priv(self) -> PrivateKey
pub fn to_priv(self) -> PrivateKey
Constructs ECDSA compressed private key matching internal secret key representation.
pub fn to_keypair<C>(self, secp: &Secp256k1<C>) -> Keypairwhere
C: Signing,
pub fn to_keypair<C>(self, secp: &Secp256k1<C>) -> Keypairwhere
C: Signing,
Constructs BIP340 keypair for Schnorr signatures and Taproot use matching the internal secret key representation.
pub fn derive_priv<C, P>(
&self,
secp: &Secp256k1<C>,
path: &P
) -> Result<Xpriv, Error>
pub fn derive_priv<C, P>( &self, secp: &Secp256k1<C>, path: &P ) -> Result<Xpriv, Error>
Attempts to derive an extended private key from a path.
The path
argument can be both of type DerivationPath
or Vec<ChildNumber>
.
pub fn decode(data: &[u8]) -> Result<Xpriv, Error>
pub fn decode(data: &[u8]) -> Result<Xpriv, Error>
Decoding extended private key from binary data according to BIP 32
pub fn identifier<C>(&self, secp: &Secp256k1<C>) -> XKeyIdentifierwhere
C: Signing,
pub fn identifier<C>(&self, secp: &Secp256k1<C>) -> XKeyIdentifierwhere
C: Signing,
Returns the HASH160 of the public key belonging to the xpriv
pub fn fingerprint<C>(&self, secp: &Secp256k1<C>) -> Fingerprintwhere
C: Signing,
pub fn fingerprint<C>(&self, secp: &Secp256k1<C>) -> Fingerprintwhere
C: Signing,
Returns the first four bytes of the identifier