P2PKH_addr
Module for P2PKH address encoding/decoding.
- class P2PKHPubKeyModes(value)
Bases:
Enum
Enumerative for P2PKH public key modes.
- COMPRESSED = 1
- UNCOMPRESSED = 2
- class P2PKHAddrDecoder
Bases:
IAddrDecoder
P2PKH address decoder class. It allows the Pay-to-Public-Key-Hash address decoding.
- static DecodeAddr(addr: str, **kwargs: Any) bytes
Decode a P2PKH address to bytes.
- Parameters:
addr (str) – Address string
net_ver (bytes) – Expected net address version
base58_alph (Base58Alphabets, optional) – Base58 alphabet (default: Bitcoin alphabet)
- Returns:
Public key hash bytes
- Return type:
bytes
- Raises:
ValueError – If the address encoding is not valid
- class P2PKHAddrEncoder
Bases:
IAddrEncoder
P2PKH address encoder class. It allows the Pay-to-Public-Key-Hash address encoding.
- static EncodeKey(pub_key: Union[bytes, IPublicKey], **kwargs: Any) str
Encode a public key to P2PKH address.
- Parameters:
pub_key (bytes or IPublicKey) – Public key bytes or object
net_ver (bytes) – Net address version
base58_alph (Base58Alphabets, optional) – Base58 alphabet, Bitcoin alphabet by default
pub_key_mode (P2PKHPubKeyModes, optional) – Public key mode, compressed key by default
- Returns:
Address string
- Return type:
str
- Raises:
ValueError – If the public key is not valid
TypeError – If the public key is not secp256k1
- class BchP2PKHAddrDecoder
Bases:
IAddrDecoder
Bitcoin Cash P2PKH address decoder class. It allows the Bitcoin Cash P2PKH decoding.
- static DecodeAddr(addr: str, **kwargs: Any) bytes
Decode a Bitcoin Cash P2PKH address to bytes.
- Parameters:
addr (str) – Address string
hrp (str) – Expected HRP
net_ver (bytes) – Expected net address version
- Returns:
Public key hash bytes
- Return type:
bytes
- Raises:
ValueError – If the address encoding is not valid
- class BchP2PKHAddrEncoder
Bases:
IAddrEncoder
Bitcoin Cash P2PKH address encoder class. It allows the Bitcoin Cash P2PKH encoding.
- static EncodeKey(pub_key: Union[bytes, IPublicKey], **kwargs: Any) str
Encode a public key to Bitcoin Cash P2PKH address.
- Parameters:
pub_key (bytes or IPublicKey) – Public key bytes or object
hrp (str) – HRP
net_ver (bytes) – Net address version
- Returns:
Address string
- Return type:
str
- Raises:
ValueError – If the public key is not valid
TypeError – If the public key is not secp256k1
- P2PKHAddr
alias of
P2PKHAddrEncoder
- BchP2PKHAddr
alias of
BchP2PKHAddrEncoder