XPrv (Class)¶
An extended private key (BIP-32).
Allows hierarchical deterministic key derivation from a seed. All keys in an HD wallet can be derived from a single XPrv.
__new__
¶
__new__(seed: str) -> XPrv
Create an XPrv from a seed hex string.
| PARAMETER | DESCRIPTION |
|---|---|
seed
|
A hex-encoded seed (typically from Mnemonic.to_seed()).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
XPrv
|
A new XPrv instance.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
Exception
|
If the seed is invalid. |
derive_child
¶
derive_child(child_number: int, hardened: Optional[bool] = None) -> XPrv
Derive a child key at the given index.
| PARAMETER | DESCRIPTION |
|---|---|
child_number
|
The child index.
TYPE:
|
hardened
|
Whether to use hardened derivation (default: False).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
XPrv
|
The derived child XPrv.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
Exception
|
If derivation fails. |
derive_path
¶
derive_path(path: Any) -> XPrv
Derive a key at the given derivation path.
| PARAMETER | DESCRIPTION |
|---|---|
path
|
A derivation path string (e.g., "m/44'/111111'/0'") or DerivationPath.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
XPrv
|
The derived XPrv at that path.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
Exception
|
If derivation fails. |
from_xprv
staticmethod
¶
from_xprv(xprv: str) -> XPrv
Create an XPrv from a serialized xprv string.
| PARAMETER | DESCRIPTION |
|---|---|
xprv
|
A Base58-encoded extended private key string.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
XPrv
|
A new XPrv instance.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
Exception
|
If the xprv string is invalid. |
into_string
¶
Serialize to string with custom prefix.
| PARAMETER | DESCRIPTION |
|---|---|
prefix
|
The key prefix (e.g., "kprv", "xprv").
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The serialized extended private key.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
Exception
|
If serialization fails. |
to_private_key
¶
to_private_key() -> PrivateKey
Get the private key at this derivation level.
| RETURNS | DESCRIPTION |
|---|---|
PrivateKey
|
The private key.
TYPE:
|
to_string
¶
Serialize to string with default "kprv" prefix.
| RETURNS | DESCRIPTION |
|---|---|
str
|
The serialized extended private key.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
Exception
|
If serialization fails. |