BitcoinElixir.Script (bitcoin_elixir v0.1.0)

Copy Markdown View Source

Locking scripts for addresses, and the Electrum "scripthash" used to look an address up on an Electrum or Fulcrum server.

iex> script = BitcoinElixir.Script.locking_script!("bitcoincash:qq8hepxlmyfelgyfy985tw80r8pe805gfv230d2ufw")
iex> Base.encode16(script, case: :lower)
"76a9140f7c84dfd9139fa089214f45b8ef19c393be884b88ac"

Summary

Functions

The locking script for a decoded address or address text.

The Electrum scripthash of an address (text or decoded): SHA-256 of its locking script, byte-reversed, as lower-case hex. A plain and a token-aware address for the same key share one scripthash.

The Electrum scripthash of a raw locking script.

Functions

locking_script(text)

@spec locking_script(BitcoinElixir.CashAddr.t() | String.t()) ::
  {:ok, binary()} | {:error, atom()}

The locking script for a decoded address or address text.

locking_script!(addr)

@spec locking_script!(BitcoinElixir.CashAddr.t() | String.t()) :: binary()

Like locking_script/1 but raises.

scripthash(address)

@spec scripthash(BitcoinElixir.CashAddr.t() | String.t()) ::
  {:ok, String.t()} | {:error, atom()}

The Electrum scripthash of an address (text or decoded): SHA-256 of its locking script, byte-reversed, as lower-case hex. A plain and a token-aware address for the same key share one scripthash.

scripthash!(address)

@spec scripthash!(BitcoinElixir.CashAddr.t() | String.t()) :: String.t()

Like scripthash/1 but raises.

scripthash_of_script(script)

@spec scripthash_of_script(binary()) :: String.t()

The Electrum scripthash of a raw locking script.