electrum_v2
Module containing utility classes for Electrum v2 keys derivation, since it uses its own paths.
- class ElectrumV2Base(bip32_obj: Bip32Base)
Bases:
ABC
Electrum v2 base class.
- classmethod FromSeed(seed_bytes: bytes) ElectrumV2Base
Construct class from seed bytes.
- Parameters:
seed_bytes (bytes) – Seed bytes
- Returns:
ElectrumV2Base object
- Return type:
ElectrumV2Base object
- Bip32Object() Bip32Base
Return the BIP32 object.
- Returns:
Bip32Base object
- Return type:
Bip32Base object
- IsPublicOnly() bool
Get if it’s public-only.
- Returns:
True if public-only, false otherwise
- Return type:
bool
- MasterPrivateKey() Bip32PrivateKey
Get the master private key.
- Returns:
Bip32PrivateKey object
- Return type:
Bip32PrivateKey object
- MasterPublicKey() Bip32PublicKey
Get the master public key.
- Returns:
Bip32PublicKey object
- Return type:
Bip32PublicKey object
- abstract GetPrivateKey(change_idx: Union[int, Bip32KeyIndex], addr_idx: Union[int, Bip32KeyIndex]) Bip32PrivateKey
Get the private key with the specified change and address indexes.
- Parameters:
change_idx (int or Bip32KeyIndex object) – Change index
addr_idx (int or Bip32KeyIndex object) – Address index
- Returns:
Bip32PrivateKey object
- Return type:
Bip32PrivateKey object
- Raises:
Bip32KeyError – If the derivation results in an invalid key or the object is public-only
Bip32PathError – If the path indexes are not valid
- abstract GetPublicKey(change_idx: Union[int, Bip32KeyIndex], addr_idx: Union[int, Bip32KeyIndex]) Bip32PublicKey
Get the public key with the specified change and address indexes.
- Parameters:
change_idx (int or Bip32KeyIndex object) – Change index
addr_idx (int or Bip32KeyIndex object) – Address index
- Returns:
Bip32PublicKey object
- Return type:
Bip32PublicKey object
- Raises:
Bip32KeyError – If the derivation results in an invalid key
Bip32PathError – If the path indexes are not valid
- abstract GetAddress(change_idx: Union[int, Bip32KeyIndex], addr_idx: Union[int, Bip32KeyIndex]) str
Get the address with the specified change and address indexes.
- Parameters:
change_idx (int or Bip32KeyIndex object) – Change index
addr_idx (int or Bip32KeyIndex object) – Address index
- Returns:
Address
- Return type:
str
- Raises:
Bip32KeyError – If the derivation results in an invalid key
Bip32PathError – If the path indexes are not valid
- class ElectrumV2Standard(bip32_obj: Bip32Base)
Bases:
ElectrumV2Base
Electrum v2 standard class. It derives keys like the Electrum wallet with standard mnemonic.
- GetPrivateKey(change_idx: Union[int, Bip32KeyIndex], addr_idx: Union[int, Bip32KeyIndex]) Bip32PrivateKey
Get the private key with the specified change and address indexes. Derivation path: m/change_idx/addr_idx
- Parameters:
change_idx (int or Bip32KeyIndex object) – Change index
addr_idx (int or Bip32KeyIndex object) – Address index
- Returns:
Bip32PrivateKey object
- Return type:
Bip32PrivateKey object
- Raises:
Bip32KeyError – If the derivation results in an invalid key or the object is public-only
Bip32PathError – If the path indexes are not valid
- GetPublicKey(change_idx: Union[int, Bip32KeyIndex], addr_idx: Union[int, Bip32KeyIndex]) Bip32PublicKey
Get the public key with the specified change and address indexes. Derivation path: m/change_idx/addr_idx
- Parameters:
change_idx (int or Bip32KeyIndex object) – Change index
addr_idx (int or Bip32KeyIndex object) – Address index
- Returns:
Bip32PublicKey object
- Return type:
Bip32PublicKey object
- Raises:
Bip32KeyError – If the derivation results in an invalid key
Bip32PathError – If the path indexes are not valid
- GetAddress(change_idx: Union[int, Bip32KeyIndex], addr_idx: Union[int, Bip32KeyIndex]) str
Get the address with the specified change and address indexes. Derivation path: m/change_idx/addr_idx
- Parameters:
change_idx (int or Bip32KeyIndex object) – Change index
addr_idx (int or Bip32KeyIndex object) – Address index
- Returns:
Address
- Return type:
str
- Raises:
Bip32KeyError – If the derivation results in an invalid key
Bip32PathError – If the path indexes are not valid
- class ElectrumV2Segwit(bip32: Bip32Base)
Bases:
ElectrumV2Base
Electrum v2 segwit class. It derives keys like the Electrum wallet with segwit mnemonic.
- GetPrivateKey(change_idx: Union[int, Bip32KeyIndex], addr_idx: Union[int, Bip32KeyIndex]) Bip32PrivateKey
Get the private key with the specified change and address indexes. Derivation path: m/0’/change_idx/addr_idx
- Parameters:
change_idx (int or Bip32KeyIndex object) – Change index
addr_idx (int or Bip32KeyIndex object) – Address index
- Returns:
Bip32PrivateKey object
- Return type:
Bip32PrivateKey object
- Raises:
Bip32KeyError – If the derivation results in an invalid key or the object is public-only
Bip32PathError – If the path indexes are not valid
- GetPublicKey(change_idx: Union[int, Bip32KeyIndex], addr_idx: Union[int, Bip32KeyIndex]) Bip32PublicKey
Get the public key with the specified change and address indexes. Derivation path: m/0’/change_idx/addr_idx
- Parameters:
change_idx (int or Bip32KeyIndex object) – Change index
addr_idx (int or Bip32KeyIndex object) – Address index
- Returns:
Bip32PublicKey object
- Return type:
Bip32PublicKey object
- Raises:
Bip32KeyError – If the derivation results in an invalid key
Bip32PathError – If the path indexes are not valid
- GetAddress(change_idx: Union[int, Bip32KeyIndex], addr_idx: Union[int, Bip32KeyIndex]) str
Get the address with the specified change and address indexes. Derivation path: m/0’/change_idx/addr_idx
- Parameters:
change_idx (int or Bip32KeyIndex object) – Change index
addr_idx (int or Bip32KeyIndex object) – Address index
- Returns:
Address
- Return type:
str
- Raises:
Bip32KeyError – If the derivation results in an invalid key
Bip32PathError – If the path indexes are not valid