Transaction Output (aka "txout") is a part of a bitcoin transaction that specifies destination of the bitcoins being transferred.
Every output has value
(in satoshis) and script
(that typically corresponds to an address).
This class is frequently used to specify unspent outputs (aka "unspents").
Unspent outputs typically have optional attributes transaction_hash
and index
to allow
creating a corresponding input.
Returns a new transaction output initialized with a binary string in wire format.
Raises ArgumentError
if transaction output is incomplete or incorrectly encoded.
Returns a new transaction output initialized with data in wire format read from a given stream.
Raises ArgumentError
if transaction output is incomplete or incorrectly encoded.
Returns a new transaction output with named attributes. All attributes are optional and have appropriate default values.
TransactionOutput.new(
value: 42 * BTC::COIN,
script: Address.parse("1CBtcGivXmHQ8ZqdPgeMfcpQNJrqTrSAcG").script,
...
)
Amount in satoshis to be locked in this output.
An instance of BTC::Script that specifies conditions that allow spending bitcoins.
Typically corresponds to a recipient address:
Address.parse("1CBtcGivXmHQ8ZqdPgeMfcpQNJrqTrSAcG").script
These are not derived from transaction outputs’s binary data, but set from some other source.
Reference to the owning transaction. It is set on tx.add_output and
reset to nil
in tx.remove_all_outputs. Default value is nil
.
Binary hash of the containing transaction. Default value is nil
.
Hex big-endian hash of the containing transaction. See Hash↔ID Conversion.
Index of this output in the containing transaction. Default value is nil
.
Binary hash of the block at which containing transaction was included.
If not confirmed or not available, equals nil
.
Hex big-endian hash corresponding to block_hash
. See Hash↔ID Conversion.
Height of the block at which containing transaction was included.
If not confirmed equals -1
.
Note: block_height
might not be provided by some APIs while confirmations
may be.
Default value is derived from transaction
if possible or equals nil
.
Time of the block at which containing transaction was included (Time
instance or nil
).
Default value is derived from transaction
if possible or equals nil
.
Number of confirmations. Default value is derived from transaction
if possible or equals nil
.
If available, returns whether this output is spent (true
or false
).
Default is nil
. See also spent_confirmations
.
If the containing transaction is spent, contains number of confirmations of the spending transaction.
Returns nil
if not available or output is not spent.
Returns 0
if spending transaction is not confirmed.
Binary representation of the transaction output in wire format (aka payload).
Dictionary representation of transaction output ready to be encoded in JSON, PropertyList etc.