Bitcoin Transactions Explained: UTXO, Scripting, and Validation

·

Bitcoin is more than just digital cash — it's a decentralized system built on cryptographic principles, peer-to-peer networking, and transparent ledgers. At the heart of this system lies the transaction, the fundamental unit that enables value transfer across the network.

In this article, we'll dive deep into how Bitcoin transactions work, from their underlying structure to the scripting mechanisms that secure them. Whether you're revisiting the basics or expanding your blockchain knowledge, this guide will clarify how transactions are constructed, validated, and permanently recorded.

Understanding Bitcoin Transaction Structure

Every Bitcoin transaction consists of inputs and outputs, forming a chain of ownership that traces back to coin creation (mining). Unlike traditional bank accounts with balances, Bitcoin uses a model called Unspent Transaction Outputs (UTXO) to track ownership.

👉 Discover how real-time blockchain transactions are processed and verified.

Think of UTXOs as digital coins of varying denominations. When you "send" Bitcoin, your wallet selects enough UTXOs to cover the payment, creates new outputs for the recipient and yourself (change), and marks the old ones as spent.

Let’s walk through a real-world example:

Alice buys a coffee from Bob’s café for 0.015 BTC. Her wallet constructs a transaction like this:

{
  "version": 1,
  "locktime": 0,
  "vin": [
    {
      "txid": "7957a35fe64f80d234d76d83a2a8f1a0d8149a41d81de548f0a65a8a999f6f18",
      "vout": 0,
      "scriptSig": "3045022100884d...[ALL] 0484ecc0d4...",
      "sequence": 4294967295
    }
  ],
  "vout": [
    {
      "value": 0.01500000,
      "scriptPubKey": "OP_DUP OP_HASH160 ab68025513c3dbd2f7b92a94e0581f5d50f654e7 OP_EQUALVERIFY OP_CHECKSIG"
    },
    {
      "value": 0.08450000,
      "scriptPubKey": "OP_DUP OP_HASH160 7f9b1a7fb68d60c536c2fd8aeaa53a8f3cc025a8 OP_EQUALVERIFY OP_CHECKSIG"
    }
  ]
}

This JSON represents the raw data behind a transaction — not what you see in a wallet, but what miners and nodes process.

Breaking Down Inputs and Outputs

The total input value was 0.0995 BTC (0.015 + 0.0845), so:

Bitcoin does not return “change” like physical money — instead, it creates a new output for the sender.

What Are Unspent Transaction Outputs (UTXOs)?

UTXOs are the foundation of Bitcoin’s accounting model. Each output represents a chunk of Bitcoin that hasn’t been spent yet. When used as an input in a new transaction, it becomes spent and can never be reused.

There are two types:

When your wallet shows a balance of “1.2 BTC,” it’s actually summing up hundreds or thousands of individual UTXOs scattered across the blockchain.

Each vout contains:

For example:

"value": 0.01500000,
"scriptPubKey": "OP_DUP OP_HASH160 ab6802... OP_EQUALVERIFY OP_CHECKSIG"

This means: “Only someone who can prove ownership of the private key corresponding to address ab6802... may spend this.”

How Transaction Inputs Claim Ownership

Inputs don’t contain Bitcoin — they point to previous outputs. To spend them, users must provide proof of ownership via an unlocking script (scriptSig).

In our example:

"txid": "7957a35f...",
"vout": 0,
"scriptSig": "30450221...[ALL] 0484ecc..."

Here:

Nodes verify this by:

  1. Fetching the referenced UTXO from the blockchain
  2. Checking if it’s still unspent
  3. Running both scripts together to confirm validity

If any step fails — duplicate spend, invalid sig — the entire transaction is rejected.

The Role of Bitcoin Script: Locking and Unlocking Funds

Bitcoin uses a simple, stack-based scripting language to define spending rules. Two key components make this work:

During validation, nodes combine both scripts and execute them sequentially.

Example: Pay-to-Public-Key-Hash (P2PKH)

Most common transaction type.

Locking Script (in UTXO):

OP_DUP OP_HASH160 <Bob's address> OP_EQUALVERIFY OP_CHECKSIG

Unlocking Script (provided by Bob later):

<Bob's signature> <Bob's public key>

Execution flow:

  1. Push public key and signature onto stack
  2. Duplicate public key (OP_DUP)
  3. Hash it (OP_HASH160) and compare to stored address
  4. Verify signature matches (OP_CHECKSIG)

Only if all steps succeed is the transaction valid.

👉 Learn how advanced wallets use scripting for enhanced security and control.

Beyond Basic Payments: Multi-Signature & P2SH Scripts

While P2PKH works for everyday use, more complex scenarios require flexible scripting.

Multi-Signature (M-of-N) Transactions

Used for shared custody (e.g., corporate wallets). Requires M out of N signatures to unlock funds.

Example: A 2-of-3 setup for a business wallet:

Locking script:

2 <PubKey1> <PubKey2> <PubKey3> 3 OP_CHECKMULTISIG

Problem? Long scripts increase transaction size and cost — especially when N is large.

Pay-to-Script-Hash (P2SH): Simplifying Complexity

P2SH solves bloat by hashing complex redemption logic.

Instead of embedding a long multi-sig script, senders lock funds to its hash:

OP_HASH160 <hash_of_redeem_script> OP_EQUAL

To spend, the user provides:

Node checks:

  1. Does the redeem script hash match?
  2. Are signatures valid?

This shifts responsibility from sender to receiver — cleaner, cheaper, more scalable.

👉 See how institutions leverage P2SH and multi-sig for secure asset management.

Script Language Design: Security Through Simplicity

Bitcoin’s script isn’t Turing-complete. It lacks loops and complex control flows to prevent infinite execution or resource exhaustion attacks.

It operates on a stack-based model, processing instructions left to right:

Example:
Script: 2 3 OP_ADD 5 OP_EQUAL
Steps:

  1. Push 2, then 3
  2. OP_ADD → pops both, pushes 5
  3. Push 5, run OP_EQUAL → compares top two values
  4. Result: TRUE

Only successful execution validates the transaction.

Frequently Asked Questions (FAQ)

Q: What is a UTXO?
A: An Unspent Transaction Output represents a discrete amount of Bitcoin that can be spent as input in a new transaction. Your wallet balance is the sum of all your UTXOs.

Q: Why doesn’t Bitcoin use account balances like banks?
A: The UTXO model enhances privacy and parallelizability. Each transaction explicitly references prior outputs, making double-spending impossible without network consensus.

Q: How are transaction fees determined?
A: Fees are the difference between total inputs and total outputs. Higher fees incentivize miners to prioritize your transaction during congestion.

Q: Can a UTXO be partially spent?
A: No — UTXOs are indivisible. Spending part of one creates two outputs: one to the recipient, one as change back to you.

Q: What happens if I lose my private key?
A: You lose access to all UTXOs locked under that key. There’s no recovery mechanism — this underscores the importance of secure key storage.

Q: Is Bitcoin scripting used only for payments?
A: No — while most scripts handle basic transfers, advanced use cases include time-locked contracts, escrow services, and decentralized finance primitives.

Core Keywords

By understanding how inputs, outputs, and scripts interact, you gain insight into Bitcoin’s trustless design — where math replaces intermediaries, and code enforces ownership.