Transaction Inputs

9 min readarticleIncludes quiz · 4 questions

Every Bitcoin you spend must come from somewhere — a specific previous transaction where you received it. These references back to previous transactions are called inputs, and they form an unbroken chain all the way back to the coinbase transaction that originally mined those coins.

Transaction inputs are where your Bitcoin comes from. Each input references a previous UTXO you own and includes a signature proving you have the right to spend it. Think of inputs as showing your "receipts" of where your money came from.

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).
Transaction Input Structure
Transaction Input Structure

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."

Multiple Inputs Example:

Alice has:

She wants to send 0.6 BTC to Bob. Her wallet combines:

Inputs:

  • Input 1: Reference to UTXO 1 (0.3 BTC) + signature
  • Input 2: Reference to UTXO 2 (0.25 BTC) + signature

Total input value: 0.55 BTC (not enough!)

She needs to add:

  • Input 3: Reference to UTXO 3 (0.15 BTC) + signature

Total input value: 0.70 BTC ✓ Output to Bob: 0.6 BTC Change back: 0.0999 BTC Fee: 0.0001 BTC

Multiple Inputs
Multiple Inputs

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:

  • Largest first: Use biggest UTXOs to minimize number of inputs (smaller transaction).
  • Smallest first: Use smallest UTXOs to consolidate dust.
  • Privacy-focused: Avoid linking UTXOs from different sources.
  • Fee-optimized: Balance between transaction size and future fee savings.

Trade-offs:

  • More inputs = larger transaction = higher fees
  • Fewer inputs = better, but might not have enough value
  • Consolidating dust = good when fees are low

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.

Key Takeaway

Inputs reference previous outputs. This chain of references is how Bitcoin proves ownership without a central authority. Every coin can be traced back to the block where it was mined.

Test Your Knowledge

4 questions · Passing score: 75%

Enjoying these lessons?

Get a free Bitcoin lesson in your inbox every week. Join thousands of learners.

Free forever. No spam. Unsubscribe anytime.