bech32m

package module
v0.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 15, 2024 License: MIT Imports: 5 Imported by: 1

README

GoDoc

bech32m

Implementation of bech32m format for segwit addrs.

BIP: https://github.com/bitcoin/bips/blob/master/bip-0350.mediawiki

A lot of this code comes from Takatoshi Nakagawa's implementation but with optimizations on various obvious areas, including avoiding allocating memory for polymod calculation and such.

Documentation

Index

Constants

View Source
const (
	Bech32   = 1
	Bech32m  = 2
	CashAddr = 3
	Failed   = -1
)

Variables

View Source
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")
)

Functions

func CashAddrDecode added in v0.1.3

func CashAddrDecode(hrp, addr string) (byte, []byte, error)

func CashAddrEncode added in v0.1.4

func CashAddrEncode(hrp string, vers byte, buf []byte) (string, error)

func Decode

func Decode(bechString string) (string, []byte, int, error)

Decode validate a Bech32/Bech32m string, and determine HRP and data.

func Encode

func Encode(hrp string, data []byte, spec int) string

Encode compute a Bech32 string given HRP and data values.

func SegwitAddrDecode

func SegwitAddrDecode(hrp, addr string) (byte, []byte, error)

SegwitAddrDecode decode a segwit address.

func SegwitAddrEncode

func SegwitAddrEncode(hrp string, witver byte, witprog []byte) (string, error)

SegwitAddrEncode encode a segwit address.

func SegwitAddrEncodeNoCheck added in v0.1.2

func SegwitAddrEncodeNoCheck(hrp string, witver byte, witprog []byte) (string, error)

SegwitAddrEncodeNoCheck is the same as SegwitAddrEncode but it will not check if the generated address is valid

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL