f281d151bb
This commit brings a host of improvements to the bech32 package. The public interface of the package remains unchanged. Summary of changes: * Improved error handling using dedicated error types. Programmatically detect if the errors produced are the expected ones. * Improve test coverage to test more corner cases. Added test vectors from Bitcoin Core. * Add a benchmark for a full encode/decode cycle of a bech32 string. * Add a new function DecodeNoLimit, for decoding large bech32 encoded strings. It does NOT validate against the BIP-173 maximum length allowed for bech32 strings. * Automatically convert the HRP to lowercase in Encode function. * Improve performance of encode/decode functions by using strings.Builder. * Improve memory allocation in ConvertBits function. * Updated documentation. Credits: @matheusd Closes #152 and #168. |
||
---|---|---|
.. | ||
bech32.go | ||
bech32_test.go | ||
doc.go | ||
error.go | ||
example_test.go | ||
README.md |
bech32
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
- Bech32 decode Example Demonstrates how to decode a bech32 encoded string.
- Bech32 encode Example Demonstrates how to encode data into a bech32 string.
License
Package bech32 is licensed under the copyfree ISC License.