Documentation
¶
Overview ¶
Package bech32m implements the Bech32 and Bech32m encoding formats used for segregated witness (segwit) addresses as defined in BIP-0173 and BIP-0350, as well as the CashAddr format used by Bitcoin Cash.
Index ¶
- Constants
- Variables
- func CashAddrDecode(hrp, addr string) (byte, []byte, error)
- func CashAddrEncode(hrp string, vers byte, buf []byte) (string, error)
- func Decode(bechString string) (string, []byte, int, error)
- func Encode(hrp string, data []byte, spec int) string
- func SegwitAddrDecode(hrp, addr string) (byte, []byte, error)
- func SegwitAddrEncode(hrp string, witver byte, witprog []byte) (string, error)
- func SegwitAddrEncodeNoCheck(hrp string, witver byte, witprog []byte) (string, error)
Constants ¶
const ( Bech32 = 1 // Bech32 encoding (BIP-0173, used for segwit v0) Bech32m = 2 // Bech32m encoding (BIP-0350, used for segwit v1+) CashAddr = 3 // CashAddr encoding (Bitcoin Cash) Failed = -1 // Indicates checksum verification failure )
Encoding spec constants returned by Decode to indicate which encoding was used.
Variables ¶
var ( ErrMaxLengthExceeded = errors.New("bech32m: overall max length exceeded") ErrMixedCase = errors.New("bech32m: mixed case found in address") ErrInvalidChecksum = errors.New("bech32m: invalid checksum") ErrCorruptInput = errors.New("bech32m: corrupt base32 data") )
Sentinel errors returned during decoding.
Functions ¶
func CashAddrDecode ¶
CashAddrDecode decodes a CashAddr-encoded address, returning the version byte, payload data, and any error. The hrp parameter should include the trailing colon (e.g. "bitcoincash:").
func CashAddrEncode ¶
CashAddrEncode encodes a CashAddr address from the given hrp (including trailing colon), version byte, and hash payload. The payload length must be one of the standard CashAddr sizes (20, 24, 28, 32, 40, 48, 56, or 64 bytes).
func Decode ¶
Decode validates and decodes a Bech32, Bech32m, or CashAddr string, returning the human-readable part, data bytes, and encoding spec (Bech32, Bech32m, or CashAddr).
func Encode ¶
Encode computes a Bech32, Bech32m, or CashAddr encoded string given HRP, data values, and the encoding spec. The data slice is not modified.
func SegwitAddrDecode ¶
SegwitAddrDecode decode a segwit address.
func SegwitAddrEncode ¶
SegwitAddrEncode encode a segwit address.
func SegwitAddrEncodeNoCheck ¶
SegwitAddrEncodeNoCheck is the same as SegwitAddrEncode but skips the round-trip decode validation of the generated address.
Types ¶
This section is empty.