P2WPKH_addr
Module for P2WPKH address encoding/decoding.
References
https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki
- class P2WPKHAddrDecoder
Bases:
IAddrDecoder
P2WPKH address decoder class. It allows the Pay-to-Witness-Public-Key-Hash address decoding.
- static DecodeAddr(addr: str, **kwargs: Any) bytes
Decode a P2WPKH address to bytes.
- Parameters:
addr (str) – Address string
hrp (str) – Expected HRP
- Returns:
Public key hash bytes
- Return type:
bytes
- Raises:
ValueError – If the address encoding is not valid
- class P2WPKHAddrEncoder
Bases:
IAddrEncoder
P2WPKH address encoder class. It allows the Pay-to-Witness-Public-Key-Hash address encoding.
- static EncodeKey(pub_key: Union[bytes, IPublicKey], **kwargs: Any) str
Encode a public key to P2WPKH address.
- Parameters:
pub_key (bytes or IPublicKey) – Public key bytes or object
hrp (str) – HRP
- Returns:
Address string
- Return type:
str
- Raises:
ValueError – If the public key is not valid
TypeError – If the public key is not secp256k1
- P2WPKHAddr
alias of
P2WPKHAddrEncoder