BSV.Contract.P2MS (BSV v2.1.0) View Source

Pay to Multi Signature contract.

P2PK scripts are used to lock Bitcoin to a multiple public keys. The Bitcoin can later be unlocked using the specified threshold of corresponding private keys.

Lock parameters

  • :pubkeys - List of BSV.PubKey.t/0 structs.
  • :threshold - Threshold of required signatures.

Unlock parameters

Examples

iex> contract = P2MS.lock(1000, %{pubkeys: @pubkeys, threshold: 2})
iex> Contract.to_script(contract)
%Script{chunks: [
  :OP_2,
  <<2, 148, 83, 173, 92, 5, 192, 13, 32, 255, 52, 204, 49, 136, 138, 176, 156, 149, 52, 201, 230, 182, 195, 34, 84, 148, 33, 110, 190, 94, 109, 106, 32>>,
  <<3, 232, 222, 19, 142, 204, 19, 161, 243, 84, 197, 85, 103, 159, 51, 211, 169, 138, 154, 133, 20, 69, 88, 63, 180, 94, 123, 42, 101, 231, 172, 96, 245>>,
  <<2, 180, 138, 62, 127, 140, 27, 86, 215, 147, 254, 50, 182, 67, 69, 93, 3, 111, 66, 45, 196, 228, 10, 63, 227, 25, 171, 151, 208, 44, 54, 157, 124>>,
  :OP_3,
  :OP_CHECKMULTISIG
]}

iex> contract = P2MS.unlock(%UTXO{}, %{privkeys: @privkeys})
iex> Contract.to_script(contract)
%Script{chunks: [
  :OP_0,
  <<0::568>>, # signatures are zero'd out until the transaction context is attached
  <<0::568>>
]}

Link to this section Summary

Functions

Returns a locking script contract with the given parameters.

Returns an unlocking script contract with the given parameters.

Link to this section Functions

Link to this function

lock(satoshis, params, opts \\ [])

View Source

Specs

Returns a locking script contract with the given parameters.

Link to this function

unlock(utxo, params, opts \\ [])

View Source

Specs

unlock(BSV.UTXO.t(), map(), keyword()) :: BSV.Contract.t()

Returns an unlocking script contract with the given parameters.