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§
source§impl Xpriv
impl Xpriv
sourcepub 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
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<Xpriv, Error>
pub fn derive_priv<C: Signing, P: AsRef<[ChildNumber]>>( &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>
.
sourcepub 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
sourcepub fn identifier<C: Signing>(&self, secp: &Secp256k1<C>) -> XKeyIdentifier
pub fn identifier<C: Signing>(&self, secp: &Secp256k1<C>) -> XKeyIdentifier
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<'de> Deserialize<'de> for Xpriv
impl<'de> Deserialize<'de> for Xpriv
source§fn deserialize<D>(deserializer: D) -> Result<Xpriv, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Xpriv, D::Error>where
D: Deserializer<'de>,
source§impl PartialEq for Xpriv
impl PartialEq for Xpriv
impl Copy for Xpriv
impl Eq for Xpriv
impl StructuralPartialEq for Xpriv
Auto Trait Implementations§
impl Freeze for Xpriv
impl RefUnwindSafe for Xpriv
impl Send for Xpriv
impl Sync for Xpriv
impl Unpin for Xpriv
impl UnwindSafe for Xpriv
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
)