Documentation ¶
Overview ¶
Package bech32 provides a Go implementation of the bech32 format specified in BIP 173.
Bech32 strings consist of a human-readable part (hrp), followed by the separator 1, then a checksummed data part encoded using the 32 characters "qpzry9x8gf2tvdw0s3jn54khce6mua7l".
More info: https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Bech32Decode ¶
Decode decodes a bech32 encoded string, returning the human-readable part and the data part excluding the checksum.
Example ¶
This example demonstrates how to decode a bech32 encoded string.
encoded := "bc1pw508d6qejxtdg4y5r3zarvary0c5xw7kw508d6qejxtdg4y5r3zarvary0c5xw7k7grplx" hrp, decoded, err := Bech32Decode(encoded) if err != nil { fmt.Println("Error:", err) } // Show the decoded data. fmt.Println("Decoded human-readable part:", hrp) fmt.Println("Decoded Data:", hex.EncodeToString(decoded))
Output: Decoded human-readable part: bc Decoded Data: 010e140f070d1a001912060b0d081504140311021d030c1d03040f1814060e1e160e140f070d1a001912060b0d081504140311021d030c1d03040f1814060e1e16
func Bech32Encode ¶
Encode encodes a byte slice into a bech32 string with the human-readable part hrb. Note that the bytes must each encode 5 bits (base32).
Types ¶
This section is empty.