# `BitcoinElixir.Script`
[🔗](https://github.com/cashlet-labs/bitcoin-elixir/blob/v0.1.0/lib/bitcoin_elixir/script.ex#L1)

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"

# `locking_script`

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

The locking script for a decoded address or address text.

# `locking_script!`

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

Like `locking_script/1` but raises.

# `scripthash`

```elixir
@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!`

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

Like `scripthash/1` but raises.

# `scripthash_of_script`

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

The Electrum scripthash of a raw locking script.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
