BSV.TxIn (BSV v2.1.0) View Source

A TxIn is a data structure representing a single input in a BSV.Tx.t/0.

A TxIn consists of the BSV.OutPoint.t/0 of the output which is being spent, a Script known as the unlocking script, and a sequence number.

A TxIn spends a previous output by concatenating the unlocking script with the locking script in the order:

unlocking_script <> locking_script

The entire script is evaluated and if it returns a truthy value, the output is unlocked and spent.

When the sequence value is less that 0xFFFFFFFF and that transaction locktime is set in the future, that transaction is considered non-final and will not be mined in a block. This mechanism can be used to build payment channels.

Link to this section Summary

Types

t()

TxIn struct

Vin - Vector of an input in a Bitcoin transaction

Functions

Parses the given binary into a BSV.TxIn.t/0.

Parses the given binary into a BSV.TxIn.t/0.

Returns the number of bytes of the given BSV.TxIn.t/0.

Serialises the given BSV.TxIn.t/0 into a binary.

Link to this section Types

Specs

t() :: %BSV.TxIn{
  outpoint: BSV.OutPoint.t(),
  script: BSV.Script.t(),
  sequence: non_neg_integer()
}

TxIn struct

Specs

vin() :: non_neg_integer()

Vin - Vector of an input in a Bitcoin transaction

In integer representing the index of a TxIn.

Link to this section Functions

Link to this function

from_binary(data, opts \\ [])

View Source

Specs

from_binary(binary(), keyword()) :: {:ok, t()} | {:error, term()}

Parses the given binary into a BSV.TxIn.t/0.

Returns the result in an :ok / :error tuple pair.

Options

The accepted options are:

  • :encoding - Optionally decode the binary with either the :base64 or :hex encoding scheme.
Link to this function

from_binary!(data, opts \\ [])

View Source

Specs

from_binary!(binary(), keyword()) :: t()

Parses the given binary into a BSV.TxIn.t/0.

As from_binary/2 but returns the result or raises an exception.

Specs

get_size(t()) :: non_neg_integer()

Returns the number of bytes of the given BSV.TxIn.t/0.

Link to this function

to_binary(txin, opts \\ [])

View Source

Serialises the given BSV.TxIn.t/0 into a binary.

Options

The accepted options are:

  • :encoding - Optionally encode the binary with either the :base64 or :hex encoding scheme.