Glossary | Input
$16,548.83/BTCBuy

Input

An input is what you call an output when you're spending it in a transaction.

Structure

01000000017967a5185e907a25225574544c31f7b059c1a191d65b53dcc1554d339c4f9efc010000006a47304402206a2eb16b7b92051d0fa38c133e67684ed064effada1d7f925c842da401d4f22702201f196b10e6e4b4a9fff948e5c5d71ec5da53e90529c8dbd122bff2b1d21dc8a90121039b7bcd0824b9a9164f7ba098408e63e5b7e3cf90835cceb19868f54f8961a825ffffffff014baf2100000000001976a914db4d1141d0048b1ed15839d0b7a4c488cd368b0e88ac00000000

Transaction: 0d0897966df95d0b8e7a33855a64f7de365e7d17e28f2a05c39806e77d5f9859

Fields

Field Data Size Description
TXID 796...efc 32 bytes Refer to an existing transaction.
VOUT 01000000 4 bytes Select one of its outputs.
ScriptSig Size 6a Variable Indicates the upcoming size of the unlocking code.
ScriptSig 473...825 A script that unlocks the input.
Sequence ffffffff 4 bytes

TXID Byte Order: When you refer to a TXID within transaction data, you have to reverse the byte order to get it in its original format. The byte-order used when searching for a TXID is in reverse (due to a historical mistake in the way the original bitcoin client works).

How do Inputs work?

An an "input" has two jobs:

  1. Select an Output.
  2. Unlock it.

1. Select an Output.

When you want to use an output as an input for a transaction, you just need to specify which one you want to spend.

Every transaction has a unique TXID, so by using that with a specific output number (VOUT), you can refer to any output in the blockchain.

All you need is a txid and a vout and you can select any output from the blockchain.

All you need is a txid and a vout and you can select any output from the blockchain.

2. Unlock it.

After selecting an output, you then have to be able to unlock it.

Each output is set with a locking script. So if you want to spend one, you need to supply an unlocking script (called a ScriptSig).

Nodes validate every transaction they receive. So if you do not provide an unlocking script that satisfies the locking script, your transaction will get rejected.

Notes

listunspent

This command gives you a list of unspent outputs in your Bitcoin Core wallet.

In other words, it gives you a list of outputs that you can use as inputs in a new transaction:

$ bitcoin-cli listunspent

[
  {
    "txid" : "txid",          (string) the transaction id 
    "vout" : n,               (numeric) the vout value
    "address" : "address",    (string) the bitcoin address
    "account" : "account",    (string) DEPRECATED. The associated account, or "" for the default account
    "scriptPubKey" : "key",   (string) the script key
    "amount" : x.xxx,         (numeric) the transaction output amount in BTC
    "confirmations" : n,      (numeric) The number of confirmations
    "redeemScript" : n        (string) The redeemScript if scriptPubKey is P2SH
    "spendable" : xxx,        (bool) Whether we have the private keys to spend this output
    "solvable" : xxx,         (bool) Whether we know how to spend this output, ignoring the lack of keys
    "safe" : xxx              (bool) Whether this output is considered safe to spend. Unconfirmed transactions
                              from outside keys and unconfirmed replacement transactions are considered unsafe
                              and are not eligible for spending by fundrawtransaction and sendtoaddress.
  }
  ,...
]
Back to Top