Skip to content

PrivateKeyGenerator (Class)

Generator for deriving private keys from an extended private key.

Used for creating wallets that can sign transactions.

__new__

__new__(xprv: str | XPrv, is_multisig: bool, account_index: int, cosigner_index: Optional[int] = None) -> PrivateKeyGenerator

Create a new private key generator.

PARAMETER DESCRIPTION
xprv

The master extended private key, as a string or XPrv instance.

TYPE: str | XPrv

is_multisig

Whether this is for a multisig wallet.

TYPE: bool

account_index

The account index to use.

TYPE: int

cosigner_index

Optional cosigner index for multisig.

TYPE: Optional[int] DEFAULT: None

RETURNS DESCRIPTION
PrivateKeyGenerator

A new generator instance.

TYPE: PrivateKeyGenerator

RAISES DESCRIPTION
Exception

If derivation fails.

change_key

change_key(index: int) -> PrivateKey

Get a change (internal) private key at the given index.

PARAMETER DESCRIPTION
index

The address index.

TYPE: int

RETURNS DESCRIPTION
PrivateKey

The private key at that index.

TYPE: PrivateKey

RAISES DESCRIPTION
Exception

If derivation fails.

receive_key

receive_key(index: int) -> PrivateKey

Get a receive (external) private key at the given index.

PARAMETER DESCRIPTION
index

The address index.

TYPE: int

RETURNS DESCRIPTION
PrivateKey

The private key at that index.

TYPE: PrivateKey

RAISES DESCRIPTION
Exception

If derivation fails.