View Source Bitcoinex.Bech32 (bitcoinex v0.1.8)

Includes Bech32 serialization and validation.

Reference: https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki#bech32

Link to this section Summary

Link to this section Types

@type data() :: [integer()]
@type encoding_type() :: :bech32 | :bech32m
@type error() :: atom()
@type hrp() :: String.t()
@type max_encoded_length() :: pos_integer() | :infinity
@type witness_program() :: [integer()]
@type witness_version() :: Range.t(0, 16)

Link to this section Functions

Link to this function

convert_bits(data, from_bits, to_bits, padding \\ true)

View Source
@spec convert_bits([integer()], integer(), integer(), boolean()) ::
  {:error, :invalid_data} | {:ok, [integer()]}
Link to this function

decode(bech32_str, max_encoded_length \\ 90)

View Source
@spec decode(String.t(), max_encoded_length()) ::
  {:ok, {encoding_type(), hrp(), data()}} | {:error, error()}
Link to this function

encode(hrp, data, encoding_type, max_encoded_length \\ 90)

View Source
@spec encode(hrp(), data() | String.t(), encoding_type(), max_encoded_length()) ::
  {:ok, String.t()} | {:error, error()}