View Source BitcoinLib (BitcoinLib v0.2.0-pre3)

High level bitcoin operations

Link to this section Summary

Functions

Derives a public key from a raw private key

Creates a P2PKH address from a public key

Creates a bitcoin private key both in raw and WIF format

Link to this section Functions

Link to this function

derive_public_key(private_key)

View Source
@spec derive_public_key(%BitcoinLib.Key.PrivateKey{
  chain_code: term(),
  depth: term(),
  fingerprint: term(),
  index: term(),
  key: term(),
  parent_fingerprint: term()
}) :: %BitcoinLib.Key.PublicKey{
  chain_code: term(),
  depth: term(),
  fingerprint: term(),
  index: term(),
  key: term(),
  parent_fingerprint: term(),
  uncompressed_key: term()
}

Derives a public key from a raw private key

examples

Examples

iex> %BitcoinLib.Key.PrivateKey{key: <<0x0a8d286b11b98f6cb2585b627ff44d12059560acd430dcfa1260ef2bd9569373::256>>} ...> |> BitcoinLib.derive_public_key() %BitcoinLib.Key.PublicKey{

chain_code: nil,
depth: 0,
fingerprint: <<0x6ae20179::32>>,
index: 0,
key: <<0x020f69ef8f2feb09b29393eef514761f22636b90d8e4d3f2138b2373bd37523053::264>>,
parent_fingerprint: <<0::32>>,
uncompressed_key: <<0x040f69ef8f2feb09b29393eef514761f22636b90d8e4d3f2138b2373bd37523053002119e16b613619691f760eadd486315fc9e36491c7adb76998d1b903b3dd12::520>>

}

Link to this function

generate_p2pkh_address(public_key)

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

Creates a P2PKH address from a public key

examples

Examples

iex> %BitcoinLib.Key.PublicKey{key: <<0x020f69ef8f2feb09b29393eef514761f22636b90d8e4d3f2138b2373bd37523053::264>>} ...> |> BitcoinLib.generate_p2pkh_address() "1Ak9NVPmwCHEpsSWvM6cNRC7dsYniRmwMG"

@spec generate_private_key() :: %{raw: <<_::256>>, wif: binary()}

Creates a bitcoin private key both in raw and WIF format

examples

Examples

iex> %{raw: , wif: } = BitcoinLib.generate_private_key()