### Development Installation Source: https://hdwallet.readthedocs.io/en/v3.5.1/_sources/installation.rst Installs the hdwallet package in editable mode with development dependencies, including CLI, tests, and documentation. This setup is for contributing to the project. ```shell pip install -e .[cli,tests,docs] ``` -------------------------------- ### Install HDWallet CLI Source: https://hdwallet.readthedocs.io/en/v3.5.1/_sources/installation.rst Installs the hdwallet package with command-line interface extras. This enables global access to hdwallet commands from your terminal. ```shell pip install hdwallet[cli] ``` -------------------------------- ### Install HDWallet from Git Source: https://hdwallet.readthedocs.io/en/v3.5.1/_sources/installation.rst Installs the latest version of the hdwallet library directly from its GitHub repository. This is useful for development or testing the most recent code. ```shell pip install git+git://github.com/hdwallet-io/python-hdwallet.git ``` -------------------------------- ### Verify HDWallet Installation Source: https://hdwallet.readthedocs.io/en/v3.5.1/_sources/installation.rst Executes the hdwallet command to check if the installation was successful and display its usage information. This command provides access to various HDWallet functionalities. ```shell hdwallet ``` -------------------------------- ### MoneroDerivation Usage Examples Source: https://hdwallet.readthedocs.io/en/v3.5.1/derivations Demonstrates how to use the MoneroDerivation class for setting derivation paths and retrieving index values. Includes examples of initializing the class and manipulating derivation indexes. ```Python from hdwallet.derivations.monero import MoneroDerivation # Example 1: Setting major and minor indexes monero_derivation: MoneroDerivation = MoneroDerivation() monero_derivation.from_major(11) monero_derivation.from_minor(2) # Example 2: Initializing with specific indexes and checking path monero_derivation_init: MoneroDerivation = MoneroDerivation(minor=11, major=2) print(monero_derivation_init.path()) print(monero_derivation_init.indexes()) print(monero_derivation_init.minor()) print(monero_derivation_init.major()) ``` -------------------------------- ### Install HDWallet CLI Source: https://hdwallet.readthedocs.io/en/v3.5.1/installation Installs the HDWallet library along with its command-line interface (CLI) dependencies. This enables you to interact with HDWallet directly from your terminal using various commands. ```shell pip install hdwallet[cli] ``` -------------------------------- ### Install HDWallet via Pip Source: https://hdwallet.readthedocs.io/en/v3.5.1/_sources/installation.rst Installs the hdwallet Python package using pip. This is the recommended method for adding the library to your Python environment. ```shell pip install hdwallet ``` -------------------------------- ### Install HDWallet from Git Source: https://hdwallet.readthedocs.io/en/v3.5.1/installation Installs the HDWallet library directly from its GitHub repository. This method is useful for obtaining the latest development version or a specific commit from the source code. ```shell pip install git+git://github.com/hdwallet-io/python-hdwallet.git ``` -------------------------------- ### Development Install Source: https://hdwallet.readthedocs.io/en/v3.5.1/installation Installs HDWallet in an editable mode for development purposes. This includes optional dependencies for the CLI, testing suite, and documentation generation, allowing for local code modifications and testing. ```shell pip install -e .[cli,tests,docs] ``` -------------------------------- ### ElectrumDerivation Usage Examples Source: https://hdwallet.readthedocs.io/en/v3.5.1/derivations Provides practical examples of using the ElectrumDerivation class, including initializing it, calling the name class method, setting change and address indices, and retrieving the resulting path and indices. ```python >>> from hdwallet.derivations.electrum import ElectrumDerivation >>> ElectrumDerivation.name() 'Electrum' >>> electrum_derivation: ElectrumDerivation = ElectrumDerivation() >>> electrum_derivation.path() 'm/0/0' >>> electrum_derivation.from_change(change=0) >>> electrum_derivation.from_address(address=10) >>> electrum_derivation.path() 'm/0/10' >>> electrum_derivation.indexes() [0, 10] >>> electrum_derivation.change() 0 >>> electrum_derivation.address() 10 ``` -------------------------------- ### CIP1852 Derivation Examples Source: https://hdwallet.readthedocs.io/en/v3.5.1/derivations Demonstrates the usage of the CIP1852Derivation class for generating and managing Cardano CIP-1852 derivation paths. Includes examples for setting account, role, and address indexes, and retrieving path components. ```python from hdwallet.derivations.cip1852 import CIP1852Derivation, ROLES # Get the name of the derivation class print(CIP1852Derivation.name()) # Instantiate CIP1852Derivation and use its methods cip1852_derivation: CIP1852Derivation = CIP1852Derivation() print(cip1852_derivation.path()) # Set derivation path components cip1852_derivation.from_account(account=1) cip1852_derivation.from_role(role="external-chain") cip1852_derivation.from_address(address=10) print(cip1852_derivation.path()) # Get all indexes print(cip1852_derivation.indexes()) # Instantiate with specific parameters cip1852_derivation_specific: CIP1852Derivation = CIP1852Derivation(account=1, role=ROLES.EXTERNAL_CHAIN, address=10) # Retrieve specific components print(cip1852_derivation_specific.purpose()) print(cip1852_derivation_specific.coin_type()) print(cip1852_derivation_specific.account()) print(cip1852_derivation_specific.role()) print(cip1852_derivation_specific.address()) ``` -------------------------------- ### Install HDWallet via pip Source: https://hdwallet.readthedocs.io/en/v3.5.1/installation Installs the HDWallet library using pip. This is the standard method for adding the library to your Python environment, making its functionalities available for use in your projects. ```shell pip install hdwallet ``` -------------------------------- ### Cardano Seed Generation Examples Source: https://hdwallet.readthedocs.io/en/v3.5.1/seeds Demonstrates how to generate Cardano seeds from mnemonics using the CardanoSeed class. Includes examples for different derivation paths like Byron and Shelley. ```python from hdwallet.seeds.cardano import CardanoSeed # Example using a Russian mnemonic phrase mnemonic_phrase = "возраст чушь целевой клоун колено кисть против заснуть шоколад хулиган готовый шумно" # Derive seed from mnemonic derived_seed = CardanoSeed.from_mnemonic(mnemonic=mnemonic_phrase) print(f"Derived Seed: {derived_seed}") # Initialize CardanoSeed with a seed cardano_seed_instance = CardanoSeed(seed=derived_seed) # Get seed information print(f"Seed Name: {cardano_seed_instance.name()}") print(f"Seed Value: {cardano_seed_instance.seed()}") # Generate seeds for different derivation paths byron_icarus_seed = cardano_seed_instance.generate_byron_icarus(mnemonic=mnemonic_phrase) print(f"Byron Icarus Seed: {byron_icarus_seed}") byron_ledger_seed = cardano_seed_instance.generate_byron_ledger(mnemonic=mnemonic_phrase) print(f"Byron Ledger Seed: {byron_ledger_seed}") byron_legacy_seed = cardano_seed_instance.generate_byron_legacy(mnemonic=mnemonic_phrase) print(f"Byron Legacy Seed: {byron_legacy_seed}") shelley_icarus_seed = cardano_seed_instance.generate_shelley_icarus(mnemonic=mnemonic_phrase) print(f"Shelley Icarus Seed: {shelley_icarus_seed}") shelley_ledger_seed = cardano_seed_instance.generate_shelley_ledger(mnemonic=mnemonic_phrase) print(f"Shelley Ledger Seed: {shelley_ledger_seed}") ``` -------------------------------- ### Aptos Address Python Example Source: https://hdwallet.readthedocs.io/en/v3.5.1/addresses Example usage of the AptosAddress class for encoding and decoding addresses, and retrieving the cryptocurrency name. ```python from hdwallet.addresses.aptos import AptosAddress # Get the name of the cryptocurrency print(f"Cryptocurrency Name: {AptosAddress.name()}") # Example public key public_key_hex = "00d14696583ee9144878635b557d515a502b04366818dfe7765737746b4f57978d" # Encode public key to Aptos address encoded_address = AptosAddress.encode(public_key=public_key_hex) print(f"Encoded Aptos Address: {encoded_address}") # Decode Aptos address back to public key decoded_public_key = AptosAddress.decode(address=encoded_address) print(f"Decoded Public Key: {decoded_public_key}") ``` -------------------------------- ### HDWDerivation Class Usage Example Source: https://hdwallet.readthedocs.io/en/v3.5.1/derivations Demonstrates how to instantiate and use the HDWDerivation class, including setting account and address, and retrieving path, indexes, account, ECC, and address values. ```python >>> from hdwallet.derivations.hdw import HDWDerivation >>> HDWDerivation.name() 'HDW' >>> hdw_derivation: HDWDerivation = HDWDerivation() >>> hdw_derivation.from_account(11) >>> hdw_derivation.from_address(2) >>> hdw_derivation: HDWDerivation = HDWDerivation(ecc='SLIP10-Ed25519-Monero') >>> hdw_derivation.path() "m/0'/5/0" >>> hdw_derivation.indexes() [2147483648, 5, 0] >>> hdw_derivation.account() 0 >>> hdw_derivation.ecc() 'SLIP10-Ed25519-Monero' >>> hdw_derivation.address() 0 ``` -------------------------------- ### Algorand Address Python Example Source: https://hdwallet.readthedocs.io/en/v3.5.1/addresses Example usage of the AlgorandAddress class for encoding and decoding addresses, and retrieving the cryptocurrency name. ```python from hdwallet.addresses.algorand import AlgorandAddress # Get the name of the cryptocurrency print(f"Cryptocurrency Name: {AlgorandAddress.name()}") # Example public key public_key_hex = "00d14696583ee9144878635b557d515a502b04366818dfe7765737746b4f57978d" # Encode public key to Algorand address encoded_address = AlgorandAddress.encode(public_key=public_key_hex) print(f"Encoded Algorand Address: {encoded_address}") # Decode Algorand address back to public key decoded_public_key = AlgorandAddress.decode(address=encoded_address) print(f"Decoded Public Key: {decoded_public_key}") ``` -------------------------------- ### Python: Electrum V2 Mnemonic Usage Example Source: https://hdwallet.readthedocs.io/en/v3.5.1/mnemonics Demonstrates generating an Electrum V2 mnemonic phrase from words and entropy using the `ElectrumV2Mnemonic` class. It shows how to specify language and mnemonic types, and includes an example of encoding with a potential error. ```python >>> from hdwallet.mnemonics.electrum.v2 import ElectrumV2Mnemonic, ELECTRUM_V2_MNEMONIC_WORDS, ELECTRUM_V2_MNEMONIC_LANGUAGES, ELECTRUM_V2_MNEMONIC_TYPES >>> ElectrumV2Mnemonic.name() 'Electrum-V2' >>> mnemonic: str = ElectrumV2Mnemonic.from_words(words=BIP39_MNEMONIC_WORDS.TWELVE, language=ELECTRUM_V2_MNEMONIC_LANGUAGES.CHINESE_SIMPLIFIED, mnemonic_type=ELECTRUM_V2_MNEMONIC_TYPES.SEGWIT) >>> ElectrumV2Mnemonic.from_entropy(entropy="0c3a7d6111221a9a9f3f309ee2680aa54a", language=ELECTRUM_V2_MNEMONIC_LANGUAGES.CHINESE_SIMPLIFIED) '凭 八 响 帐 乙 牢 碗 头 术 透 德 砖' >>> ElectrumV2Mnemonic.encode(entropy="0c3a7d6111221a9a9f3f309ee2680aa54a", language=ELECTRUM_V2_MNEMONIC_LANGUAGES.CHINESE_SIMPLIFIED, mnemonic_type=ELECTRUM_V2_MNEMONIC_TYPES.SEGWIT) Traceback (most recent call last): File "", line 1, in File "X:\\#repos\\python-hdwallet\\hdwallet\\mnemonics\\electrum\\v2\\mnemonic.py", line 321, in encode raise EntropyError("Entropy bytes are not suitable for generating a valid mnemonic") ``` -------------------------------- ### HD Wallet Address Examples Source: https://hdwallet.readthedocs.io/en/v3.5.1/addresses Demonstrates how to use the ADDRESSES class to retrieve address names, classes, and specific address instances, along with type checking. ```Python >>> from hdwallet.addresses import ADDRESSES >>> ADDRESSES.names() ['Algorand', 'Aptos', 'Avalanche', 'Cardano', 'Cosmos', 'EOS', 'Ergo', 'Ethereum', 'Filecoin', 'Harmony', 'Icon', 'Injective', 'Monero', 'MultiversX', 'Nano', 'Near', 'Neo', 'OKT-Chain', 'P2PKH', 'P2SH', 'P2TR', 'P2WPKH', 'P2WPKH-In-P2SH', 'P2WSH', 'P2WSH-In-P2SH', 'Ripple', 'Solana', 'Stellar', 'Sui', 'Tezos', 'Tron', 'XinFin', 'Zilliqa'] >>> ADDRESSES.classes() [, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ] >>> from hdwallet.addresses.p2wsh import P2WSHAddress >>> ADDRESSES.address(name="P2WSH") >>> ADDRESSES.address(name="P2WSH") == P2WSHAddress True >>> ADDRESSES.is_address(name="P2WSH") True ``` -------------------------------- ### HDWallet CLI Usage Source: https://hdwallet.readthedocs.io/en/v3.5.1/installation Details the usage of the HDWallet command-line interface. It outlines the available global options and commands for managing HD wallets, including generating keys, dumping, listing, and selecting specific operations. ```APIDOC Usage: hdwallet [OPTIONS] COMMAND [ARGS]... Options: -v, --version Show HDWallet version and exit -h, --help Show this message and exit. Commands: dump (d) Select Dump hdwallet keys dumps (ds) Select Dumps hdwallet keys generate (g) Select Generate for HDWallet list (l) Select List for HDWallet information ``` -------------------------------- ### XinFin Address Name Example Source: https://hdwallet.readthedocs.io/en/v3.5.1/addresses Demonstrates how to use the XinFinAddress class to get the protocol name. ```Python from hdwallet.addresses.xinfin import XinFinAddress # Get the name of the protocol print(XinFinAddress.name()) ``` -------------------------------- ### HDWallet CLI Usage Source: https://hdwallet.readthedocs.io/en/v3.5.1/_sources/installation.rst Details the available commands, options, and general usage for the HDWallet command-line interface. This serves as the primary API documentation for the CLI tool. ```APIDOC Usage: hdwallet [OPTIONS] COMMAND [ARGS]... Options: -v, --version Show HDWallet version and exit -h, --help Show this message and exit. Commands: dump (d) Select Dump hdwallet keys dumps (ds) Select Dumps hdwallet keys generate (g) Select Generate for HDWallet list (l) Select List for HDWallet information ``` -------------------------------- ### Zilliqa Address Name Example Source: https://hdwallet.readthedocs.io/en/v3.5.1/addresses Demonstrates how to use the ZilliqaAddress class to get the protocol name. ```Python from hdwallet.addresses.zilliqa import ZilliqaAddress # Get the name of the protocol print(ZilliqaAddress.name()) ``` -------------------------------- ### Ripple Address Encoding/Decoding Example Source: https://hdwallet.readthedocs.io/en/v3.5.1/addresses Demonstrates how to use the RippleAddress class to get the address name, encode a public key into a Ripple address, and decode it. ```python from hdwallet.addresses.ripple import RippleAddress # Get the name of the address type print(RippleAddress.name()) # Encode a public key to a Ripple address address: str = RippleAddress.encode(public_key="0374a436044b4904bbd7a074b098d65fad39fc5b66f28da8440f10dbcf86568429") print(address) # Decode a Ripple address print(RippleAddress.decode(address=address)) ``` -------------------------------- ### Tron Address Encoding and Decoding Example Source: https://hdwallet.readthedocs.io/en/v3.5.1/addresses Demonstrates how to use the TronAddress class to get the protocol name, encode a public key into a Tron address, and decode a Tron address. ```Python from hdwallet.addresses.tron import TronAddress # Get the name of the protocol print(TronAddress.name()) # Encode a public key into a Tron address address: str = TronAddress.encode(public_key="0374a436044b4904bbd7a074b098d65fad39fc5b66f28da8440f10dbcf86568429") print(address) # Decode a Tron address print(TronAddress.decode(address=address)) ``` -------------------------------- ### Tezos Address Encoding and Decoding Example Source: https://hdwallet.readthedocs.io/en/v3.5.1/addresses Demonstrates how to use the TezosAddress class to get the protocol name, encode a public key into a Tezos address, and decode a Tezos address. ```Python from hdwallet.addresses.tezos import TezosAddress # Get the name of the protocol print(TezosAddress.name()) # Encode a public key into a Tezos address address: str = TezosAddress.encode(public_key="00d14696583ee9144878635b557d515a502b04366818dfe7765737746b4f57978d") print(address) # Decode a Tezos address print(TezosAddress.decode(address=address)) ``` -------------------------------- ### Zilliqa Address Encoding and Decoding Example Source: https://hdwallet.readthedocs.io/en/v3.5.1/addresses Demonstrates how to use the ZilliqaAddress class to encode a public key into a Zilliqa address and decode a Zilliqa address back to its original form. It also shows how to get the name of the address type. ```python from hdwallet.addresses.zilliqa import ZilliqaAddress # Get the name of the address type print(ZilliqaAddress.name()) # Encode a public key to a Zilliqa address address: str = ZilliqaAddress.encode(public_key="0374a436044b4904bbd7a074b098d65fad39fc5b66f28da8440f10dbcf86568429") print(address) # Decode a Zilliqa address decoded_address = ZilliqaAddress.decode(address=address) print(decoded_address) ``` -------------------------------- ### BIP32HD Initialization and Derivation Methods Source: https://hdwallet.readthedocs.io/en/v3.5.1/hds This section covers the core methods for initializing a BIP32HD wallet instance and managing its derivation path. It includes methods for creating instances from WIF, private keys, public keys, and derivation paths, as well as functions to update, clean, and drive the derivation. ```APIDOC BIP32HD Class Methods: 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. Returns: BIP32HD: The initialized BIP32HD instance. from_private_key(private_key: str) -> BIP32HD Initializes the BIP32HD instance from the given private key. Parameters: private_key (str): The private key as a string. Returns: BIP32HD: The initialized BIP32HD instance. from_public_key(public_key: str) -> BIP32HD Initializes the BIP32HD instance from the given public key. Parameters: public_key (str): The public key as a string. Returns: BIP32HD: The initialized BIP32HD instance. from_derivation(derivation: IDerivation) -> BIP32HD Initializes the BIP32HD instance using the specified derivation path. Parameters: derivation (IDerivation): The derivation path instance. Returns: BIP32HD: The initialized BIP32HD instance. 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. Parameters: derivation (IDerivation): The new derivation path to set. Returns: BIP32HD: The updated BIP32HD instance. clean_derivation() -> BIP32HD Cleans the derivation path of the BIP32HD instance. Returns: BIP32HD: The cleaned BIP32HD instance. 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: Optional[BIP32HD]: The updated BIP32HD instance with the derived child key, or None if the derivation fails. seed() -> str | None Retrieves the seed value as a string if it exists. Returns: Optional[str]: The seed value as a string, or None if the seed is not set. root_xprivate_key(version: bytes | int = 76066276, encoded: bool = True) -> str | None Generates the root extended private key (xprv) in serialized format. Parameters: version (bytes | int): The version bytes for the extended key (default: 76066276). encoded (bool): Whether to return the key in encoded format (default: True). Returns: Optional[str]: The serialized root extended private key, or None if not available. ``` -------------------------------- ### BIP44HD Class Methods Source: https://hdwallet.readthedocs.io/en/v3.5.1/hds Documentation for the BIP44HD class, detailing methods for managing derivation paths and generating addresses. Includes class methods for initialization and instance methods for path manipulation. ```APIDOC class hdwallet.hds.bip44.BIP44HD: __init__(ecc: Type[IEllipticCurveCryptography], public_key_type: str = 'compressed', **kwargs) ecc: The elliptic curve cryptography implementation to use. public_key_type: Type of public key ('compressed' or 'uncompressed'). Defaults to 'compressed'. **kwargs: Additional keyword arguments. 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: Union[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: Union[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. Defaults to 0. **kwargs: Additional keyword arguments for encoding. Returns: Bitcoin address encoded in P2PKH format. Return type: str ``` -------------------------------- ### HDWallet Initialization Methods Source: https://hdwallet.readthedocs.io/en/v3.5.1/hdwallet Methods for initializing an HDWallet instance from different key formats. These include initialization from Wallet Import Format (WIF), public key, spend private key, and watch-only mode. ```APIDOC HDWallet Initialization: Initialize the HDWallet from a Wallet Import Format (WIF) key. Parameters: wif (str): The WIF key to initialize the HD wallet. Returns: HDWallet: The initialized HDWallet instance. Examples: BIP’s: Electrum-V1: 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: HDWallet: The initialized HDWallet instance. Examples: BIP’s: Cardano: Electrum-V1: 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: HDWallet: The initialized Monero HDWallet instance. Examples: Monero: 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: HDWallet: The initialized Monero HDWallet instance. Examples: Monero: ``` -------------------------------- ### BIP44Derivation Class Methods Source: https://hdwallet.readthedocs.io/en/v3.5.1/derivations Implements derivation paths according to the BIP44 standard. Provides methods to construct paths from coin type, account, change, and address. ```APIDOC hdwallet.derivations.bip44.BIP44Derivation: name(): Description: Returns the name of the derivation standard (BIP44). Returns: String 'BIP44'. from_coin_type(coin_type: int, account: int = 0, change: int = 0, address: int = 0): Description: Creates a BIP44 derivation path from coin type, account, change, and address index. Parameters: coin_type: The coin type identifier (e.g., 0 for Bitcoin). account: The account index (default: 0). change: The change bit (0 for external, 1 for internal, default: 0). address: The address index within the account/change branch (default: 0). Returns: BIP44Derivation object. from_account(account: int, change: int = 0, address: int = 0): Description: Creates a BIP44 derivation path from account, change, and address index, assuming a default coin type. Parameters: account: The account index. change: The change bit (default: 0). address: The address index (default: 0). Returns: BIP44Derivation object. from_change(change: int, address: int = 0): Description: Creates a BIP44 derivation path from change and address index, assuming default coin type and account. Parameters: change: The change bit (default: 0). address: The address index (default: 0). Returns: BIP44Derivation object. from_address(address: int = 0): Description: Creates a BIP44 derivation path from address index, assuming default coin type, account, and change. Parameters: address: The address index (default: 0). Returns: BIP44Derivation object. clean(): Description: Cleans and normalizes the BIP44 derivation path. Returns: Cleaned BIP44Derivation object. purpose(): Description: Returns the purpose code for BIP44 (44). Returns: Integer 44. coin_type(): Description: Returns the coin type index of the derivation. Returns: Integer coin type. account(): Description: Returns the account index of the derivation. Returns: Integer account index. change(): Description: Returns the change bit of the derivation. Returns: Integer change bit. address(): Description: Returns the address index of the derivation. Returns: Integer address index. ``` -------------------------------- ### BIP32HD Key Initialization Methods Source: https://hdwallet.readthedocs.io/en/v3.5.1/hds Provides class methods for initializing BIP32HD instances from various sources, including seeds, extended private keys (xprv), and extended public keys (xpub). Supports different encoding and strictness options during initialization. ```APIDOC hdwallet.hds.bip32.BIP32HD: 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 ``` -------------------------------- ### BIP44 Derivation Path Methods and Usage Source: https://hdwallet.readthedocs.io/en/v3.5.1/derivations Demonstrates the usage of the BIP44Derivation class for generating hierarchical deterministic wallet paths according to BIP44 standards. Includes examples of setting coin type, account, change, and address, and retrieving the derived path and indexes. ```APIDOC class hdwallet.derivations.bip44.BIP44Derivation: purpose() → int Retrieve the purpose value from the object’s _purpose attribute. Returns the first element of _purpose. Returns: The purpose value stored in _purpose. Return type: int coin_type() → int Retrieve the coin type value from the object’s _coin_type attribute. Returns the first element of _coin_type. Returns: The coin type value stored in _coin_type. Return type: int account() → int Retrieve the account from the object. Returns: The account value. Return type: int change(*name_only: bool = True*) → str Get the change value. Parameters: name_only (bool): Return the change name if True, or its index if False. Returns: Change name or index. Return type: str address() → int Retrieve the address from the object. Returns: The address value. Return type: int name() → str Get the name of the derivation class. Returns: The name of the derivation class. Return type: str ``` ```python from hdwallet.derivations.bip44 import BIP44Derivation, CHANGES # Get the name of the derivation print(f"BIP44 Name: {BIP44Derivation.name()}") # Initialize BIP44Derivation with default values bip44_derivation: BIP44Derivation = BIP44Derivation() print(f"Default path: {bip44_derivation.path()}") # Modify derivation parameters bip44_derivation.from_coin_type(coin_type=11) bip44_derivation.from_account(account=1) bip44_derivation.from_change(change="external-chain") bip44_derivation.from_address(address=10) # Get the updated path print(f"Updated path: {bip44_derivation.path()}") # Get the derivation indexes print(f"Indexes: {bip44_derivation.indexes()}") # Initialize BIP44Derivation with specific values bip44_derivation_specific: BIP44Derivation = BIP44Derivation(coin_type=11, account=1, change=CHANGES.EXTERNAL_CHAIN, address=10) # Access individual components print(f"Purpose: {bip44_derivation_specific.purpose()}") print(f"Coin Type: {bip44_derivation_specific.coin_type()}") print(f"Account: {bip44_derivation_specific.account()}") print(f"Change: {bip44_derivation_specific.change()}") print(f"Address: {bip44_derivation_specific.address()}") ``` -------------------------------- ### P2WSH Address Encoding/Decoding Example Source: https://hdwallet.readthedocs.io/en/v3.5.1/addresses Provides a Python example for using the P2WSHAddress class to obtain the address name, encode a public key into a P2WSH address, and decode it. ```python from hdwallet.addresses.p2wsh import P2WSHAddress # Get the name of the address type print(P2WSHAddress.name()) # Encode a public key to a P2WSH address address: str = P2WSHAddress.encode(public_key="0374a436044b4904bbd7a074b098d65fad39fc5b66f28da8440f10dbcf86568429") print(address) # Decode a P2WSH address print(P2WSHAddress.decode(address=address)) ``` -------------------------------- ### BIP86HD Class Methods Source: https://hdwallet.readthedocs.io/en/v3.5.1/hds Documentation for the BIP86HD class, covering methods for initializing from derivation paths and generating root extended private keys according to BIP44. ```APIDOC class hdwallet.hds.bip86.BIP86HD: name() -> str Get the name of the bip class. Returns: The name of the bip class. 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. 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): 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. ``` -------------------------------- ### HD Wallet Initialization Source: https://hdwallet.readthedocs.io/en/v3.5.1/hds Methods for initializing HD wallet instances from different key formats and derivation paths. These methods are crucial for setting up wallet objects with various cryptographic key types. ```APIDOC HDWallet Initialization Methods: 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: IHD: The initialized HD instance. 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: IHD: The initialized HD instance. 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: IHD: The initialized HD instance. 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: IHD: The initialized HD instance. from_spend_private_key(spend_private_key: str) -> IHD Initializes the HD instance from a spend private key. Parameters: spend_private_key (str): Spend private key to initialize from. Returns: IHD: Updated HD instance initialized from the spend private key. 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: IHD: The initialized HD instance. from_watch_only(view_private_key, spend_public_key) -> IHD Initializes 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: MoneroHD: Updated HD instance initialized from the watch-only keys. 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: MoneroHD: The initialized MoneroHD instance. ``` -------------------------------- ### ElectrumV1Mnemonic Usage Examples Source: https://hdwallet.readthedocs.io/en/v3.5.1/mnemonics Demonstrates the usage of the ElectrumV1Mnemonic class for creating, encoding, decoding, and validating mnemonic phrases using Python. Includes examples for generating mnemonics from words and entropy. ```python from hdwallet.mnemonics.electrum.v1 import ElectrumV1Mnemonic, ELECTRUM_V1_MNEMONIC_WORDS, ELECTRUM_V1_MNEMONIC_LANGUAGES # Get mnemonic name print(ElectrumV1Mnemonic.name()) # Generate mnemonic from words mnemonic_from_words: str = ElectrumV1Mnemonic.from_words(words=BIP39_MNEMONIC_WORDS.TWELVE, language=ELECTRUM_V1_MNEMONIC_LANGUAGES.ENGLISH) # Generate mnemonic from entropy mnemonic_from_entropy: str = ElectrumV1Mnemonic.from_entropy(entropy="724bf9ce32db1baa801761c4f11fe901", language=ELECTRUM_V1_MNEMONIC_LANGUAGES.ENGLISH) print(mnemonic_from_entropy) # Encode entropy to mnemonic encoded_mnemonic: str = ElectrumV1Mnemonic.encode(entropy="724bf9ce32db1baa801761c4f11fe901", language=ELECTRUM_V1_MNEMONIC_LANGUAGES.ENGLISH) print(encoded_mnemonic) # Instantiate mnemonic object mnemonic_str: str = 'vast floor creation tonight company express around surface mean ode mother red' ev1_mnemonic: ElectrumV1Mnemonic = ElectrumV1Mnemonic(mnemonic=mnemonic_str) # Access mnemonic properties print(ev1_mnemonic.mnemonic()) print(ev1_mnemonic.language()) print(ev1_mnemonic.words()) # Decode mnemonic to entropy decoded_entropy: str = ElectrumV1Mnemonic.decode(mnemonic=mnemonic_str) print(decoded_entropy) # Validate language and word count print(ElectrumV1Mnemonic.is_valid_language(language="english")) print(ElectrumV1Mnemonic.is_valid_words(words=12)) # Validate a mnemonic phrase print(ElectrumV1Mnemonic.is_valid(mnemonic="spring hopefully foot effort complete awake stand sheep deserve any soft perfect")) ``` -------------------------------- ### HDWallet CLI Usage Source: https://hdwallet.readthedocs.io/en/v3.5.1/cli Defines the basic structure for using the hdwallet command-line interface, including general options and commands. It allows users to generate wallets, derive addresses, and manage keys. ```CLI hdwallet [OPTIONS] COMMAND [ARGS]... Options: -v, --version Show HDWallet version and exit ```