View Source BitcoinLib.Address.P2PKH (BitcoinLib v0.4.2)

Implementation of P2PKH addresses

Sources:

Link to this section Summary

Functions

Converts an extended public key into a P2PKH address starting by 1

Creates a P2PKH address, which is starting by 1, out of a script hash

Applies the address's checksum to make sure it's valid

Link to this section Functions

Link to this function

from_public_key(public_key, network \\ :mainnet)

View Source
@spec from_public_key(
  %BitcoinLib.Key.PublicKey{
    chain_code: term(),
    depth: term(),
    fingerprint: term(),
    index: term(),
    key: term(),
    parent_fingerprint: term(),
    uncompressed_key: term()
  },
  :mainnet | :testnet
) :: binary()

Converts an extended public key into a P2PKH address starting by 1

examples

Examples

iex> %BitcoinLib.Key.PublicKey{
...>  key: <<0x02D0DE0AAEAEFAD02B8BDC8A01A1B8B11C696BD3D66A2C5F10780D95B7DF42645C::264>>,
...>  chain_code: <<0::256>>
...> } |> BitcoinLib.Address.P2PKH.from_public_key()
"1LoVGDgRs9hTfTNJNuXKSpywcbdvwRXpmK"
Link to this function

from_public_key_hash(public_key_hash, network \\ :mainnet)

View Source
@spec from_public_key_hash(<<_::160>>, :mainnet | :testnet) :: binary()

Creates a P2PKH address, which is starting by 1, out of a script hash

examples

Examples

iex> <<0xba27f99e007c7f605a8305e318c1abde3cd220ac::160>>
...> |> BitcoinLib.Address.P2PKH.from_public_key_hash(:testnet)
"mxVFsFW5N4mu1HPkxPttorvocvzeZ7KZyk"
@spec valid?(binary()) :: boolean()

Applies the address's checksum to make sure it's valid

examples

Examples

iex> "mxVFsFW5N4mu1HPkxPttorvocvzeZ7KZyk"
...> |> BitcoinLib.Address.P2PKH.valid?()
true