Protocol Rules

Bitcoin Transactions

Inputs, outputs, and scripts. How Bitcoin actually moves from one owner to another.

Not Accounts—UTXOs

Bitcoin doesn't use accounts with balances like a bank. Instead, it uses UTXOs—Unspent Transaction Outputs. Think of them like discrete "coins" of various sizes.

When you receive bitcoin, you receive one or more UTXOs. When you spend, you consume entire UTXOs and create new ones. Your "balance" is just the sum of all UTXOs you control.

A UTXO is like a check made out to you. You can't tear off part of a check—you cash the whole thing. Same with UTXOs: spend the whole thing, get change back.

Transaction Structure

Every Bitcoin transaction has inputs (UTXOs being spent) and outputs (new UTXOs being created):

INPUTS (being spent)

From previous tx
0.5 BTC
From previous tx
0.3 BTC
📝
Transaction

OUTPUTS (created)

To recipient
0.6 BTC
Change (back to you)
0.19 BTC
0.80 BTC
Total Inputs
=
0.79 BTC
Total Outputs
+
0.01 BTC
Fee (to miner)

Notice: Inputs (0.80) = Outputs (0.79) + Fee (0.01). The fee is implicit—it's whatever is left over. Forget to add a change output, and the miner takes everything!

Locking and Unlocking

Each UTXO is "locked" with a script that specifies conditions for spending. The most common: "provide a signature from this public key."

When you spend a UTXO, you provide an "unlocking script" (usually your signature). If it satisfies the locking conditions, the UTXO can be spent.

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

The most common transaction type. Lock: "Only someone with the private key for this address can spend."

// Locking script (in the UTXO):
OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG

// Unlocking script (provided by spender):
<signature> <pubKey>

Translation: "Duplicate the public key, hash it, check it matches the expected hash, then verify the signature is valid for this key."

Transaction Fees

There's no "fee" field in a transaction. The fee is simply inputs minus outputs. Whatever's left over goes to the miner who includes your transaction.

Factor Effect on Fee
Transaction size Larger tx = more bytes = higher fee needed
Network congestion More pending txs = higher fee to get confirmed fast
Number of inputs More inputs = larger tx = higher fee
Urgency Need fast confirmation? Pay more

Fees are measured in satoshis per virtual byte (sat/vB). During high demand, fees can spike. During quiet periods, you can get confirmed for just a few sats/vB.

Transaction Types

Type Use Case Size
P2PKH Legacy addresses (1...) Larger
P2SH Script hash, multisig (3...) Medium
P2WPKH Native SegWit (bc1q...) Smaller
P2TR Taproot (bc1p...) Most efficient

Newer address types (SegWit, Taproot) are more efficient, meaning lower fees for the same transaction.

The Mempool

When you broadcast a transaction, it enters the mempool—a waiting room of unconfirmed transactions. Miners pick from this pool, prioritizing higher-fee transactions.

Your transaction isn't final until it's in a block. Until then, it's just a proposal floating in the mempool, waiting for a miner to include it.

Next: The Blockchain →

How blocks link together to create an immutable history.

📌 TL;DR
A Bitcoin transaction spends previous outputs and creates new ones. Your signature proves you own the coins. Each transaction destroys old UTXOs and creates fresh ones—no moving, just reclassifying.

Frequently Asked Questions

What's a UTXO?

Unspent Transaction Output—the "coins" in Bitcoin. Unlike bank accounts (subtract from balance), Bitcoin tracks individual unspent chunks. Your wallet manages many UTXOs automatically.

Why do I pay fees?

You're bidding for block space. Each block fits ~3,000 transactions. When demand is high, fees spike. The fee also protects against dust spam—tiny UTXOs would cost more to spend than they're worth.

Can I spend someone else's Bitcoin?

Only if you have their private key. Signatures are math—you cannot fake them. Without the key, the math doesn't work and every node rejects the transaction.

← Previous: Consensus Next: Blockchain →