electrum_v1

Module containing utility classes for Electrum v1 keys derivation, since it uses its own algorithm.

class ElectrumV1(priv_key: Optional[IPrivateKey], pub_key: Optional[IPublicKey])

Bases: object

Electrum v1 class. It derives keys like the Electrum wallet with old (v1) mnemonic.

classmethod FromSeed(seed_bytes: bytes) ElectrumV1

Construct class from seed bytes.

Parameters:

seed_bytes (bytes) – Seed bytes

Returns:

ElectrumV1 object

Return type:

ElectrumV1 object

classmethod FromPrivateKey(priv_key: Union[bytes, IPrivateKey]) ElectrumV1

Construct class from private key.

Parameters:

priv_key (bytes or IPrivateKey) – Private key

Returns:

ElectrumV1 object

Return type:

ElectrumV1 object

Raises:

TypeError – if the private key is not a Secp256k1PrivateKey

classmethod FromPublicKey(pub_key: Union[bytes, IPublicKey]) ElectrumV1

Construct class from public key.

Parameters:

pub_key (bytes or IPublicKey) – Public key

Returns:

ElectrumV1 object

Return type:

ElectrumV1 object

Raises:

TypeError – if the public key is not a Secp256k1PublicKey

m_priv_key: Optional[IPrivateKey]
m_pub_key: IPublicKey
IsPublicOnly() bool

Get if it’s public-only.

Returns:

True if public-only, false otherwise

Return type:

bool

MasterPrivateKey() IPrivateKey

Get the master private key.

Returns:

IPrivateKey object

Return type:

IPrivateKey object

MasterPublicKey() IPublicKey

Get the master public key.

Returns:

IPublicKey object

Return type:

IPublicKey object

GetPrivateKey(change_idx: int, addr_idx: int) IPrivateKey

Get the private key with the specified change and address indexes. Derivation path (not BIP32 derivation): m/change_idx/addr_idx

Parameters:
  • change_idx (int) – Change index

  • addr_idx (int) – Address index

Returns:

IPrivateKey object

Return type:

IPrivateKey object

Raises:

ValueError – If one of the index is not valid

GetPublicKey(change_idx: int, addr_idx: int) IPublicKey

Get the public key with the specified change and address indexes. Derivation path (not BIP32 derivation): m/change_idx/addr_idx

Parameters:
  • change_idx (int) – Change index

  • addr_idx (int) – Address index

Returns:

IPublicKey object

Return type:

IPublicKey object

Raises:

ValueError – If one of the index is not valid

GetAddress(change_idx: int, addr_idx: int) str

Get the address with the specified change and address indexes. Derivation path (not BIP32 derivation): m/change_idx/addr_idx

Parameters:
  • change_idx (int) – Change index

  • addr_idx (int) – Address index

Returns:

Address

Return type:

str

Raises:

ValueError – If one of the index is not valid