ExBech32 (ExBech32 v0.1.0)
Nif for Bech32 format encoding and decoding.
It uses https://github.com/rust-bitcoin/rust-bech32 rust library
Link to this section Summary
Link to this section Functions
Link to this function
decode(encoded)
Specs
Decodes bech32 decoded string
Examples
iex> ExBech32.decode("bech321qqqsyrhqy2a")
{:ok, {"bech32", <<0, 1, 2>>, :bech32}}
iex> ExBech32.decode("bech32m1qqqsyy9kzpq")
{:ok, {"bech32m", <<0, 1, 2>>, :bech32m}}
Link to this function
encode(hrp, data, variant \\ :bech32)
Specs
Encodes into Bech32 format
It accepts the following three paramters:
- human-readable part
- data to be encoded
- bech32 variant. it can be
:bech32
(BIP-0173) or:bech32m
(BIP-0350)
Examples
iex> ExBech32.encode("bech32", <<0, 1, 2>>)
{:ok, "bech321qqqsyrhqy2a"}
iex> ExBech32.encode("bech32m", <<0, 1, 2>>, :bech32m)
{:ok, "bech32m1qqqsyy9kzpq"}