Transaction Inputs
What is a Transaction Input?
- •Definition: A reference to a previous unspent output (UTXO) that you're spending.
- •Components: Previous transaction ID, output index, signature script (unlocking script).
- •Proof of ownership: Contains your digital signature proving you own the private key.
- •Multiple inputs: Transactions can have many inputs to combine smaller amounts.
- •Must be unspent: You can only spend UTXOs that haven't been spent yet (no double-spending).
Key Definitions:
- •Outpoint: The reference to a previous output (txid + index).
- •Previous txid: The transaction ID where the UTXO was created.
- •Output index (vout): Which output of that transaction (outputs are numbered starting from 0).
- •scriptSig: The unlocking script containing your signature and public key.
- •Witness: In SegWit transactions, signature data moved here (separate from base transaction).
- •Sequence: A field for advanced features like Replace-By-Fee and timelocks.
Input Structure:
``` Input: Previous tx: 7f8a9b3c... (txid) Output index: 0 scriptSig: <signature> <public key> Sequence: 0xffffffff ```
This says: "I'm spending output #0 from transaction 7f8a9b3c..., and here's my signature to prove it."
How Inputs Are Validated:
1. Check UTXO exists: Node looks up the previous transaction and output index. 2. Verify unspent: Ensure this UTXO hasn't been spent already. 3. Check signature: Verify the signature matches the public key and transaction data. 4. Match public key: Confirm the public key hashes to the address that locked the UTXO. 5. Sum values: Ensure total inputs ≥ total outputs + fee.
Coin Selection (How Wallets Choose Inputs):
Strategies:
Input Locking Scripts:
UTXOs are locked with scripts that define spending conditions:
- •P2PKH (Pay-to-Public-Key-Hash): Locked to a Bitcoin address. Requires signature + public key.
- •P2WPKH (SegWit): Similar to P2PKH but witness data is separate.
- •P2SH (Pay-to-Script-Hash): Locked to a script hash (e.g., multisig).
- •P2TR (Taproot): Most flexible, privacy-preserving scripts.
Inputs must provide the correct "key" (scriptSig or witness) to unlock each type.
Test Your Knowledge
This lesson includes a 4-question quiz (passing score: 75%).
Quiz functionality available in the mobile app.