lbcutil/bech32
Olaoluwa Osuntokun 23db973afa
bech32: add new EncodeM and DecodeGeneric functions for bech32
In this commit, we add two new package level functions: `EncodeM`, and
`DecodeGeneric`. The new encode method is intended to allow callers to
specify that they want to use the new bech32m checksum. This should be
used when encoding segwit addresses with version 1 and beyond. The new
`DecodeGeneric` function allows a caller to decode a bech32 and bech32m
string with a single function. A new return value is added which is the
version of the returned bech32 string, which allows callers to perform
additional segwit addr validation (v1+ should use bech32m etc).

We opted to add new functions rather than modifying the existing
functions to not cause a breaking API change, as most uses in the wild
can just use the existing functions, and only taproot related logic/code
needs to worry about the new methods.

A series of tests have been added to ensure that `DecodeGeneric`
extracts the proper bech version, and we've also adopted the bech32m
tests from BIP 350.
2021-09-21 17:11:48 -07:00
..
bech32.go bech32: add new EncodeM and DecodeGeneric functions for bech32 2021-09-21 17:11:48 -07:00
bech32_test.go bech32: add new EncodeM and DecodeGeneric functions for bech32 2021-09-21 17:11:48 -07:00
doc.go bech32: Add bech32 encoding package. 2017-07-25 22:14:01 -05:00
error.go bech32: add additional field to ErrInvalidChecksum (bech32m version) 2021-09-21 17:11:43 -07:00
example_test.go bech32: Ensure HRP is lowercase when encoding. 2020-12-01 09:42:36 -05:00
README.md bech32: Add bech32 encoding package. 2017-07-25 22:14:01 -05:00
version.go bech32: add new set of constants/versions to be used for bech32m 2021-09-21 17:11:38 -07:00

bech32

Build Status ISC License GoDoc

Package bech32 provides a Go implementation of the bech32 format specified in BIP 173.

Test vectors from BIP 173 are added to ensure compatibility with the BIP.

Installation and Updating

$ go get -u github.com/btcsuite/btcutil/bech32

Examples

License

Package bech32 is licensed under the copyfree ISC License.