Input
Also: vin, TxIn
network · intermediate
A reference to a previous transaction's UTXO, plus proof — a signature and/or script — that the spender is allowed to consume it.
A transaction input points at an existing [UTXO](/glossary/utxo) and provides the data needed to spend it. Three required fields:
- txid — the transaction ID of the previous transaction whose output is being spent.
- vout — the index of the specific output within that transaction (a transaction usually has multiple outputs; this picks one).
- scriptSig and/or witness — the unlocking data. In pre-SegWit (P2PKH) inputs, signatures live in scriptSig. In SegWit inputs (P2WPKH, P2WSH, P2TR), they live in the [witness](/glossary/witness) field outside the transaction body.
The witness/scriptSig has to satisfy the locking script that was attached to the output when it was created. For a typical P2WPKH input that means producing a signature over the transaction with the private key that matches the public-key-hash in the output's script. The [node](/glossary/node) re-runs the unlocking script against the locking script during validation; if it returns true, the spend is authorized.
A single transaction can have many inputs. Each input is independent: they can reference different prior transactions, be controlled by different keys, and use different script types. The total value of a transaction's inputs has to be at least as large as the total value of its outputs; the difference is the fee.