BSV.UTXO (BSV v2.1.0) View Source
A UTXO is a data structure representing an unspent transaction output.
A UTXO consists of a BSV.OutPoint.t/0 and the BSV.TxOut.t/0 itself.
UTXOs are used in the BSV.TxBuilder module to create transaction inputs.
Link to this section Summary
Functions
Builds a BSV.UTXO.t/0 from the given map of params. Useful for building
UTXO's from JSON APIs.
Builds a BSV.UTXO.t/0 from the given map of params.
Builds a BSV.UTXO.t/0 from the given transaction and vout index. Useful
for building UTXO's when you already have the full transaction being spent
from.
Link to this section Types
Specs
t() :: %BSV.UTXO{outpoint: BSV.OutPoint.t(), txout: BSV.TxOut.t()}
UTXO struct
Link to this section Functions
Specs
Builds a BSV.UTXO.t/0 from the given map of params. Useful for building
UTXO's from JSON APIs.
Returns the result in an :ok / :error tuple pair.
Params
The required params are:
txid- Transaction IDvout- Vector of the output in a transaction. Also acceptsoutputIndexsatoshis- Number of satoshis. Also acceptsamountscript- Hex-encoded locking script
Examples
iex> UTXO.from_params(%{
...> "txid" => "5e3014372338f079f005eedc85359e4d96b8440e7dbeb8c35c4182e0c19a1a12",
...> "vout" => 0,
...> "satoshis" => 15399,
...> "script" => "76a91410bdcba3041b5e5517a58f2e405293c14a7c70c188ac"
...> })
{:ok, %UTXO{
outpoint: %OutPoint{
hash: <<18, 26, 154, 193, 224, 130, 65, 92, 195, 184, 190, 125, 14, 68, 184, 150, 77, 158, 53, 133, 220, 238, 5, 240, 121, 240, 56, 35, 55, 20, 48, 94>>,
vout: 0
},
txout: %TxOut{
satoshis: 15399,
script: %Script{chunks: [
:OP_DUP,
:OP_HASH160,
<<16, 189, 203, 163, 4, 27, 94, 85, 23, 165, 143, 46, 64, 82, 147, 193, 74, 124, 112, 193>>,
:OP_EQUALVERIFY,
:OP_CHECKSIG
]}
}
}}
Specs
Builds a BSV.UTXO.t/0 from the given map of params.
As from_params/1 but returns the result or raises an exception.
Specs
from_tx(BSV.Tx.t(), BSV.TxOut.vout()) :: BSV.TxOut.t() | nil
Builds a BSV.UTXO.t/0 from the given transaction and vout index. Useful
for building UTXO's when you already have the full transaction being spent
from.