Transaction Input (aka "txin") is a part of a bitcoin transaction that unlocks bitcoins stored in the outputs of the previous transactions.
Every input contains a reference to some output (transaction hash and a numeric index of the output) and a signature script that typically contains signatures and other data to satisfy conditions defined by the corresponding output script.
Invalid index is used in coinbase inputs. Equals 0xFFFFFFFF
((unsigned int) -1
).
Equals 0xFFFFFFFF
.
Equals all-zero 32-byte binary string.
Returns a new transaction input initialized with a binary string in wire format.
Raises ArgumentError
if transaction input is incomplete or incorrectly encoded.
Returns a new transaction input initialized with data in wire format read from a given stream.
Raises ArgumentError
if transaction input is incomplete or incorrectly encoded.
Returns a new transaction input with named attributes. All attributes are optional and have appropriate default values.
TransactionInput.new(
previous_id: "d21633ba23f70118185227be58a63527675641ad37967e2aa461559f577aec43",
previous_index: 0,
signature_script: Script.new << script_signature << pubkey,
...
)
Binary hash of the previous transaction.
Hex big-endian hash of the previous transaction. See Hash↔ID Conversion.
Index of the previous transaction's output (uint32).
Default value is INVALID_INDEX
.
BTC::Script instance that proves ownership of the previous transaction output. We intentionally do not call it "script" to avoid accidental confusion with TransactionOutput#script.
For coinase inputs use coinbase_data
instead.
Binary string contained in place of signature_script
in a coinbase input (see coinbase?
).
Returns nil
if it is not a coinbase input.
Input sequence (uint32_t). Default is maximum value 0xFFFFFFFF. Sequence is used to update a timelocked tx stored in memory of the nodes. It is only relevant when tx lock_time > 0. Currently, for DoS and security reasons, nodes do not store timelocked transactions making the sequence number meaningless.
These are not derived from transaction input’s binary data, but set from some other source.
Optional reference to the owning transaction. It is set on tx.add_input and
reset to nil
on tx.remove_all_inputs.
Default value is nil
.
Optional reference to an output that this input is spending.
Optional value in the corresponding output (in satoshis).
Default value is transaction_output.value
or nil
.
Binary representation of the transaction input in wire format (aka payload).
Dictionary representation of transaction input ready to be encoded in JSON, PropertyList etc.
Returns true
if this transaction input belongs to a coinbase transaction.
Coinbase input has no signature_script
and its index
equals INVALID_INDEX
.