nim_addr

Module for Nimiq address encoding/decoding.

class NimAddrConst

Bases: object

Class container for Nimiq address constants.

ADDR_GROUP_LEN: int = 4
CHECKSUM_ENC_LEN: int = 2
BASE32_ALPHABET: str = '0123456789ABCDEFGHJKLMNPQRSTUVXY'
HASH_BYTE_LEN: int = 20
HASH_ENC_LEN: int = 32
class NimAddrDecoder

Bases: IAddrDecoder

Nimiq address decoder class. It allows the Nimiq address decoding.

static DecodeAddr(addr: str, **kwargs: Any) bytes

Decode an Nimiq address to bytes.

Parameters:
  • addr (str) – Address string

  • **kwargs – Not used

Returns:

Public key hash bytes

Return type:

bytes

Raises:

ValueError – If the address encoding is not valid

class NimAddrEncoder

Bases: IAddrEncoder

Nimiq address encoder class. It allows the Nimiq address encoding.

static EncodeKey(pub_key: Union[bytes, IPublicKey], **kwargs: Any) str

Encode a public key to Nimiq address.

Parameters:
  • pub_key (bytes or IPublicKey) – Public key bytes or object

  • **kwargs – Not used

Returns:

Address string

Return type:

str

Raises:
  • ValueError – If the public key is not valid

  • TypeError – If the public key is not ed25519

NimAddr

alias of NimAddrEncoder