Mastering Bitcoin Transactions: How Value Moves in the Bitcoin Network

·

Bitcoin transactions are the lifeblood of the entire Bitcoin system. Every component of the network—from mining to wallet software—is designed to ensure that transactions can be created, propagated across the peer-to-peer network, verified, and permanently recorded on the blockchain. At their core, Bitcoin transactions are data structures encoding the transfer of value between participants. The blockchain serves as a global, public ledger where each transaction becomes an immutable entry.

In this chapter, we’ll break down the inner workings of Bitcoin transactions: their structure, creation, validation, and role in maintaining the ledger. When we refer to a "wallet," we mean the software responsible for constructing transactions—not just a key storage tool.


Transaction Anatomy: What You Don’t See in Wallets

In Chapter 2, we examined a sample transaction where Alice paid for coffee at Bob’s café using a block explorer. The interface showed a simple flow: funds moving from Alice’s address to Bob’s. But this is a high-level abstraction. The actual transaction data looks very different under the hood.

Most of what you see in wallet interfaces—addresses, senders, receivers—is reconstructed by applications. These concepts don’t exist natively in the raw transaction.

Let’s decode Alice’s raw transaction using Bitcoin Core commands (getrawtransaction and decoderawtransaction):

{
 "version": 1,
 "locktime": 0,
 "vin": [
   {
     "txid": "7957a35fe64f80d234d76d83a2a8f1a0d8149a41d81de548f0a65a8a999f6f18",
     "vout": 0,
     "scriptSig": "3045022100884d142d86652a3f47ba4746ec719bbfbd040a570b1deccbb6498c75c4ae24cb02204b9f039ff08df09cbe9f6addac960298cad530a863ea8f53982c09db8f6e3813[ALL] 0484ecc0d46f1918b30928fa0e4ed99f16a0fb4fde0735e7ade8416ab9fe423cc5412336376789d172787ec3457eee41c04f4938de5cc17b4a10fa336a8d752adf",
     "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"
   }
 ]
}

You might notice: Where are Alice and Bob’s addresses? Where’s the 0.1 BTC input? The truth is, Bitcoin doesn’t store addresses, balances, or accounts. These are abstractions built on top of the underlying UTXO model.


The UTXO Model: Unspent Transaction Outputs

The foundation of Bitcoin transactions is the Unspent Transaction Output (UTXO). Each UTXO is an indivisible unit of value recorded on the blockchain and recognized by all nodes.

What Is a UTXO?

When your wallet shows a “balance,” it’s actually summing all UTXOs your private keys can unlock. This balance is not stored—it’s computed by scanning the blockchain.

Key Insight: UTXOs are like physical coins or bills. You can’t split them—you must spend the whole amount and receive change.

How UTXOs Work in Practice

Imagine paying $1.50 with a $5 bill. You get $3.50 back as change. Similarly, if you have a 2 BTC UTXO but want to send 0.1 BTC, your transaction must:

This is why most Bitcoin transactions have multiple outputs—even simple ones.

👉 Discover how modern wallets manage UTXOs automatically


Transaction Inputs and Outputs Explained

Transaction Outputs (vout)

Each output contains:

In Alice’s transaction:

"vout": [
  {
    "value": 0.015,
    "scriptPubKey": "OP_DUP OP_HASH160 ab68... OP_EQUALVERIFY OP_CHECKSIG"
  },
  {
    "value": 0.0845,
    "scriptPubKey": "OP_DUP OP_HASH160 7f9b... OP_EQUALVERIFY OP_CHECKSIG"
  }
]

These scripts are typically P2PKH (Pay-to-Public-Key-Hash), locking funds to a Bitcoin address.

Transaction Inputs (vin)

Inputs reference and spend existing UTXOs. Each input includes:

Alice’s input:

"vin": [
  {
    "txid": "7957a35fe6...",
    "vout": 0,
    "scriptSig": "<signature> <pubkey>",
    "sequence": 4294967295
  }
]

To verify this input, nodes must:

  1. Fetch the referenced transaction
  2. Retrieve the UTXO
  3. Validate the signature against the locking script

How Transaction Fees Work

Bitcoin transactions often include fees paid to miners for securing the network.

Key Facts About Fees:

For example:

Fee Estimation & Priority

Miners prioritize transactions by fee rate (sat/vB). Higher fees = faster confirmation.

PriorityFee Rate (sat/vB)Confirmation Time
High80Next block
Medium603–6 blocks
Low301+ hours

Wallets use APIs like https://bitcoinfees.21.co/api/v1/fees/recommended to estimate optimal fees dynamically.

⚠️ Warning: Static fees lead to stuck transactions. Always use dynamic fee estimation.

👉 Learn how smart fee algorithms keep your transactions moving


Bitcoin Script: The Language of Transactions

Bitcoin uses a stack-based scripting language called Script to define spending conditions.

Core Principles:

Example: P2PKH (Most Common)

Locking Script (scriptPubKey):

OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG

Unlocking Script (scriptSig):

<signature> <publicKey>

When combined and executed, they verify that:

  1. The public key hashes to the expected value
  2. The signature matches the private key controlling that public key

Digital Signatures and ECDSA

Bitcoin uses Elliptic Curve Digital Signature Algorithm (ECDSA) to prove ownership without revealing private keys.

How It Works:

  1. A hash of the transaction is created
  2. Signed with the private key → produces (R, S) values
  3. Serialized using DER encoding

Example DER signature:

30450221...[ALL]

The [ALL] indicates SIGHASH_ALL, meaning the signature commits to all inputs and outputs—preventing tampering.

SIGHASH Types:

These enable advanced use cases like crowdfunding and atomic swaps.


Address and Balance Abstractions

Bitcoin doesn’t store addresses or balances—these are derived by wallets and block explorers.

How Addresses Are Built:

  1. Extract public key hash from scriptPubKey
  2. Encode using Base58Check → human-readable address (e.g., 1A1zP1...)

How Balances Are Calculated:

  1. Scan blockchain for UTXOs linked to your public key hash
  2. Sum their values → display as “balance”

This process requires indexing millions of transactions—explaining why some complex scripts appear as “unknown” in explorers.


Frequently Asked Questions

Q: Why doesn’t my transaction confirm?

A: Likely due to low fees. Use a fee estimator to rebroadcast with higher fees (via RBF or CPFP).

Q: Can I split a UTXO?

A: No—UTXOs are indivisible. You must spend the whole amount and receive change.

Q: What happens if I forget to add change?

A: The remaining amount becomes a mining fee—potentially costing you thousands.

Q: Are Bitcoin addresses stored in transactions?

A: No—only public key hashes are stored. Addresses are reconstructed by software.

Q: How do wallets calculate my balance?

A: By scanning the blockchain for UTXOs your keys can unlock and summing their values.

Q: Can I create custom spending conditions?

A: Yes—via custom scripts like multisig, timelocks, or smart contracts using Taproot.


Final Thoughts

Bitcoin transactions are more than simple value transfers—they’re programmable data structures enabling trustless exchange. While wallets abstract complexity into familiar concepts like addresses and balances, understanding the underlying mechanics empowers better security, cost control, and innovation.

From UTXOs to scripts, every element ensures decentralization, verifiability, and permanence. As Bitcoin evolves with upgrades like SegWit and Taproot, these fundamentals remain unchanged—forming the bedrock of digital ownership.

👉 Explore how advanced wallets leverage these principles for seamless crypto management