BSV.Tx (BSV v2.1.0) View Source
A Tx is a data structure representing a Bitcoin transaction.
A Tx consists of a version number, a list of inputs, list of outputs, and a locktime value.
A Bitcoin transaction is used to transfer custody of Bitcoins. It can also be used for smart contracts, recording and timestamping data, and many other functionalities.
The Tx module is used for parsing and serialising transaction data. Use the
BSV.TxBuilder
module for building transactions.
Link to this section Summary
Functions
Adds the given BSV.TxIn.t/0
to the transaction.
Adds the given BSV.TxOut.t/0
to the transaction.
Parses the given binary into a BSV.Tx.t/0
.
Parses the given binary into a BSV.Tx.t/0
.
Returns the BSV.Tx.hash/0
of the given transaction.
Returns the number of bytes of the given BSV.Tx.t/0
.
Returns the BSV.Tx.txid/0
of the given transaction.
Returns true if the given BSV.Tx.t/0
is a coinbase transaction (the first
transaction in a block, containing the miner block reward).
Serialises the given BSV.TxIn.t/0
into a binary.
Link to this section Types
Specs
hash() :: <<_::256>>
Tx hash
Result of hashing the transaction data through the SHA-256 algorithm twice.
Specs
t() :: %BSV.Tx{ inputs: [BSV.TxIn.t()], lock_time: non_neg_integer(), outputs: [BSV.TxOut.t()], version: non_neg_integer() }
Tx struct
Specs
txid() :: String.t()
TXID
Result of reversing and hex-encoding the BSV.Tx.hash/0
.
Link to this section Functions
Specs
add_input(t(), BSV.TxIn.t()) :: t()
Adds the given BSV.TxIn.t/0
to the transaction.
Specs
add_output(t(), BSV.TxOut.t()) :: t()
Adds the given BSV.TxOut.t/0
to the transaction.
Specs
Parses the given binary into a BSV.Tx.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.
Specs
Parses the given binary into a BSV.Tx.t/0
.
As from_binary/2
but returns the result or raises an exception.
Specs
Returns the BSV.Tx.hash/0
of the given transaction.
Specs
get_size(t()) :: non_neg_integer()
Returns the number of bytes of the given BSV.Tx.t/0
.
Specs
Returns the BSV.Tx.txid/0
of the given transaction.
Specs
Returns true if the given BSV.Tx.t/0
is a coinbase transaction (the first
transaction in a block, containing the miner block reward).
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.