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

Pay to Public Key contract.

P2PK scripts are used to lock Bitcoin to a public key. The Bitcoin can later be unlocked using the corresponding private key.

Lock parameters

Unlock parameters

Examples

iex> contract = P2PK.lock(1000, %{pubkey: @keypair.pubkey})
iex> Contract.to_script(contract)
%Script{chunks: [
  <<3, 248, 31, 140, 139, 144, 245, 236, 6, 238, 66, 69, 234, 177, 102, 232, 175, 144, 63, 199, 58, 109, 215, 54, 54, 104, 126, 240, 39, 135, 10, 190, 57>>,
  :OP_CHECKSIG
]}

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

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.