bech32

Bech32 and Bech32m string encoding used by newer Bitcoin address types.

Types

NameDescription
DecodeResult Result of decoding a Bech32(m) string: its encoding, human-readable part, and payload.

Enums

NameDescription
CharLimit Character limits for Bech32(m) encoded strings. Character limits are how we provide error location guarantees. These values should never exceed 2^31 - 1 (max value for a 32-bit int), since there are places where we may need to convert the CharLimit::VALUE to an int. In practice, this should never happen since this CharLimit applies to an address encoding and we would never encode an address with such a massive value
Encoding Which Bech32 variant a string uses, or that decoding failed.

Functions

NameDescription
Decode Decode a Bech32 or Bech32m string.
Encode Encode a Bech32 or Bech32m string. If hrp contains uppercase characters, this will cause an assertion error. Encoding must be one of BECH32 or BECH32M.
LocateErrors Return the positions of errors in a Bech32 string.

Variables

NameDescription
CHECKSUM_SIZE Number of trailing checksum characters in a Bech32(m) string.
SEPARATOR Character separating the human-readable part from the data section.