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?
- A UTXO represents a specific amount of bitcoin (in satoshis).
- It includes a locking script (scriptPubKey) defining who can spend it.
- Full nodes track all UTXOs in the UTXO set, currently numbering in the tens of millions.
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:
- Consume the full 2 BTC UTXO
Create two outputs:
- 0.1 BTC to the recipient
- 1.9 BTC as change back to your wallet
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:
- A value in satoshis (1 BTC = 100,000,000 satoshis)
- A locking script (scriptPubKey) that sets spending conditions
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:
txid: Hash of the transaction containing the UTXOvout: Index of the output (starting from 0)scriptSig: Unlocking script (signature + public key)sequence: Used for advanced features like Replace-by-Fee
Alice’s input:
"vin": [
{
"txid": "7957a35fe6...",
"vout": 0,
"scriptSig": "<signature> <pubkey>",
"sequence": 4294967295
}
]To verify this input, nodes must:
- Fetch the referenced transaction
- Retrieve the UTXO
- 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:
- Fees are not based on transaction value—they’re based on size in kilobytes
- Fee = Sum of inputs – Sum of outputs
- No dedicated fee field exists in transaction data
For example:
- Input: 0.1 BTC
- Outputs: 0.015 BTC (to Bob) + 0.084 BTC (change)
- Fee: 0.001 BTC (unclaimed difference)
Fee Estimation & Priority
Miners prioritize transactions by fee rate (sat/vB). Higher fees = faster confirmation.
| Priority | Fee Rate (sat/vB) | Confirmation Time |
|---|---|---|
| High | 80 | Next block |
| Medium | 60 | 3–6 blocks |
| Low | 30 | 1+ 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:
- Turing-incomplete: No loops—ensures predictable execution
- Decentralized validation: Same result on every node
- Based on locking scripts (scriptPubKey) and unlocking scripts (scriptSig)
Example: P2PKH (Most Common)
Locking Script (scriptPubKey):
OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIGUnlocking Script (scriptSig):
<signature> <publicKey>When combined and executed, they verify that:
- The public key hashes to the expected value
- 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:
- A hash of the transaction is created
- Signed with the private key → produces
(R, S)values - 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:
ALL: Signs all inputs/outputs (most common)NONE: Only signs inputs; outputs can changeSINGLE: Signs one input-output pairANYONECANPAY: Only signs one input; others can be added
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:
- Extract public key hash from scriptPubKey
- Encode using Base58Check → human-readable address (e.g.,
1A1zP1...)
How Balances Are Calculated:
- Scan blockchain for UTXOs linked to your public key hash
- 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