Bitcoinex.Address (bitcoinex v0.1.6) View Source

Bitcoinex.Address supports Base58 and Bech32 address encoding and validation.

Link to this section Summary

Types

The address_type describes the address type to use.

Functions

Decodes an address and returns the address_type.

Accepts a public key hash, network, and address_type and returns its address.

Checks if the address is valid. Both encoding and network is checked.

Checks if the address is valid and matches the given address_type. Both encoding and network is checked.

Returns a list of supported address types.

Link to this section Types

Specs

address_type() :: :p2pkh | :p2sh | :p2wpkh | :p2wsh

The address_type describes the address type to use.

Four address types are supported:

  • p2pkh: Pay-to-Public-Key-Hash
  • p2sh: Pay-to-Script-Hash
  • p2wpkh: Pay-to-Witness-Public-Key-Hash
  • p2wsh: Pay-To-Witness-Script-Hash

Link to this section Functions

Link to this function

decode_type(address, network_name)

View Source

Specs

decode_type(String.t(), Bitcoinex.Network.network_name()) ::
  {:ok, address_type()} | {:error, :decode_error}

Decodes an address and returns the address_type.

Link to this function

encode(pubkey_hash, network_name, atom)

View Source

Specs

Accepts a public key hash, network, and address_type and returns its address.

Link to this function

is_valid?(address, network_name)

View Source

Specs

Checks if the address is valid. Both encoding and network is checked.

Link to this function

is_valid?(address, network_name, atom)

View Source

Specs

Checks if the address is valid and matches the given address_type. Both encoding and network is checked.

Link to this function

supported_address_types()

View Source

Returns a list of supported address types.