Addresses

Collection of base classes that implement the work with Bitcoin addresses and address keys. Supports addresses types PUBKEY, P2PKH, P2SH, P2SH-PWPKH, P2WPKH, P2WSH.

class PrivateKey(k, A)

The class for creating private key object.

Parameters
k

(optional) private key in HEX, bytes string or WIF format. In case no key specified new random private key will be created

Arguments
  • compressed – (optional) if set to true private key corresponding compressed public key, by default is true. Recommended use only compressed public key.

  • testnet – (optional) flag for testnet network, by default is false.

PrivateKey.compressed

flag for compressed type of corresponding public key (boolean)

PrivateKey.hex

private key in HEX (string)

PrivateKey.testnet

flag for testnet network (boolean)

PrivateKey.wif

private key in WIF format (string)

class PublicKey(k, A)

The class for creating public key object.

Parameters
k

one of this types allowed:

– private key is instance of PrivateKey class

– private key HEX encoded string

– private key 32 bytes string

– private key in WIF format

– public key in HEX encoded string

– public key [33/65] bytes string

In case no key specified with HEX or bytes string you have to provide flag for testnet and compressed key. WIF format and PrivateKey instance already contain this flags. For HEX or bytes public key only testnet flag has the meaning, comressed flag is determined according to the length of key.

Arguments
  • compressed – (optional) if set to true private key corresponding compressed public key, by default is true. Recommended use only compressed public key.

  • testnet – (optional) flag for testnet network, by default is false.

PublicKey.compressed

flag for compressed type of corresponding public key (boolean)

PublicKey.hex

public key in HEX (string)

PublicKey.testnet

flag for testnet network (boolean)

class Address(k, A)

The class for Address object.

Parameters
k

(optional) one of this types allowed:

– private key WIF format

– instance of PrivateKey

– private key HEX encoded string

– instance of PublicKey

Arguments
  • addressType – (optional) P2PKH, PUBKEY, P2WPKH, P2SH_P2WPKH.

  • testnet – (optional) flag for testnet network, by default is false.

  • compressed – (optional) if set to true private key corresponding compressed public key, by default is true. Recommended use only compressed public key.

In case instance is created from WIF private key, PrivateKey or PublicKey compressed and testnet flags already contain in initial key parameter and will be ignored.

Address.address

address in base58 or bech32 encoding (string)

Address.hash

address hash

Address.hashHex

address hash HEX (string)

Address.privateKey

instance of PrivateKey class

Address.publicKey

instance of PublicKey class

Address.redeemScript

redeeem script, only for P2SH_P2WPKH (bytes)

Address.redeemScriptHex

redeeem script HEX, only for P2SH_P2WPKH (string)

Address.scriptHash

flag for script hash address (boolean)

Address.testnet

flag for testnet network address (boolean)

Address.type

address type (string)