View Source Bitcoinex.Address (bitcoinex v0.1.8)

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

@type 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
@spec 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

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

Link to this function

is_valid?(address, network_name)

View Source
@spec is_valid?(String.t(), Bitcoinex.Network.network_name()) :: boolean()

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

Link to this function

is_valid?(address, network_name, atom)

View Source

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.