View Source BitcoinLib.Address.P2SH (BitcoinLib v0.4.3)

Implementation of P2SH-P2WPKH addresses

BIP13: Address Format for pay-to-script-hash https://github.com/bitcoin/bips/blob/master/bip-0013.mediawiki BIP16: Pay to Script Hash https://github.com/bitcoin/bips/blob/master/bip-0016.mediawiki

Source: https://github.com/bitcoin/bips/blob/master/bip-0013.mediawiki

Link to this section Summary

Functions

Creates a P2SH-P2WPKH address, which is starting by 3, out of an Extended Public Key

Creates a P2SH-P2WPKH address, which is starting by 3, 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()

Creates a P2SH-P2WPKH address, which is starting by 3, out of an Extended Public Key

examples

Examples

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

from_script_hash(script_hash, network \\ :mainnet)

View Source
@spec from_script_hash(bitstring(), :mainnet | :testnet) :: binary()

Creates a P2SH-P2WPKH address, which is starting by 3, out of a script hash

examples

Examples

iex> <<0x11c371a2b2d22c7b8b1b51d9fde0e44a9dfdc7bb::160>>
...> |> BitcoinLib.Address.P2SH.from_script_hash(:testnet)
"2Mts9cDyaoGfxPseMzxab2bAKHLW4o4SzAK"
@spec valid?(binary()) :: boolean()

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

examples

Examples

iex> "2N4GxhpXrgdWJf5CaEoGWkoWCsW8NhygsKg"
...> |> BitcoinLib.Address.P2SH.valid?()
true