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: NetworkKindThe network 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 (0 for master)
child_number: ChildNumberChild number of the key used to derive from parent (0 for master)
private_key: SecretKeyPrivate key
chain_code: ChainCodeChain code
Implementations§
Source§impl Xpriv
impl Xpriv
Sourcepub fn new_master(
network: impl Into<NetworkKind>,
seed: impl AsRef<Bip32Seed>,
) -> Self
pub fn new_master( network: impl Into<NetworkKind>, seed: impl AsRef<Bip32Seed>, ) -> Self
Constructs a new master key from a Bip32Seed.
Sourcepub fn to_priv(self) -> PrivateKey
👎Deprecating in a future version: use to_private_key() instead
pub fn to_priv(self) -> PrivateKey
use to_private_key() instead
Constructs a new ECDSA compressed private key matching internal secret key representation.
Sourcepub fn to_private_key(self) -> PrivateKey
pub fn to_private_key(self) -> PrivateKey
Constructs a new ECDSA compressed private key matching internal secret key representation.
Sourcepub fn to_xpub(self) -> Xpub
pub fn to_xpub(self) -> Xpub
Constructs a new extended public key from this extended private key.
Sourcepub fn to_keypair(self) -> Keypair
pub fn to_keypair(self) -> Keypair
Constructs a new BIP-0340 keypair for Schnorr signatures and Taproot use matching the internal secret key representation.
Sourcepub fn derive_priv<P: AsRef<[ChildNumber]>>(
&self,
path: P,
) -> Result<Self, DerivationError>
👎Deprecating in a future version: use derive_xpriv() instead
pub fn derive_priv<P: AsRef<[ChildNumber]>>( &self, path: P, ) -> Result<Self, DerivationError>
use derive_xpriv() instead
Derives an extended private key from a path.
The path argument can be both of type RelativeDerivationPath or Vec<ChildNumber>.
§Errors
See derive_xpriv.
Sourcepub fn derive_xpriv<P: AsRef<[ChildNumber]>>(
&self,
path: P,
) -> Result<Self, DerivationError>
pub fn derive_xpriv<P: AsRef<[ChildNumber]>>( &self, path: P, ) -> Result<Self, DerivationError>
Derives an extended private key from a path.
The path argument can be both of type RelativeDerivationPath or Vec<ChildNumber>.
§Errors
Returns an error if the derived key exceeds the maximum key depth.
Sourcepub fn decode(data: &[u8]) -> Result<Self, ParseError>
pub fn decode(data: &[u8]) -> Result<Self, ParseError>
Decoding extended private key from binary data according to BIP-0032
§Errors
ParseError::UnknownVersionif the decoded network value is not main or testnet.ParseError::InvalidPrivateKeyPrefixif the private key bytes don’t start with zero.ParseError::Secp256k1if the private key bytes are not a valid secp secret key.ParseError::WrongExtendedKeyLengthif the data is not the correct length.ParseError::NonZeroParentFingerprintForMasterKeyif the depth is 0 and the master key fingerprint is non-zero.ParseError::NonZeroChildNumberForMasterKeyif the depth is 0 and the child number is non-zero.
Sourcepub fn identifier(&self) -> XKeyIdentifier
pub fn identifier(&self) -> XKeyIdentifier
Returns the HASH160 of the public key belonging to the xpriv
Sourcepub fn fingerprint(&self) -> Fingerprint
pub fn fingerprint(&self) -> Fingerprint
Returns the first four bytes of the identifier
Trait Implementations§
Source§impl<'a> Arbitrary<'a> for Xpriv
Available on crate feature arbitrary only.
impl<'a> Arbitrary<'a> for Xpriv
arbitrary only.Source§fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
Self from the given unstructured data. Read moreSource§fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
Self from the entirety of the given
unstructured data. Read moreSource§fn size_hint(depth: usize) -> (usize, Option<usize>)
fn size_hint(depth: usize) -> (usize, Option<usize>)
Unstructured this type
needs to construct itself. Read moreSource§fn try_size_hint(
depth: usize,
) -> Result<(usize, Option<usize>), MaxRecursionReached>
fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>
Unstructured this type
needs to construct itself. Read more