Hierarchical Deterministic’s

class hdwallet.hds.HDS

A class that manages a dictionary of hd classes.

This class provides methods to retrieve names and classes of various hd implementations, as well as methods to validate and access specific hd classes by name.

Here are available hd names and classes:

classmethod names() List[str]

Get a list of names from the dictionary attribute of the class.

Returns:

List of names from the class dictionary.

Return type:

List[str]

classmethod classes() List[Type[IHD]]

Get a list of classes from the dictionary attribute of the class.

Returns:

List of classes from the class dictionary.

Return type:

List[Type[IHD]]

classmethod hd(name: str) Type[IHD]

Get the HD class type from the dictionary attribute of the class based on the given name.

Parameters:

name (str) – The name of the HD class to retrieve.

Returns:

The HD class type corresponding to the given name.

Return type:

Type[IHD]

classmethod is_hd(name: str) bool

Check if the given name corresponds to an HD class in the class dictionary.

Parameters:

name (str) – The name to check.

Returns:

True if the name corresponds to an HD class, False otherwise.

Return type:

bool

>>> from hdwallet.hds import HDS
>>> HDS.names()
['Algorand', 'BIP32', 'BIP44', 'BIP49', 'BIP84', 'BIP86', 'BIP141', 'Cardano', 'Electrum-V1', 'Electrum-V2', 'Monero']
>>> HDS.classes()
[<class 'hdwallet.hds.algorand.AlgorandHD'>, <class 'hdwallet.hds.bip32.BIP32HD'>, <class 'hdwallet.hds.bip44.BIP44HD'>, <class 'hdwallet.hds.bip49.BIP49HD'>, <class 'hdwallet.hds.bip84.BIP84HD'>, <class 'hdwallet.hds.bip86.BIP86HD'>, <class 'hdwallet.hds.bip141.BIP141HD'>, <class 'hdwallet.hds.cardano.CardanoHD'>, <class 'hdwallet.hds.electrum.v1.ElectrumV1HD'>, <class 'hdwallet.hds.electrum.v2.ElectrumV2HD'>, <class 'hdwallet.hds.monero.MoneroHD'>]
>>> from hdwallet.hds.electrum.v2 import ElectrumV2HD
>>> HDS.hd(name="BIP32")
<class 'hdwallet.hds.bip32.BIP32HD'>
>>> HDS.hd(name="Electrum-V2") == ElectrumV2HD
True
>>> HDS.is_hd(name="Electrum-V1")
True
class hdwallet.hds.ihd.IHD(**kwargs)
classmethod name() str

Get the name of the hd class.

Returns:

The name of the hd class.

Return type:

str

from_seed(seed: bytes | str, **kwargs) IHD

Initializes the HD instance from the given seed.

Parameters:
  • seed (Union[bytes, str]) – The seed to initialize the instance. It can be of type bytes, str, or ISeed.

  • kwargs – Additional keyword arguments.

Returns:

The initialized HD instance.

Return type:

HD

from_xprivate_key(xprivate_key: str, encoded: bool = True, strict: bool = False) IHD

Initializes the HD instance from the given extended private key (xprivate key).

Parameters:
  • xprivate_key (str) – The extended private key to initialize the instance.

  • encoded (bool) – Indicates if the xprivate key is encoded. Defaults to True.

  • strict (bool) – If set to True, enforces strict checking to ensure the xprivate key is a root key. Defaults to False.

Returns:

The initialized HD instance.

Return type:

HD

from_xpublic_key(xpublic_key: str, encoded: bool = True, strict: bool = False) IHD

Initializes the HD instance from the given extended public key (xpublic key).

Parameters:
  • xpublic_key (str) – The extended public key to initialize the instance.

  • encoded (bool) – Indicates if the xpublic key is encoded. Defaults to True.

  • strict (bool) – If set to True, enforces strict checking to ensure the xpublic key is a root key. Defaults to False.

Returns:

The initialized HD instance.

Return type:

HD

from_wif(wif: str) IHD

Initializes the HD instance from the given Wallet Import Format (WIF) key.

Parameters:

wif (str) – The Wallet Import Format (WIF) key to initialize the instance.

Returns:

The initialized HD instance.

Return type:

HD

from_private_key(private_key: str) IHD

Initializes the HD instance from the given private key.

Parameters:

private_key (str) – The private key to initialize the instance, represented as a string.

Returns:

The initialized HD instance.

Return type:

HD

from_spend_private_key(spend_private_key: str) IHD

Initialize the HD instance from a spend private key.

Parameters:

spend_private_key (str) – Spend private key to initialize from.

Returns:

Updated HD instance initialized from the spend private key.

Return type:

HD

from_public_key(public_key: str) IHD

Initializes the HD instance from the given public key.

Parameters:

public_key (str) – The public key to initialize the instance, represented as a string.

Returns:

The initialized HD instance.

Return type:

HD

from_watch_only(view_private_key, spend_public_key) IHD

Initialize the MoneroHD instance from watch-only keys.

Parameters:
  • view_private_key – View private key or seed to initialize from.

  • spend_public_key – Spend public key to initialize from.

Returns:

Updated HD instance initialized from the watch-only keys.

Return type:

MoneroHD

from_derivation(derivation: IDerivation) IHD

Initializes the MoneroHD instance using the specified derivation path.

Parameters:

derivation (IDerivation) – The derivation path to initialize the instance. It must be an instance of IDerivation.

Returns:

The initialized MoneroHD instance.

Return type:

MoneroHD

update_derivation(derivation: IDerivation) IHD

Updates the derivation path for the HD instance.

This method first cleans the current derivation path and then sets the new derivation path provided. It drives the instance through the new derivation path.

Parameters:

derivation (IDerivation) – The new derivation path to set. It must be an instance of IDerivation.

Returns:

The updated HD instance.

Return type:

HD

clean_derivation() IHD

Cleans the derivation path of the HD instance.

Returns:

The cleaned HD instance.

Return type:

HD

derivation() IDerivation

Retrieves the derivation method used for key generation.

Returns:

An object representing the derivation details.

Return type:

IDerivation

seed() str | None

Retrieves the seed value as a string if it exists.

Returns:

The seed value as a string, or None if the seed is not set.

Return type:

Optional[str]

semantic() str | None

Retrieves the semantic value as a string if it exists.

Returns:

The semantic value as a string, or None if the semantic is not set.

Return type:

Optional[str]

root_xprivate_key(*args, **kwargs) str | None

Retrieves the root extended private key (xprv) in serialized format.

Parameters:
  • args – Additional positional arguments.

  • kwargs – Additional keyword arguments.

Returns:

The root extended private key (xprv) in serialized format, or None if the chain code is not set.

Return type:

Optional[str]

root_xpublic_key(*args, **kwargs) str | None

Retrieves the root extended public key (xpub) in serialized format.

Parameters:
  • args – Additional positional arguments.

  • kwargs – Additional keyword arguments.

Returns:

The root extended public key (xpub) in serialized format, or None if the chain code is not set.

Return type:

Optional[str]

master_xprivate_key(*args, **kwargs) str | None

Retrieves the master extended private key in serialized format.

Parameters:
  • args – Additional positional arguments.

  • kwargs – Additional keyword arguments.

Returns:

The root extended private key in serialized format, or None if the chain code is not set.

Return type:

Optional[str]

master_xpublic_key(*args, **kwargs) str | None

Retrieves the master extended public key in serialized format.

Parameters:
  • args – Additional positional arguments.

  • kwargs – Additional keyword arguments.

Returns:

The master extended public key in serialized format, or None if the chain code is not set.

Return type:

Optional[str]

root_private_key(*args, **kwargs) str | None

Retrieves the root private key as a string.

Parameters:
  • args – Additional positional arguments.

  • kwargs – Additional keyword arguments.

Returns:

The root private key as a hexadecimal string, or None if not set.

Return type:

Optional[str]

root_wif(*args, **kwargs) str | None

Retrieves the root private key in WIF format.

Parameters:
  • args – Additional positional arguments.

  • kwargs – Additional keyword arguments.

Returns:

The root private key in WIF format as a string, or None if the root private key is not set.

Return type:

Optional[str]

root_chain_code() str | None

Retrieves the root chain code as a string.

Returns:

The root chain code as a string, or None if the root chain code is not set.

Return type:

Optional[str]

root_public_key(*args, **kwargs) str | None

Retrieves the root public key as a string.

Parameters:
  • args – Additional positional arguments.

  • kwargs – Additional keyword arguments.

Returns:

The root public key as a string, or None if the root public key is not set.

Return type:

Optional[str]

master_private_key(*args, **kwargs) str | None

Retrieves the master private key as a string.

Parameters:
  • args – Additional positional arguments.

  • kwargs – Additional keyword arguments.

Returns:

The master private key as a string, or None if the master private key is not set.

Return type:

Optional[str]

master_wif(*args, **kwargs) str | None

Retrieves the master wif as a string.

Parameters:
  • args – Additional positional arguments.

  • kwargs – Additional keyword arguments.

Returns:

The master wif as a string, or None if the master private is not set.

Return type:

Optional[str]

master_chain_code() str | None

Retrieves the master chain code as a string.

Parameters:
  • args – Additional positional arguments.

  • kwargs – Additional keyword arguments.

Returns:

The master chain code as a string, or None if the master chain code is not set.

Return type:

Optional[str]

master_public_key(*args, **kwargs) str

Retrieves the master public key as a string.

Parameters:
  • args – Additional positional arguments.

  • kwargs – Additional keyword arguments.

Returns:

The master public key as a string, or None if the master public key is not set.

Return type:

Optional[str]

xprivate_key(*args, **kwargs) str | None

Retrieves the extended private key (xprivate key) as a serialized string.

Parameters:
  • args – Additional positional arguments.

  • kwargs – Additional keyword arguments.

Returns:

The serialized xprivate key as a string, or None if the private key or chain code is not set.

Return type:

Optional[str]

xpublic_key(*args, **kwargs) str | None

Retrieves the extended public key (xpublic key) as a serialized string.

Parameters:
  • args – Additional positional arguments.

  • kwargs – Additional keyword arguments.

Returns:

The serialized xpublic key as a string, or None if the chain code is not set.

Return type:

Optional[str]

private_key(*args, **kwargs) str | None

Retrieves the private key as a string.

Parameters:
  • args – Additional positional arguments.

  • kwargs – Additional keyword arguments.

Returns:

The private key as a string, or None if the private key is not set.

Return type:

Optional[str]

spend_private_key() str

Retrieves the spend private key used in this MoneroHD instance.

Returns:

Spend private key used in this instance, or None if not set.

Return type:

Optional[str]

view_private_key() str

Retrieves the view private key used in this MoneroHD instance.

Returns:

View private key used in this instance.

Return type:

str

wif(*args, **kwargs) str | None

Converts the private key to a WIF (Wallet Import Format) string.

Parameters:
  • args – Additional positional arguments.

  • kwargs – Additional keyword arguments.

Returns:

The WIF representation of the private key, or None if the private key is not set.

Return type:

Optional[str]

wif_type() str

Retrieves the current WIF (Wallet Import Format) type used by the instance.

Returns:

The current WIF type if a WIF is present, otherwise None.

Return type:

Optional[str]

chain_code() str

Retrieves the chain code associated with the current instance.

Returns:

The chain code as a string if available, otherwise None.

Return type:

Optional[str]

public_key(*args, **kwargs) str

Retrieves the public key associated with the current instance.

Parameters:
  • args – Additional positional arguments.

  • kwargs – Additional keyword arguments.

Returns:

The public key as a string based on the specified type.

Return type:

str

compressed() str

Retrieves the compressed form of the public key associated with the current instance.

Returns:

The compressed public key.

Return type:

str

uncompressed() str

Retrieves the uncompressed form of the public key associated with the current instance.

Returns:

The uncompressed public key.

Return type:

str

spend_public_key() str

Retrieves the spend public key used in this MoneroHD instance.

Returns:

Spend public key used in this instance.

Return type:

str

view_public_key() str

Retrieves the view public key used in this MoneroHD instance.

Returns:

View public key used in this instance.

Return type:

str

public_key_type() str

Retrieves the type of public key associated with the current instance.

Returns:

The type of public key.

Return type:

str

mode() str

Get the mode of the ElectrumV2HD instance.

Returns:

The mode of the instance.

Return type:

str

hash() str

Retrieves the hash of the public key.

Returns:

The hash of the public key.

Return type:

str

fingerprint() str

Computes the fingerprint of the HD object by hashing the public key.

Returns:

The fingerprint of the HD object.

Return type:

str

parent_fingerprint() str

Retrieves the parent fingerprint of the HD object.

Returns:

The parent fingerprint if available, otherwise None.

Return type:

Optional[str]

depth() int

Retrieves the depth of the HD object in the hierarchical tree.

Returns:

The depth of the object.

Return type:

int

path() str

Retrieves the derivation path associated with the HD object.

Returns:

The derivation path.

Return type:

str

path_key() str

Retrieves the derivation path key associated with the HD object.

Returns:

The derivation path.

Return type:

str

index() int

Retrieves the index of the current BIP32HD object.

Returns:

The index value.

Return type:

int

indexes() List[int]

Retrieves the list of indexes from the derivation associated with this BIP32HD object.

Returns:

The list of indexes.

Return type:

List[int]

strict() bool | None

Retrieves the strict mode flag associated with this BIP32HD object.

Returns:

The strict mode flag.

Return type:

Optional[bool]

integrated_address(**kwargs) str

Generates the integrated Monero address associated with the spend and view public keys.

Parameters:

kwargs – Additional keyword arguments.

Returns:

Integrated Monero address.

Return type:

str

primary_address(**kwargs) str

Generates the primary Monero address associated with the spend and view public keys.

Parameters:

kwargs – Additional keyword arguments.

Returns:

Primary Monero address.

Return type:

str

sub_address(**kwargs) str

Generates a sub-address associated with the given minor and major indexes or uses the current derivation indexes.

Parameters:

kwargs – Additional keyword arguments.

Returns:

Generated sub-address.

Return type:

str

address(**kwargs) str

Generates an address based on the specified type and parameters.

Parameters:

kwargs – Additional keyword arguments.

Returns:

The generated address.

Return type:

str

class hdwallet.hds.algorand.AlgorandHD
classmethod name() str

Get the name of the Algorand class.

Returns:

The name of the Algorand class.

Return type:

str

from_seed(seed: bytes | str | ISeed, **kwargs) AlgorandHD

Initializes the AlgorandHD instance from the given seed.

Parameters:
  • seed (Union[bytes, str, ISeed]) – The seed to initialize the instance. It can be of type bytes, str, or ISeed.

  • kwargs – Additional keyword arguments.

Returns:

The initialized AlgorandHD instance.

Return type:

AlgorandHD

drive(index: int) AlgorandHD | None

Drives the AlgorandHD instance forward along the derivation path by deriving a child key at the given index.

Parameters:

index (int) – The index to derive the child key.

Returns:

The updated AlgorandHD instance with the derived child key, or None if the derivation fails.

Return type:

Optional[AlgorandHD]

root_xprivate_key(version: bytes | int = 256061908, encoded: bool = True) str | None

Generates the root extended private key (xprv) in serialized format.

Parameters:
  • version (Union[bytes, int]) – The version bytes for the extended key. Defaults to Algorand mainnet P2PKH version.

  • encoded (bool) – Whether to return the key in encoded format. Defaults to True.

Returns:

The root extended private key (xprv) in serialized format, or None if the chain code is not set.

Return type:

Optional[str]

xprivate_key(version: bytes | int = 256061908, encoded: bool = True) str | None

Retrieves the extended private key (xprivate key) as a serialized string.

Parameters:
  • version (Union[bytes, int]) – The version bytes or integer version of the xprivate key.

  • encoded (bool) – Flag indicating whether the key should be encoded.

Returns:

The serialized xprivate key as a string, or None if the private key or chain code is not set.

Return type:

Optional[str]

address(**kwargs) str

Generates a Algorand address using the AlgorandAddress encoding scheme.

Parameters:

kwargs – Additional keyword arguments for encoding.

Returns:

Algorand address encoded.

Return type:

str

Example: https://github.com/hdwallet-io/python-hdwallet/blob/master/examples/hds/algorand.py

class hdwallet.hds.bip32.BIP32HD(ecc: Type[IEllipticCurveCryptography], public_key_type: str = 'compressed', **kwargs)
classmethod name() str

Get the name of the bip class.

Returns:

The name of the bip class.

Return type:

str

from_seed(seed: bytes | str | ISeed, **kwargs) BIP32HD

Initializes the BIP32HD instance from the given seed.

Parameters:
  • seed (Union[bytes, str, ISeed]) – The seed to initialize the instance. It can be of type bytes, str, or ISeed.

  • kwargs – Additional keyword arguments.

Returns:

The initialized BIP32HD instance.

Return type:

BIP32HD

from_xprivate_key(xprivate_key: str, encoded: bool = True, strict: bool = False) BIP32HD

Initializes the BIP32HD instance from the given extended private key (xprivate key).

Parameters:
  • xprivate_key (str) – The extended private key to initialize the instance. It should be a string.

  • encoded (bool) – Indicates if the xprivate key is encoded. Defaults to True.

  • strict (bool) – If set to True, enforces strict checking to ensure the xprivate key is a root key. Defaults to False.

Returns:

The initialized BIP32HD instance.

Return type:

BIP32HD

from_xpublic_key(xpublic_key: str, encoded: bool = True, strict: bool = False) BIP32HD

Initializes the BIP32HD instance from the given extended public key (xpublic key).

Parameters:
  • xpublic_key (str) – The extended public key to initialize the instance. It should be a string.

  • encoded (bool) – Indicates if the xpublic key is encoded. Defaults to True.

  • strict (bool) – If set to True, enforces strict checking to ensure the xpublic key is a root key. Defaults to False.

Returns:

The initialized BIP32HD instance.

Return type:

BIP32HD

from_wif(wif: str) BIP32HD

Initializes the BIP32HD instance from the given Wallet Import Format (WIF) key.

Parameters:

wif (str) – The Wallet Import Format (WIF) key to initialize the instance.

Returns:

The initialized BIP32HD instance.

Return type:

BIP32HD

from_private_key(private_key: str) BIP32HD

Initializes the BIP32HD instance from the given private key.

Parameters:

private_key (str) – The private key to initialize the instance, represented as a string.

Returns:

The initialized BIP32HD instance.

Return type:

BIP32HD

from_public_key(public_key: str) BIP32HD

Initializes the BIP32HD instance from the given public key.

Parameters:

public_key (str) – The public key to initialize the instance, represented as a string.

Returns:

The initialized BIP32HD instance.

Return type:

BIP32HD

from_derivation(derivation: IDerivation) BIP32HD

Initializes the BIP32HD instance using the specified derivation path.

Parameters:

derivation (IDerivation) – The derivation path to initialize the instance. It must be an instance of IDerivation.

Returns:

The initialized BIP32HD instance.

Return type:

BIP32HD

update_derivation(derivation: IDerivation) BIP32HD

Updates the derivation path for the BIP32HD instance.

This method first cleans the current derivation path and then sets the new derivation path provided. It drives the instance through the new derivation path.

Parameters:

derivation (IDerivation) – The new derivation path to set. It must be an instance of IDerivation.

Returns:

The updated BIP32HD instance.

Return type:

BIP32HD

clean_derivation() BIP32HD

Cleans the derivation path of the BIP32HD instance.

Returns:

The cleaned BIP32HD instance.

Return type:

BIP32HD

drive(index: int) BIP32HD | None

Drives the BIP32HD instance forward along the derivation path by deriving a child key at the given index.

Parameters:

index (int) – The index to derive the child key.

Returns:

The updated BIP32HD instance with the derived child key, or None if the derivation fails.

Return type:

Optional[BIP32HD]

seed() str | None

Retrieves the seed value as a string if it exists.

Returns:

The seed value as a string, or None if the seed is not set.

Return type:

Optional[str]

root_xprivate_key(version: bytes | int = 76066276, encoded: bool = True) str | None

Generates the root extended private key (xprv) in serialized format.

Parameters:
  • version (Union[bytes, int]) – The version bytes for the extended key. Defaults to Bitcoin mainnet P2PKH version.

  • encoded (bool) – Whether to return the key in encoded format. Defaults to True.

Returns:

The root extended private key (xprv) in serialized format, or None if the chain code is not set.

Return type:

Optional[str]

root_xpublic_key(version: bytes | int = 76067358, encoded: bool = True) str | None

Generates the root extended public key (xpub) in serialized format.

Parameters:
  • version (Union[bytes, int]) – The version bytes for the extended key. Defaults to Bitcoin mainnet P2PKH version.

  • encoded (bool) – Whether to return the key in encoded format. Defaults to True.

Returns:

The root extended public key (xpub) in serialized format, or None if the chain code is not set.

Return type:

Optional[str]

root_private_key() str | None

Retrieves the root private key as a string.

Returns:

The root private key as a hexadecimal string, or None if not set.

Return type:

Optional[str]

root_wif(wif_type: str | None = None) str | None

Retrieves the root private key in WIF format.

Parameters:

wif_type (Optional[str]) – Optional. The type of WIF format to use (‘WIF’ or ‘WIF_COMPRESSED’). If not specified, uses the default type stored in _wif_type.

Returns:

The root private key in WIF format as a string, or None if the root private key is not set.

Return type:

Optional[str]

root_chain_code() str | None

Retrieves the root chain code as a string.

Returns:

The root chain code as a string, or None if the root chain code is not set.

Return type:

Optional[str]

root_public_key(public_key_type: str | None = None) str | None

Retrieves the root public key as a string.

Parameters:

public_key_type (Optional[str]) – The type of public key to retrieve. If None, defaults to the current object’s public key type.

Returns:

The root public key as a string, or None if the root public key is not set.

Return type:

Optional[str]

xprivate_key(version: bytes | int = 76066276, encoded: bool = True) str | None

Retrieves the extended private key (xprivate key) as a serialized string.

Parameters:
  • version (Union[bytes, int]) – The version bytes or integer version of the xprivate key.

  • encoded (bool) – Flag indicating whether the key should be encoded.

Returns:

The serialized xprivate key as a string, or None if the private key or chain code is not set.

Return type:

Optional[str]

xpublic_key(version: bytes | int = 76067358, encoded: bool = True) str | None

Retrieves the extended public key (xpublic key) as a serialized string.

Parameters:
  • version (Union[bytes, int]) – The version bytes or integer version of the xpublic key.

  • encoded (bool) – Flag indicating whether the key should be encoded.

Returns:

The serialized xpublic key as a string, or None if the chain code is not set.

Return type:

Optional[str]

private_key() str | None

Retrieves the private key as a string.

Returns:

The private key as a string, or None if the private key is not set.

Return type:

Optional[str]

wif(wif_type: str | None = None) str | None

Converts the private key to a WIF (Wallet Import Format) string.

Parameters:

wif_type (Optional[str]) – Optional parameter specifying the type of WIF. If None, uses the instance’s default type.

Returns:

The WIF representation of the private key, or None if the private key is not set.

Return type:

Optional[str]

wif_type() str | None

Retrieves the current WIF (Wallet Import Format) type used by the instance.

Returns:

The current WIF type if a WIF is present, otherwise None.

Return type:

Optional[str]

chain_code() str | None

Retrieves the chain code associated with the current instance.

Returns:

The chain code as a string if available, otherwise None.

Return type:

Optional[str]

public_key(public_key_type: str | None = None)

Retrieves the public key associated with the current instance.

Parameters:

public_key_type (Optional[str]) – Optional. Specifies the type of public key to return. If not provided, defaults to the type set during initialization.

Returns:

The public key as a string based on the specified type.

Return type:

str

public_key_type() str

Retrieves the type of public key associated with the current instance.

Returns:

The type of public key.

Return type:

str

compressed() str

Retrieves the compressed form of the public key associated with the current instance.

Returns:

The compressed public key.

Return type:

str

uncompressed() str

Retrieves the uncompressed form of the public key associated with the current instance.

Returns:

The uncompressed public key.

Return type:

str

hash() str

Computes the hash of the public key using SHA-256 followed by RIPEMD-160.

Returns:

The hash of the public key.

Return type:

str

fingerprint() str

Computes the fingerprint of the BIP32HD object by hashing the public key and taking the first 4 bytes (8 characters) of the resulting hash.

Returns:

The fingerprint of the BIP32HD object.

Return type:

str

parent_fingerprint() str | None

Retrieves the parent fingerprint of the BIP32HD object.

Returns:

The parent fingerprint if available, otherwise None.

Return type:

Optional[str]

depth() int

Retrieves the depth of the BIP32HD object in the hierarchical tree.

Returns:

The depth of the object.

Return type:

int

path() str

Retrieves the derivation path associated with the BIP32HD object.

Returns:

The derivation path.

Return type:

str

index() int

Retrieves the index of the current BIP32HD object.

Returns:

The index value.

Return type:

int

indexes() List[int]

Retrieves the list of indexes from the derivation associated with this BIP32HD object.

Returns:

The list of indexes.

Return type:

List[int]

strict() bool | None

Retrieves the strict mode flag associated with this BIP32HD object.

Returns:

The strict mode flag.

Return type:

Optional[bool]

address(address: str = 'P2PKH', public_key_address_prefix: int = 0, script_address_prefix: int = 5, hrp: str = 'bc', witness_version: int = 0, **kwargs) str

Generates an address based on the specified address type and parameters.

Parameters:
  • address (str, optional) – The type of address to generate (e.g., P2PKH, P2SH, P2TR, P2WPKH, P2WPKHInP2SH, P2WSH, P2WSHInP2SH).

  • public_key_address_prefix (int, optional) – Public key address prefix for encoding addresses, defaults to Bitcoin.NETWORKS.MAINNET.PUBLIC_KEY_ADDRESS_PREFIX

  • script_address_prefix (int, optional) – Script address prefix for encoding addresses, defaults to Bitcoin.NETWORKS.MAINNET.SCRIPT_ADDRESS_PREFIX

  • hrp (str, optional) – Human-readable part for Bech32 addresses, defaults to Bitcoin.NETWORKS.MAINNET.HRP

  • witness_version (int, optional) – Witness version for SegWit addresses, defaults to Bitcoin.NETWORKS.MAINNET.WITNESS_VERSIONS.P2WPKH

  • kwargs – Additional keyword arguments for address generation.

Returns:

The generated address.

Return type:

str

Example: https://github.com/hdwallet-io/python-hdwallet/blob/master/examples/hds/bip32.py

class hdwallet.hds.bip44.BIP44HD(ecc: Type[IEllipticCurveCryptography], public_key_type: str = 'compressed', **kwargs)
classmethod name() str

Get the name of the bip class.

Returns:

The name of the bip class.

Return type:

str

from_coin_type(coin_type: int) BIP44HD

Update the BIP44HD object’s derivation path based on the given coin type.

Parameters:

coin_type (int) – The coin type index.

Returns:

Updated BIP44HD object.

Return type:

BIP44HD

from_account(account: int | Tuple[int, int]) BIP44HD

Update the BIP44HD object’s derivation path based on the given account.

Parameters:

account (Union[int, Tuple[int, int]]) – The account index or a tuple of (account index, change).

Returns:

Updated BIP44HD object.

Return type:

BIP44HD

from_change(change: str) BIP44HD

Update the BIP44HD object’s derivation path based on the given change type.

Parameters:

change (str) – The change type (‘external-chain’ or ‘internal-chain’).

Returns:

Updated BIP44HD object.

Return type:

BIP44HD

from_address(address: int | Tuple[int, int]) BIP44HD

Update the BIP44HD object’s derivation path based on the given address index or tuple.

Parameters:

address (Union[int, Tuple[int, int]]) – The address index (int) or tuple of (account index, address index).

Returns:

Updated BIP44HD object.

Return type:

BIP44HD

from_derivation(derivation: IDerivation) BIP44HD

Initialize the BIP44HD object from a given derivation.

Parameters:

derivation (IDerivation) – The BIP44 derivation object.

Returns:

Updated BIP44HD object.

Return type:

BIP44HD

address(public_key_address_prefix: int = 0, **kwargs) str

Generates a Bitcoin address using the P2PKHAddress encoding scheme.

Parameters:
  • public_key_address_prefix (int) – Public key address prefix value for Bitcoin network.

  • kwargs – Additional keyword arguments for encoding.

Returns:

Bitcoin address encoded in P2PKH format.

Return type:

str

Example: https://github.com/hdwallet-io/python-hdwallet/blob/master/examples/hds/bip44.py

class hdwallet.hds.bip49.BIP49HD(ecc: Type[IEllipticCurveCryptography], public_key_type: str = 'compressed', **kwargs)
classmethod name() str

Get the name of the bip class.

Returns:

The name of the bip class.

Return type:

str

from_derivation(derivation: IDerivation) BIP49HD

Sets the derivation path for the BIP49HD instance from a given derivation object.

Parameters:

derivation (IDerivation) – The derivation object to set.

Returns:

The updated BIP49HD instance.

Return type:

BIP49HD

root_xprivate_key(version: bytes | int = 77428856, encoded: bool = True) str | None

Generates the root extended private key (xprivate key) for the BIP44HD instance.

Parameters:
  • version (Union[bytes, int]) – The version bytes or integer for the xprivate key.

  • encoded (bool) – Whether to encode the xprivate key or return it in raw form, defaults to True.

Returns:

The root extended private key (xprivate key) if available, otherwise None.

Return type:

Optional[str]

root_xpublic_key(version: bytes | int = 77429938, encoded: bool = True) str | None

Generates the root extended public key (xpublic key) for the BIP44HD instance.

Parameters:
  • version (Union[bytes, int]) – The version bytes or integer for the xpublic key.

  • encoded (bool) – Whether to encode the xpublic key or return it in raw form, defaults to True.

Returns:

The root extended public key (xpublic key) if available, otherwise None.

Return type:

Optional[str]

xprivate_key(version: bytes | int = 77428856, encoded: bool = True) str | None

Generates the extended private key (xprivate key) for the BIP44HD instance.

Parameters:
  • version (Union[bytes, int]) – The version bytes or integer for the xprivate key.

  • encoded (bool) – Whether to encode the xprivate key or return it in raw form, defaults to True.

Returns:

The extended private key (xprivate key) if available, otherwise None.

Return type:

Optional[str]

xpublic_key(version: bytes | int = 77429938, encoded: bool = True) str | None

Generates the extended public key (xpublic key) for the BIP44HD instance.

Parameters:
  • version (Union[bytes, int]) – The version bytes or integer for the xpublic key.

  • encoded (bool) – Whether to encode the xpublic key or return it in raw form, defaults to True.

Returns:

The extended public key (xpublic key) if available, otherwise None.

Return type:

Optional[str]

address(script_address_prefix: int = 5, **kwargs) str

Generates the P2WPKH-in-P2SH address for the BIP49HD instance.

Parameters:

script_address_prefix (int) – The script address prefix for encoding the address, defaults to the main network prefix.

Returns:

The P2WPKH-in-P2SH encoded address.

Return type:

str

Example: https://github.com/hdwallet-io/python-hdwallet/blob/master/examples/hds/bip49.py

class hdwallet.hds.bip84.BIP84HD(ecc: Type[IEllipticCurveCryptography], public_key_type: str = 'compressed', **kwargs)
classmethod name() str

Get the name of the bip class.

Returns:

The name of the bip class.

Return type:

str

from_derivation(derivation: IDerivation) BIP84HD

Updates the current instance with a new derivation path.

Parameters:

derivation (IDerivation) – The new derivation path instance.

Returns:

The updated BIP84HD instance.

Return type:

BIP84HD

root_xprivate_key(version: bytes | int = 78791436, encoded: bool = True) str | None

Returns the root extended private key (xprv).

Parameters:
  • version (Union[bytes, int]) – The version of the xprv key, either as bytes or an integer. Defaults to P2WPKH xprv version.

  • encoded (bool) – Whether the key should be encoded or not. Defaults to True.

Returns:

The root extended private key as a string, or None if the key cannot be generated.

Return type:

Optional[str]

root_xpublic_key(version: bytes | int = 78792518, encoded: bool = True) str | None

Returns the root extended public key (xpub).

Parameters:
  • version (Union[bytes, int]) – The version of the xpub key, either as bytes or an integer. Defaults to P2WPKH xpub version.

  • encoded (bool) – Whether the key should be encoded or not. Defaults to True.

Returns:

The root extended public key as a string, or None if the key cannot be generated.

Return type:

Optional[str]

xprivate_key(version: bytes | int = 78791436, encoded: bool = True) str | None

Returns the extended private key (xprv).

Parameters:
  • version (Union[bytes, int]) – The version of the xprv key, either as bytes or an integer. Defaults to P2WPKH xprv version.

  • encoded (bool) – Whether the key should be encoded or not. Defaults to True.

Returns:

The extended private key as a string, or None if the key cannot be generated.

Return type:

Optional[str]

xpublic_key(version: bytes | int = 78792518, encoded: bool = True) str | None

Returns the extended public key (xpub).

Parameters:
  • version (Union[bytes, int]) – The version of the xpub key, either as bytes or an integer. Defaults to P2WPKH xpub version.

  • encoded (bool) – Whether the key should be encoded or not. Defaults to True.

Returns:

The extended public key as a string, or None if the key cannot be generated.

Return type:

Optional[str]

address(hrp: str = 'bc', witness_version: int = 0, **kwargs) str

Generates a native SegWit (P2WPKH) address.

Parameters:
  • hrp (str) – The Human-readable Part (HRP) for the address. Defaults to Bitcoin’s mainnet HRP.

  • witness_version (int) – The witness version for the address. Defaults to P2WPKH witness version.

  • kwargs – Additional keyword arguments, not used in this method.

Returns:

The generated native SegWit (P2WPKH) address.

Return type:

str

Example: https://github.com/hdwallet-io/python-hdwallet/blob/master/examples/hds/bip84.py

class hdwallet.hds.bip86.BIP86HD(ecc: Type[IEllipticCurveCryptography], public_key_type: str = 'compressed', **kwargs)
classmethod name() str

Get the name of the bip class.

Returns:

The name of the bip class.

Return type:

str

from_derivation(derivation: IDerivation) BIP86HD

Initialize the BIP86HD instance from a given derivation.

Parameters:

derivation (IDerivation) – The derivation object to initialize from.

Returns:

The updated BIP86HD instance.

Return type:

BIP86HD

root_xprivate_key(version: bytes | int = 76066276, encoded: bool = True) str | None

Generate the root extended private key (xprv) according to BIP44 for the specified version and encoding.

Parameters:
  • version (Union[bytes, int]) – The version bytes or integer for the extended private key.

  • encoded (bool) – Flag indicating whether the key should be encoded (default is True).

Returns:

The root extended private key (xprv) as a string, or None if not available.

Return type:

Optional[str]

root_xpublic_key(version: bytes | int = 76067358, encoded: bool = True) str | None

Generate the root extended public key (xpub) according to BIP44 for the specified version and encoding.

Parameters:
  • version (Union[bytes, int]) – The version bytes or integer for the root extended public key.

  • encoded (bool) – Flag indicating whether the key should be encoded (default is True).

Returns:

The root extended public key (xpub) as a string, or None if not available.

Return type:

Optional[str]

xprivate_key(version: bytes | int = 76066276, encoded: bool = True) str | None

Generate the extended private key (xprv) according to BIP44 for the specified version and encoding.

Parameters:
  • version (Union[bytes, int]) – The version bytes or integer for the extended private key.

  • encoded (bool) – Flag indicating whether the key should be encoded (default is True).

Returns:

The extended private key (xprv) as a string, or None if not available.

Return type:

Optional[str]

xpublic_key(version: bytes | int = 76067358, encoded: bool = True) str | None

Generate the extended public key (xpub) according to BIP44 for the specified version and encoding.

Parameters:
  • version (Union[bytes, int]) – The version bytes or integer for the extended public key.

  • encoded (bool) – Flag indicating whether the key should be encoded (default is True).

Returns:

The extended public key (xpub) as a string, or None if not available.

Return type:

Optional[str]

address(hrp: str = 'bc', witness_version: int = 1, **kwargs) str

Generate a SegWit (P2TR) address using the specified human-readable part (HRP) and witness version.

Parameters:
  • hrp (str) – Human-readable part for the address encoding (default is Bitcoin.NETWORKS.MAINNET.HRP).

  • witness_version (int) – Witness version for SegWit address encoding (default is Bitcoin.NETWORKS.MAINNET.WITNESS_VERSIONS.P2TR).

  • kwargs – Additional keyword arguments passed to the address encoding function.

Returns:

The encoded SegWit (P2TR) address as a string.

Return type:

str

Example: https://github.com/hdwallet-io/python-hdwallet/blob/master/examples/hds/bip86.py

class hdwallet.hds.bip141.BIP141HD(ecc: Type[IEllipticCurveCryptography], semantic: str, public_key_type: str = 'compressed', **kwargs)
classmethod name() str

Get the name of the bip class.

Returns:

The name of the bip class.

Return type:

str

from_semantic(semantic: str, **kwargs) BIP141HD

Initialize the BIP141HD instance based on the provided semantic type.

Parameters:
  • semantic (str) – Semantic type for address generation.

  • kwargs – Additional keyword arguments for specific semantic types.

Returns:

Self-reference for method chaining.

Return type:

BIP141HD

semantic() str

Retrieve the semantic type associated with this BIP141HD instance.

Returns:

Semantic type.

Return type:

str

root_xprivate_key(version: bytes | int | None = None, encoded: bool = True) str | None

Generate the root extended private key for the BIP141HD instance.

Parameters:
  • version (Union[bytes, int], optional) – Optional version bytes or integer for the extended private key. If None, uses the instance’s _xprivate_key_version.

  • encoded (bool) – Flag indicating whether the key should be encoded (default is True).

Returns:

Root extended private key as a string, or None if not available.

Return type:

Optional[str]

root_xpublic_key(version: bytes | int | None = None, encoded: bool = True) str | None

Generate the root extended public key for the BIP141HD instance.

Parameters:
  • version (Union[bytes, int], optional) – Optional version bytes or integer for the extended public key. If None, uses the instance’s _xpublic_key_version.

  • encoded (bool) – Flag indicating whether the key should be encoded (default is True).

Returns:

Root extended public key as a string, or None if not available.

Return type:

Optional[str]

xprivate_key(version: bytes | int | None = None, encoded: bool = True) str | None

Generate the extended private key for the BIP141HD instance.

Parameters:
  • version (Union[bytes, int], optional) – Optional version bytes or integer for the extended private key. If None, uses the instance’s _xprivate_key_version.

  • encoded (bool) – Flag indicating whether the key should be encoded (default is True).

Returns:

Extended private key as a string, or None if not available.

Return type:

Optional[str]

xpublic_key(version: bytes | int | None = None, encoded: bool = True) str | None

Generate the extended public key for the BIP141HD instance.

Parameters:
  • version (Union[bytes, int], optional) – Optional version bytes or integer for the extended public key. If None, uses the instance’s _xpublic_key_version.

  • encoded (bool) – Flag indicating whether the key should be encoded (default is True).

Returns:

Extended public key as a string, or None if not available.

Return type:

Optional[str]

address(address: str | None = None, script_address_prefix: int = 5, hrp: str = 'bc', witness_version: int = 0, **kwargs) str

Generate an address based on the specified address type for the BIP141HD instance.

Parameters:
  • address (Optional[str]) – Optional address type to encode. If None, uses the instance’s _address.

  • script_address_prefix (int) – Script address prefix for P2WPKH-in-P2SH and P2WSH-in-P2SH addresses. Default is Bitcoin mainnet script address prefix.

  • hrp (str) – Human-readable part for P2WPKH and P2WSH addresses. Default is Bitcoin mainnet HRP.

  • witness_version (int) – Witness version for P2WPKH and P2WSH addresses. Default is Bitcoin mainnet witness version.

Returns:

Encoded address string.

Return type:

str

Example: https://github.com/hdwallet-io/python-hdwallet/blob/master/examples/hds/bip141.py

class hdwallet.hds.cardano.CardanoHD(cardano_type: str)
classmethod name() str

Get the name of the cardano class.

Returns:

The name of the cardano class.

Return type:

str

from_seed(seed: str | ISeed, passphrase: str | None = None) CardanoHD

Derive hierarchical deterministic keys from a seed for the specified Cardano type.

Parameters:
  • seed (Union[str, ISeed]) – Seed to derive keys from. Can be either a string or an instance of ISeed.

  • passphrase (Optional[str]) – Optional passphrase for key derivation (default is None).

Returns:

This CardanoHD instance with derived keys set.

Return type:

CardanoHD

from_private_key(private_key: str) CardanoHD

Initialize this CardanoHD instance from a given private key.

Parameters:

private_key (str) – The private key to initialize from.

Returns:

This CardanoHD instance initialized with the provided private key.

Return type:

CardanoHD

from_public_key(public_key: str) CardanoHD

Initialize this CardanoHD instance from a given public key.

Parameters:

public_key (str) – The public key to initialize from.

Returns:

This CardanoHD instance initialized with the provided public key.

Return type:

CardanoHD

drive(index: int) CardanoHD | None

Derives a new CardanoHD instance at the specified index.

Parameters:

index (int) – The index of the child HD wallet to derive.

Returns:

A new CardanoHD instance derived at the specified index.

Return type:

CardanoHD or None

root_xprivate_key(version: bytes | int = 256061908, encoded: bool = True) str | None

Generates the root extended private key (xprv) in serialized format.

Parameters:
  • version (Union[bytes, int]) – The version bytes for the extended key. Defaults to Bitcoin mainnet P2PKH version.

  • encoded (bool) – Whether to return the key in encoded format. Defaults to True.

Returns:

The root extended private key (xprv) in serialized format, or None if the chain code is not set.

Return type:

Optional[str]

xprivate_key(version: bytes | int = 256061908, encoded: bool = True) str | None

Retrieves the extended private key (xprivate key) as a serialized string.

Parameters:
  • version (Union[bytes, int]) – The version bytes or integer version of the xprivate key.

  • encoded (bool) – Flag indicating whether the key should be encoded.

Returns:

The serialized xprivate key as a string, or None if the private key or chain code is not set.

Return type:

Optional[str]

path_key() str | None

Derives a path key based on the current CardanoHD instance.

Returns:

The derived path key as a hexadecimal string.

Return type:

str or None

address(**kwargs) str

Generates an address based on the current CardanoHD instance and specified parameters.

Parameters:

kwargs – Additional parameters based on Cardano type and address type.

Returns:

Generated Cardano address as a string.

Return type:

str

Example: https://github.com/hdwallet-io/python-hdwallet/tree/master/examples/hds/cardano

class hdwallet.hds.electrum.v1.ElectrumV1HD(public_key_type: str = 'uncompressed', **kwargs)
classmethod name() str

Get the name of the v1 class.

Returns:

The name of the v1 class.

Return type:

str

from_seed(seed: bytes | str | ISeed, **kwargs) ElectrumV1HD

Initializes the instance from a seed.

Parameters:
  • seed (Union[bytes, str, ISeed]) – The seed to initialize from.

  • kwargs – Additional keyword arguments.

Returns:

Updated instance of ElectrumV1HD.

Return type:

ElectrumV1HD

from_private_key(private_key: bytes | str | IPrivateKey) ElectrumV1HD

Initializes the instance from a private key.

Parameters:

private_key (Union[bytes, str, IPrivateKey]) – The private key to initialize from.

Returns:

Updated instance of ElectrumV1HD.

Return type:

ElectrumV1HD

from_wif(wif: str) ElectrumV1HD

Initializes the instance from a WIF (Wallet Import Format) string.

Parameters:

wif (str) – The WIF string to initialize from.

Returns:

Updated instance of ElectrumV1HD.

Return type:

ElectrumV1HD

from_public_key(public_key: bytes | str | IPublicKey) ElectrumV1HD

Initializes the instance from a public key.

Parameters:

public_key (Union[bytes, str, IPublicKey]) – The public key to initialize from.

Returns:

Updated instance of ElectrumV1HD.

Return type:

ElectrumV1HD

from_derivation(derivation: IDerivation) ElectrumV1HD

Initializes the instance from a derivation object.

Parameters:

derivation (IDerivation) – The derivation object to initialize from.

Returns:

Updated instance of ElectrumV1HD.

Return type:

ElectrumV1HD

update_derivation(derivation: IDerivation) ElectrumV1HD

Updates the instance with a new derivation object.

Parameters:

derivation (IDerivation) – The new derivation object to update with.

Returns:

Updated instance of ElectrumV1HD.

Return type:

ElectrumV1HD

clean_derivation() ElectrumV1HD

Cleans up the derivation path and updates the instance.

Returns:

Updated instance of ElectrumV1HD.

Return type:

ElectrumV1HD

drive(change_index: int, address_index: int) ElectrumV1HD

Drives the HD wallet by calculating keys based on the given change and address indexes.

Parameters:
  • change_index (int) – Index for change (0 or 1).

  • address_index (int) – Index for address derivation.

Returns:

Updated instance of ElectrumV1HD.

Return type:

ElectrumV1HD

seed() str | None

Retrieves the seed used for key derivation.

Returns:

Seed as a string if available, otherwise None.

Return type:

Optional[str]

master_private_key() str | None

Retrieves the master private key.

Returns:

Master private key as a string if available, otherwise None.

Return type:

Optional[str]

master_wif(wif_type: str | None = None) str | None

Retrieves the master private key in Wallet Import Format (WIF).

Parameters:

wif_type (Optional[str]) – Optional parameter to specify the WIF type (‘WIF’ or ‘WIF_COMPRESSED’). If not provided, defaults to the type determined during initialization.

Returns:

Master private key in WIF format as a string if available, otherwise None.

Return type:

Optional[str]

master_public_key(public_key_type: str | None = None) str

Retrieves the master public key in the specified or default public key type.

Parameters:

public_key_type (Optional[str]) – Optional parameter to specify the public key type (‘uncompressed’ or ‘compressed’). If not provided, defaults to the type determined during initialization.

Returns:

Master public key as a string.

Return type:

str

private_key() str | None

Retrieves the private key as a string, if available.

Returns:

Private key as a string if available, otherwise None.

Return type:

Optional[str]

wif(wif_type: str | None = None) str | None

Retrieves the Wallet Import Format (WIF) representation of the private key, if available.

Parameters:

wif_type (Optional[str]) – Optional. The type of WIF format to use. If not specified, defaults to the instance’s WIF type.

Returns:

WIF representation of the private key if available, otherwise None.

Return type:

Optional[str]

wif_type() str

Retrieves the current type of Wallet Import Format (WIF) used by the instance.

Returns:

The current WIF type.

Return type:

str

public_key(public_key_type: str | None = None) str

Retrieves the public key of the specified type.

Parameters:

public_key_type (str) – Optional. The type of public key to retrieve (‘uncompressed’ or ‘compressed’). Defaults to the type set in the instance.

Returns:

The public key string.

Return type:

str

public_key_type() str

Retrieves the current type of public key stored in the instance.

Returns:

The current public key type.

Return type:

str

uncompressed() str

Retrieves the uncompressed form of the stored public key.

Returns:

The uncompressed public key as a string.

Return type:

str

compressed() str

Retrieves the compressed form of the stored public key.

Returns:

The compressed public key as a string.

Return type:

str

address(public_key_address_prefix: int = 0) str

Generates a Bitcoin address (P2PKH) from the stored public key.

Parameters:

public_key_address_prefix (int) – The prefix for the Bitcoin address default is mainnet.

Returns:

The generated Bitcoin address.

Return type:

str

Example: https://github.com/hdwallet-io/python-hdwallet/blob/master/examples/hds/electrum/v1.py

class hdwallet.hds.electrum.v2.ElectrumV2HD(mode: str = 'standard', public_key_type: str = 'uncompressed', **kwargs)
classmethod name() str

Get the name of the v2 class.

Returns:

The name of the v2 class.

Return type:

str

from_seed(seed: bytes | str | ISeed, **kwargs) ElectrumV2HD

Initialize the instance from a seed.

Parameters:
  • seed (Union[bytes, str, ISeed]) – The seed to derive keys from, can be bytes, str, or an ISeed object.

  • kwargs – Additional keyword arguments.

Returns:

Updated instance of ElectrumV2HD.

Return type:

ElectrumV2HD

from_derivation(derivation: IDerivation) ElectrumV2HD

Initialize the instance from a derivation.

Parameters:

derivation (IDerivation) – The derivation instance to set.

Returns:

Updated instance of ElectrumV2HD.

Return type:

ElectrumV2HD

update_derivation(derivation: IDerivation) ElectrumV2HD

Update the derivation instance of the ElectrumV2HD object.

Parameters:

derivation (IDerivation) – The new derivation instance to update.

Returns:

Updated instance of ElectrumV2HD.

Return type:

ElectrumV2HD

clean_derivation() ElectrumV2HD

Clean up the derivation instance of the ElectrumV2HD object and update the instance.

Returns:

Updated instance of ElectrumV2HD.

Return type:

ElectrumV2HD

drive(change_index: int, address_index: int) ElectrumV2HD

Drive the derivation of keys based on the change index and address index.

Parameters:
  • change_index (int) – The change index.

  • address_index (int) – The address index.

Returns:

Updated instance of ElectrumV2HD.

Return type:

ElectrumV2HD

mode() str

Get the mode of the ElectrumV2HD instance.

Returns:

The mode of the instance.

Return type:

str

seed() str

Get the seed used in the BIP32HD instance.

Returns:

The seed used.

Return type:

str

master_private_key() str | None

Get the master private key of the BIP32HD instance.

Returns:

The master private key as a string, or None if not available.

Return type:

Optional[str]

master_wif(wif_type: str | None = None) str | None

Get the master WIF (Wallet Import Format) for the specified WIF type.

Parameters:

wif_type (Optional[str]) – The type of WIF format to use. Defaults to None (uses self._wif_type).

Returns:

The master WIF for the specified type, or None if the master private key is not available.

Return type:

Optional[str]

master_public_key(public_key_type: str | None = None) str

Get the master public key in the specified public key type.

Parameters:

public_key_type (Optional[str]) – The type of public key format to return. Defaults to None (uses self._public_key_type).

Returns:

The master public key in the specified format.

Return type:

str

private_key() str | None

Get the current private key associated with this instance.

Returns:

The current private key as a string if available, otherwise None.

Return type:

Optional[str]

wif(wif_type: str | None = None) str | None

Get the Wallet Import Format (WIF) representation of the current private key.

Parameters:

wif_type (Optional[str]) – Optional. The type of WIF format to use. Defaults to the instance’s configured WIF type.

Returns:

The WIF representation of the current private key if available, otherwise None.

Return type:

Optional[str]

wif_type() str

Get the current type of Wallet Import Format (WIF) used by this instance.

Returns:

The current WIF type.

Return type:

str

public_key(public_key_type: str | None = None) str

Get the public key associated with this instance, optionally specifying the public key type.

Parameters:

public_key_type (Optional[str]) – Optional parameter to specify the type of public key format. If not provided, defaults to the current instance’s public key type.

Returns:

The public key in the specified format.

Return type:

str

public_key_type() str

Get the current public key type used by this instance.

Returns:

The current public key type.

Return type:

str

uncompressed() str

Get the uncompressed representation of the master public key.

Returns:

Uncompressed master public key.

Return type:

str

compressed() str

Get the compressed representation of the master public key.

Returns:

Compressed master public key.

Return type:

str

address(public_key_address_prefix: int = 0, hrp: str = 'bc', witness_version: str = 0) str

Get the address based on the current mode.

Parameters:
  • public_key_address_prefix (int) – Public key address prefix for P2PKH addresses default: mainnet.

  • hrp (str) – Human-readable part for SegWit addresses default: mainnet.

  • witness_version (str) – Witness version for SegWit addresses default: P2WPKH.

Returns:

Generated address based on the current mode.

Return type:

str

Example: https://github.com/hdwallet-io/python-hdwallet/tree/master/examples/hds/electrum/v2

class hdwallet.hds.monero.MoneroHD(network: str | Type[INetwork] = 'mainnet', **kwargs)
classmethod name() str

Get the name of the monero class.

Returns:

The name of the monero class.

Return type:

str

from_seed(seed: bytes | str | ISeed, **kwargs) MoneroHD

Initialize the MoneroHD instance from a seed value.

Parameters:
  • seed (Union[bytes, str, ISeed]) – Seed value to initialize the HD wallet.

  • kwargs – Additional keyword arguments for customization.

Returns:

Initialized MoneroHD instance.

Return type:

MoneroHD

from_private_key(private_key: bytes | str | IPrivateKey) MoneroHD

Initialize the MoneroHD instance from a private key.

Parameters:

private_key (Union[bytes, str, IPrivateKey]) – Private key value to initialize the HD wallet.

Returns:

Initialized MoneroHD instance.

Return type:

MoneroHD

from_derivation(derivation: IDerivation) MoneroHD

Initialize the MoneroHD instance from a derivation object.

Parameters:

derivation (IDerivation) – Derivation object to initialize the HD wallet.

Returns:

Initialized MoneroHD instance.

Return type:

MoneroHD

update_derivation(derivation: IDerivation) MoneroHD

Update the current derivation of the MoneroHD instance.

Parameters:

derivation (IDerivation) – New derivation object to update the HD wallet’s derivation.

Returns:

Updated MoneroHD instance with the new derivation.

Return type:

MoneroHD

clean_derivation() MoneroHD

Clean up the current derivation state of the MoneroHD instance.

Returns:

Updated MoneroHD instance with cleaned derivation.

Return type:

MoneroHD

from_spend_private_key(spend_private_key: bytes | str | IPrivateKey) MoneroHD

Initialize the MoneroHD instance from a spend private key.

Parameters:

spend_private_key (Union[bytes, str, IPrivateKey]) – Spend private key to initialize from.

Returns:

Updated MoneroHD instance initialized from the spend private key.

Return type:

MoneroHD

from_watch_only(view_private_key: bytes | str | IPrivateKey, spend_public_key: bytes | str | IPublicKey) MoneroHD

Initialize the MoneroHD instance from watch-only keys.

Parameters:
  • view_private_key (Union[bytes, str, IPrivateKey]) – View private key or seed to initialize from.

  • spend_public_key (Union[bytes, str, IPublicKey]) – Spend public key to initialize from.

Returns:

Updated MoneroHD instance initialized from the watch-only keys.

Return type:

MoneroHD

drive(minor_index: int, major_index: int) Tuple[IPublicKey, IPublicKey]

Derives sub-address public keys based on given minor and major indices.

Parameters:
  • minor_index (int) – Minor index for sub-address derivation.

  • major_index (int) – Major index for sub-address derivation.

Returns:

Tuple containing the derived sub-address spend and view public keys.

Return type:

Tuple[IPublicKey, IPublicKey]

seed() str | None

Retrieves the seed used in this MoneroHD instance.

Returns:

Seed used in this instance, or None if not set.

Return type:

Optional[str]

private_key() str | None

Retrieves the private key used in this MoneroHD instance.

Returns:

Private key used in this instance, or None if not set.

Return type:

Optional[str]

spend_private_key() str | None

Retrieves the spend private key used in this MoneroHD instance.

Returns:

Spend private key used in this instance, or None if not set.

Return type:

Optional[str]

view_private_key() str

Retrieves the view private key used in this MoneroHD instance.

Returns:

View private key used in this instance.

Return type:

str

spend_public_key() str

Retrieves the spend public key used in this MoneroHD instance.

Returns:

Spend public key used in this instance.

Return type:

str

view_public_key() str

Retrieves the view public key used in this MoneroHD instance.

Returns:

View public key used in this instance.

Return type:

str

primary_address() str

Generates the primary Monero address associated with the spend and view public keys.

Parameters:

kwargs – Additional keyword arguments.

Returns:

Primary Monero address.

Return type:

str

integrated_address(payment_id: bytes | str) str

Generates the primary Monero address associated with the spend and view public keys.

Returns:

Primary Monero address.

Return type:

str

sub_address(minor: int | None = None, major: int | None = None) str

Generates a sub-address associated with the given minor and major indexes or uses the current derivation indexes.

Parameters:
  • minor (Optional[int]) – Minor index for sub-address derivation.

  • major (Optional[int]) – Major index for sub-address derivation.

Returns:

Generated sub-address.

Return type:

str

address(address_type: str, **kwargs) str

Generates a Monero address of the specified type.

Parameters:
  • address_type (str) – str - Type of Monero address to generate.

  • kwargs – Additional keyword arguments depending on the address type:

Returns:

str - Generated Monero address.

Example: https://github.com/hdwallet-io/python-hdwallet/blob/master/examples/hds/monero.py