HDWallet

class hdwallet.HDWallet(cryptocurrency: Type[ICryptocurrency], hd: Type[IHD] | None = None, network: str | Type[INetwork] = 'mainnet', address: str | Type[IAddress] | None = None, **kwargs)

The HDWallet class represents a hierarchical deterministic wallet object designed for managing various cryptocurrencies. It encapsulates functionality related to cryptocurrency handling, including mnemonic generation, seed generation, address generation, and network configuration.

from_entropy(entropy: IEntropy) HDWallet

Initialize the HDWallet from entropy.

Parameters:

entropy (IEntropy) – The entropy source to generate the mnemonic.

Returns:

The initialized HDWallet instance.

Return type:

HDWallet

Examples:

from_mnemonic(mnemonic: IMnemonic) HDWallet

Initialize the HDWallet from a mnemonic.

Parameters:

mnemonic (IMnemonic) – The mnemonic instance to generate the seed.

Returns:

The initialized HDWallet instance.

Return type:

HDWallet

Examples:

from_seed(seed: ISeed) HDWallet

Initialize the HDWallet from a seed.

Parameters:

seed (ISeed) – The seed instance to initialize the HD wallet.

Returns:

The initialized HDWallet instance.

Return type:

HDWallet

Examples:

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

Initialize the HDWallet from an extended private key.

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

  • encoded (bool) – Flag indicating if the key is encoded. Default is True.

  • strict (bool) – Flag indicating if strict mode should be used. Default is False.

Returns:

The initialized HDWallet instance.

Return type:

HDWallet

Examples:

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

Initialize the HDWallet from an extended public key.

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

  • encoded (bool) – Flag indicating if the key is encoded. Default is True.

  • strict (bool) – Flag indicating if strict mode should be used. Default is False.

Returns:

The initialized HDWallet instance.

Return type:

HDWallet

Examples:

from_derivation(derivation: IDerivation) HDWallet

Initialize the HDWallet from a derivation object.

Parameters:

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

Returns:

The initialized HDWallet instance.

Return type:

HDWallet

update_derivation(derivation: IDerivation) HDWallet

Update the derivation path of the HDWallet.

Parameters:

derivation (IDerivation) – The new derivation object to update the HD wallet.

Returns:

The updated HDWallet instance.

Return type:

HDWallet

clean_derivation() HDWallet

Clean the current derivation path of the HDWallet.

Returns:

The HDWallet instance with the cleaned derivation.

Return type:

HDWallet

from_private_key(private_key: str) HDWallet

Initialize the HDWallet from a private key.

Parameters:

private_key (str) – The private key to initialize the HD wallet.

Returns:

The initialized HDWallet instance.

Return type:

HDWallet

Examples:

from_wif(wif: str) HDWallet

Initialize the HDWallet from a Wallet Import Format (WIF) key.

Parameters:

wif (str) – The WIF key to initialize the HD wallet.

Returns:

The initialized HDWallet instance.

Return type:

HDWallet

Examples:

from_public_key(public_key: str) HDWallet

Initialize the HDWallet from a public key.

Parameters:

public_key (str) – The public key to initialize the HD wallet.

Returns:

The initialized HDWallet instance.

Return type:

HDWallet

Examples:

from_spend_private_key(spend_private_key: bytes | str | IPrivateKey) HDWallet

Initialize the Monero HDWallet from a spend private key.

Parameters:

spend_private_key (Union[bytes, str, IPrivateKey]) – The spend private key to initialize the HD wallet.

Returns:

The initialized Monero HDWallet instance.

Return type:

HDWallet

Examples:

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

Initialize the Monero HDWallet in watch-only mode using a view private key and a spend public key.

Parameters:
  • view_private_key (Union[bytes, str, IPrivateKey]) – The view private key for watch-only mode.

  • spend_public_key (Union[bytes, str, IPublicKey]) – The spend public key for watch-only mode.

Returns:

The initialized Monero HDWallet instance.

Return type:

HDWallet

Examples:

cryptocurrency() str

Get the name of the cryptocurrency associated with this HDWallet.

Returns:

The name of the cryptocurrency.

Return type:

str

symbol() str

Get the symbol of the cryptocurrency associated with this HDWallet.

Returns:

The symbol of the cryptocurrency.

Return type:

str

coin_type() int

Get the coin type of the cryptocurrency associated with this HDWallet.

Returns:

The coin type of the cryptocurrency.

Return type:

int

network() str

Get the name of the network associated with this HDWallet.

Returns:

The name of the network.

Return type:

str

entropy() str | None

Get the entropy value associated with this HDWallet.

Returns:

The entropy value if available, otherwise None.

Return type:

Optional[str]

strength() str | None

Get the strength associated with the entropy of this HDWallet.

Returns:

The strength if available, otherwise None.

Return type:

Optional[str]

mnemonic() str | None

Get the mnemonic associated with this HDWallet.

Returns:

The mnemonic if available, otherwise None.

Return type:

Optional[str]

mnemonic_type() str | None

Get the mnemonic type associated with this HDWallet.

Returns:

The mnemonic type if available, otherwise None.

Return type:

Optional[str]

language() str | None

Get the language associated with the mnemonic of this HDWallet.

Returns:

The language if available, otherwise None.

Return type:

Optional[str]

words() int | None

Get the number of words in the mnemonic of this HDWallet.

Returns:

The number of words if available, otherwise None.

Return type:

Optional[int]

passphrase() str | None

Get the passphrase associated with this HDWallet.

Returns:

The passphrase if available, otherwise None.

Return type:

Optional[str]

seed() str | None

Get the seed associated with this HDWallet.

Returns:

The seed if available, otherwise None.

Return type:

Optional[str]

ecc() str

Get the elliptic curve cryptography (ECC) name associated with this HDWallet.

Returns:

The ECC name.

Return type:

str

hd() str

Get the name of the HD type associated with this HDWallet.

Returns:

The name of the HD type.

Return type:

str

semantic() str | None

Get the semantic associated with the HD type of this HDWallet.

Returns:

The semantic if available, otherwise None.

Return type:

Optional[str]

cardano_type() str | None

Get the Cardano type associated with this HDWallet.

Returns:

The Cardano type if available and applicable, otherwise None.

Return type:

Optional[str]

mode() str

Get the mode associated with the HD type of this HDWallet.

Returns:

The mode.

Return type:

str

path_key() str | None

Get the path key associated with the HD wallet.

Returns:

The path key if available, otherwise None.

Return type:

Optional[str]

root_xprivate_key(semantic: str | None = None, encoded: bool = True) str | None

Get the root extended private key (xpriv) associated with the HD wallet.

Parameters:
  • semantic (Optional[str]) – Optional semantic to use for deriving the key.

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

Returns:

The root xpriv key if available, otherwise None.

Return type:

Optional[str]

root_xpublic_key(semantic: str | None = None, encoded: bool = True) str | None

Get the root extended public key (xpub) associated with the HD wallet.

Parameters:
  • semantic (Optional[str]) – Optional semantic to use for deriving the key.

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

Returns:

The root xpub key if available, otherwise None.

Return type:

Optional[str]

master_xprivate_key(semantic: str | None = None, encoded: bool = True) str | None

Get the master extended private key (xpriv) associated with the HD wallet.

Parameters:
  • semantic (Optional[str]) – Optional semantic to use for deriving the key.

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

Returns:

The master xpriv key if available, otherwise None.

Return type:

Optional[str]

master_xpublic_key(semantic: str | None = None, encoded: bool = True) str | None

Get the master extended public key (xpub) associated with the HD wallet.

Parameters:
  • semantic (Optional[str]) – Optional semantic to use for deriving the key.

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

Returns:

The master xpub key if available, otherwise None.

Return type:

Optional[str]

root_private_key() str | None

Get the root private key associated with the HD wallet.

Returns:

The root private key if available, otherwise None.

Return type:

Optional[str]

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

Get the root Wallet Import Format (WIF) associated with the HD wallet.

Parameters:

wif_type (Optional[str]) – Optional WIF type.

Returns:

The root WIF if available, otherwise None.

Return type:

Optional[str]

root_chain_code() str | None

Get the root chain code associated with the HD wallet.

Returns:

The root chain code if available, otherwise None.

Return type:

Optional[str]

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

Get the root public key associated with the HD wallet.

Parameters:

public_key_type (Optional[str]) – Optional public key type.

Returns:

The root public key if available, otherwise None.

Return type:

Optional[str]

master_private_key() str | None

Get the master private key associated with the HD wallet.

Returns:

The master private key if available, otherwise None.

Return type:

Optional[str]

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

Get the master Wallet Import Format (WIF) associated with the HD wallet.

Parameters:

wif_type (Optional[str]) – Optional WIF type.

Returns:

The master WIF if available, otherwise None.

Return type:

Optional[str]

master_chain_code() str | None

Get the master chain code associated with the HD wallet.

Returns:

The master chain code if available, otherwise None.

Return type:

Optional[str]

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

Get the master public key associated with the HD wallet.

Parameters:

public_key_type (Optional[str]) – Optional public key type.

Returns:

The master public key if available, otherwise None.

Return type:

Optional[str]

xprivate_key(semantic: str | None = None, encoded: bool = True) str | None

Get the extended private key (xpriv) associated with the HD wallet.

Parameters:
  • semantic (Optional[str]) – Optional semantic to use for deriving the key.

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

Returns:

The xpriv key if available, otherwise None.

Return type:

Optional[str]

xpublic_key(semantic: str | None = None, encoded: bool = True) str | None

Get the extended public key (xpub) associated with the HD wallet.

Parameters:
  • semantic (Optional[str]) – Optional semantic to use for deriving the key.

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

Returns:

The xpub key if available, otherwise None.

Return type:

Optional[str]

private_key() str | None

Get the private key associated with the HD wallet.

Returns:

The private key if available, otherwise None.

Return type:

Optional[str]

spend_private_key() str

Get the spend private key associated with the Monero HD wallet.

Returns:

The spend private key.

Return type:

str

view_private_key() str

Get the view private key associated with the Monero HD wallet.

Returns:

The view private key.

Return type:

str

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

Get the Wallet Import Format (WIF) associated with the HD wallet.

Parameters:

wif_type (Optional[str]) – Optional WIF type.

Returns:

The WIF if available, otherwise None.

Return type:

Optional[str]

wif_type() str | None

Get the WIF type associated with the HD wallet.

Returns:

The WIF type if available, otherwise None.

Return type:

Optional[str]

chain_code() str | None

Get the chain code associated with the HD wallet.

Returns:

The chain code if available, otherwise None.

Return type:

Optional[str]

public_key(public_key_type: str | None = None) str

Get the public key associated with the HD wallet.

Parameters:

public_key_type (Optional[str]) – Optional public key type.

Returns:

The public key.

Return type:

str

public_key_type() str

Get the public key type associated with the HD wallet.

Returns:

The public key type.

Return type:

str

uncompressed() str

Get the uncompressed public key associated with the HD wallet.

Returns:

The uncompressed public key.

Return type:

str

compressed() str

Get the compressed public key associated with the HD wallet.

Returns:

The compressed public key.

Return type:

str

spend_public_key() str

Get the spend public key associated with the Monero HD wallet.

Returns:

The spend public key.

Return type:

str

view_public_key() str

Get the view public key associated with the Monero HD wallet.

Returns:

The view public key.

Return type:

str

hash() str

Get the hash associated with the HD wallet.

Returns:

The hash.

Return type:

str

depth() int

Get the depth associated with the HD wallet.

Returns:

The depth.

Return type:

int

fingerprint() str

Get the fingerprint associated with the HD wallet.

Returns:

The fingerprint.

Return type:

str

parent_fingerprint() str

Get the parent fingerprint associated with the HD wallet.

Returns:

The parent fingerprint.

Return type:

str

path() str

Get the path associated with the HD wallet.

Returns:

The path.

Return type:

str

index() int

Get the index associated with the HD wallet.

Returns:

The index.

Return type:

int

indexes() List[int]

Get the indexes associated with the HD wallet.

Returns:

The indexes.

Return type:

List[int]

strict() bool | None

Get the strict flag associated with the HD wallet.

Returns:

The strict flag if applicable, otherwise None.

Return type:

Optional[bool]

primary_address() str | None

Get the primary address associated with the Monero HD wallet.

Returns:

The primary address if applicable, otherwise None.

Return type:

Optional[str]

integrated_address(payment_id: bytes | str | None = None) str | None

Get the integrated address associated with the Monero HD wallet.

Parameters:

payment_id (Union[bytes, str]) – The payment ID.

Returns:

The integrated address if applicable, otherwise None.

Return type:

Optional[str]

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

Get the sub address associated with the Monero HD wallet.

Parameters:
  • minor (Optional[int]) – Optional minor index.

  • major (Optional[int]) – Optional major index.

Returns:

The sub address if applicable, otherwise None.

Return type:

Optional[str]

address(address: str | Type[IAddress] | None = None, **kwargs) str | None

Get the address associated with the HD wallet.

Parameters:
  • address (Optional[Union[str, Type[IAddress]]]) – Optional address name or type.

  • kwargs – Additional keyword arguments for address generation.

Returns:

The generated address.

Return type:

str

dump(exclude: set | None = None) dict

Dump the state of the HD wallet and related information into a dictionary.

Parameters:

exclude (Optional[set]) – Optional set of keys to exclude from the dump.

Returns:

The dictionary containing the dumped information.

Return type:

dict

dumps(exclude: set | None = None) dict | List[dict] | None

Dump the state of multiple derivations of the HD wallet and related information into dictionaries.

Parameters:

exclude (Optional[set]) – Optional set of keys to exclude from the dump.

Returns:

Either a single dictionary or a list of dictionaries containing the dumped information, depending on the number of derivations.

Return type:

Optional[Union[dict, List[dict]]]