pub struct ExtendedKey { /* private fields */ }Expand description
A BIP32 extended key (private or public) with chain code and derivation metadata.
Supports key derivation, serialization to/from Base58Check xprv/xpub strings, and conversion between private and public extended keys.
Implementations§
Source§impl ExtendedKey
impl ExtendedKey
Sourcepub fn from_seed(seed: &[u8]) -> Result<Self, CompatError>
pub fn from_seed(seed: &[u8]) -> Result<Self, CompatError>
Derive a master extended key from a seed.
Uses HMAC-SHA512 with key “Bitcoin seed” per BIP32 specification. Seed must be between 16 and 64 bytes (128-512 bits).
Sourcepub fn derive(&self, path: &str) -> Result<Self, CompatError>
pub fn derive(&self, path: &str) -> Result<Self, CompatError>
Derive a child extended key by path string.
Path format: “m/0’/1/2’” where apostrophe or “h” suffix means hardened. Leading “m/” or “m” prefix is stripped.
Sourcepub fn derive_child(&self, index: u32) -> Result<Self, CompatError>
pub fn derive_child(&self, index: u32) -> Result<Self, CompatError>
Derive a single child key by index.
Index >= 0x80000000 is hardened derivation (requires private key). Index < 0x80000000 is normal derivation (works with public key).
Sourcepub fn to_public(&self) -> Result<Self, CompatError>
pub fn to_public(&self) -> Result<Self, CompatError>
Convert a private extended key to its public counterpart.
Returns a new ExtendedKey with the public key and xpub version bytes.
Sourcepub fn to_base58(&self) -> String
pub fn to_base58(&self) -> String
Serialize to a Base58Check string (xprv or xpub).
78-byte payload: version(4) || depth(1) || fingerprint(4) || child_index(4) || chain_code(32) || key(33, with 0x00 prefix for private).
Sourcepub fn from_string(s: &str) -> Result<Self, CompatError>
pub fn from_string(s: &str) -> Result<Self, CompatError>
Parse an extended key from a Base58Check string (xprv or xpub).
Sourcepub fn public_key(&self) -> Result<PublicKey, CompatError>
pub fn public_key(&self) -> Result<PublicKey, CompatError>
Get the public key for this extended key.
If private, derives the public key. If public, parses the stored key.
Sourcepub fn is_private(&self) -> bool
pub fn is_private(&self) -> bool
Whether this is a private extended key.
Trait Implementations§
Source§impl Clone for ExtendedKey
impl Clone for ExtendedKey
Source§fn clone(&self) -> ExtendedKey
fn clone(&self) -> ExtendedKey
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more