How Does a Bitcoin Transaction Work? Inputs, Outputs and Change
Bitcoin transactions explained simply: inputs, outputs and change, how the fee arises, what happens in the mempool and why 6 confirmations are the rule.
Short answer: A bitcoin transaction takes amounts you received earlier (inputs) and splits them anew (outputs): one part to the recipient, the rest back to you as change. Whatever is left between inputs and outputs is the fee for the miner. Your wallet signs the whole thing with your private key, sends it to the network, and a miner writes it into a block. From that moment it is confirmed, and every further block makes it safer.
If you only hold bitcoin on an exchange, you see none of this: there is a number and a send button. As soon as you hold bitcoin in your own wallet, it pays to understand what happens behind the button. You then understand why sending 0.01 BTC sometimes costs more than sending 1 BTC, why an address you never used suddenly appears in your wallet, and why the merchant waits for confirmations.
The UTXO model: bitcoin like banknotes in a wallet
A bank account is a single number. When €100 comes in, it goes up. When €30 goes out, it goes down. Bitcoin works differently. There is no account with a balance, only individual amounts that were paid to your addresses. Experts call them UTXOs, "unspent transaction outputs": outputs of earlier transactions that have not been spent yet.
The easiest way to picture UTXOs is as banknotes in a wallet:
- Every payment to you is a separate note. If you withdrew from the exchange three times, there are three notes in your wallet, however large each one is.
- You can't tear a note. You spend it whole and get change back.
- A note can have any amount, for example 0.0734 BTC. There are no fixed denominations like €5, €10 or €50 notes.
What your wallet shows as your balance is just the sum of all notes belonging to your addresses. The blockchain itself knows no balance. It only knows transactions, and every transaction uses up old notes and creates new ones.
Inputs, outputs and change
Every transaction has two sides.
Inputs are the notes you spend. Each input points to an output of an earlier transaction, that is, to a note you received at some point. It is used up completely.
Outputs are the new notes being created. Each output has an amount in sats and a condition stating who may spend it later. Usually that is an address: only whoever holds the matching private key can spend it. What the different addresses look like is explained in Bitcoin addresses explained: bc1q, bc1p, 3 and 1.
A typical transfer has one input and two outputs: one to the recipient and one back to you. This second output is the change.
The change address
The change usually doesn't go back to the address the input came from, but to a new address in your own wallet. That's why after a transfer you sometimes see an address with a balance that you never gave to anyone. It still belongs to you: modern wallets derive all addresses from the same seed phrase, and change addresses come from a branch of their own.
The reason is privacy. If the change went back to the old address, anyone could see on the blockchain at once which output was the payment and which was the rest. With a new address this is harder to tell, though not impossible.
Several inputs in one transaction
If one note isn't enough, the wallet takes several. If you want to send 0.08 BTC and have notes of 0.05 and 0.04 BTC, both become inputs:
| Sats | |
|---|---|
| Input 1 | 5’000’000 |
| Input 2 | 4’000’000 |
| Output 1: recipient | 8’000’000 |
| Output 2: change | 998’955 |
| Fee (209 vbytes × 5 sat/vB) | 1’045 |
Each input makes the transaction larger, because a signature of its own is sent along for each one. That's why the transfer with two inputs costs more in fees than the one with one input, even though the amount plays no role. If you collect many small withdrawals in your wallet, you pay for it later when spending. How to plan for that is covered in the article on bitcoin transaction fees and the mempool.
The fee is the difference
A bitcoin transaction has no "fee" field. There are only inputs and outputs. Whatever the inputs hold beyond the outputs may be kept by the miner who writes the transaction into a block.
How the fee comes about
Fee = sum of inputs − sum of outputs
Example above: 5’000’000 − (2’000’000 + 2’999’295) = 705 sats
Fee rate = fee ÷ size in vbytes = 705 ÷ 141 = 5 sat/vB
Rule of the nodes: sum of outputs ≤ sum of inputs. Otherwise the transaction would create bitcoin out of nothing, and it is rejected.
This leads to an expensive trap: if you build a transaction by hand and forget the change output, you give the whole rest to the miner. Normal wallets work out the change themselves. Good wallets also warn you when the fee is unusually high compared with the amount.
If the change is so small that an output of its own would cost more in fees than it is worth, many wallets leave it out and add the small rest to the fee. Nodes don't relay outputs of a few hundred sats anyway; they count as "dust".
Signing: who may spend a note?
Every output is tied to a condition, usually: "Whoever provides a valid signature for the key behind this address may spend it." When you send, your wallet creates a digital signature for each input with the matching private key.
The signature proves two things at once: you hold the key, and you agree to exactly this transaction. If anyone changes even one sat of the amount or the recipient on the way, the signature no longer fits, and all nodes reject the transaction. Nobody sees the private key itself; it never leaves your wallet. With a hardware wallet it doesn't even leave the device.
What a transaction contains
- Version and locktime (the earliest point at which it is valid; usually immediately)
- Inputs: each a reference to an earlier output (transaction ID and the output's number) plus the signature with the public key. For SegWit and Taproot addresses the signature sits in a separate part called the "witness".
- Outputs: each an amount in sats and a script with the condition for spending it (the address)
The transaction ID (TXID) is the double SHA-256 hash of the transaction data without the witness. Signatures use ECDSA on the secp256k1 curve, or Schnorr signatures under BIP 340 for Taproot.
Sending, mempool and confirmation
1. Broadcast
Your wallet sends the finished, signed transaction to one or more nodes in the bitcoin network. This is called the broadcast. Each node checks it itself: do the inputs still exist? Are the signatures valid? Are the outputs no larger than the inputs? Is the fee high enough for its rules? If so, it passes the transaction on to its neighbours. Within a few seconds practically every node knows it.
2. Mempool
Until a miner picks it up, the transaction waits in the mempool, the waiting area of every node. There it is known, but not yet final. Your wallet shows it as "unconfirmed" or "pending". Miners pick the transactions with the highest fee rate from the mempool first. How long you wait therefore depends on your fee and on how busy the network is. How to choose the right fee and speed up a stuck transaction is covered in the article on fees and the mempool.
3. First confirmation
A miner bundles transactions into a block and uses proof of work to search for a valid solution for it. On average this succeeds every 10 minutes. If your transaction is in that block, it has 1 confirmation. Now your old notes are used up, and the recipient has a new note they can spend themselves.
4. Further confirmations
Every new block added to the chain afterwards counts as another confirmation. After 6 blocks your transaction has 6 confirmations. That takes about an hour on average, but it can also be 30 or 90 minutes, because blocks are found at random.
You can watch new blocks being created, and how many transactions they carry, live here:
- Block 975’721Previous fingerprintPaymentsOwn fingerprint
- Block 975’722Previous fingerprintPaymentsOwn fingerprint
- Block 975’723Previous fingerprintPaymentsOwn fingerprint
Why 6 confirmations?
As long as a transaction only sits in the mempool, the sender can try to send the same notes again to themselves, with a higher fee. If a miner takes the second version, the first becomes invalid. This is called a double spend. That's why an unconfirmed payment is only a promise.
Once the transaction is in a block, an attacker would have to replace that block and every block found after it with a longer chain of their own. That takes computing power, and each further block makes it harder. Satoshi Nakamoto worked this out in the white paper: with 10% of the total computing power, an attacker has a chance of about 0.02% of reversing a payment after 6 confirmations. After 1 confirmation it is still about 20%.
The calculation from the white paper (section 11)
q = the attacker's share of the computing power, z = number of confirmations
Probability that the attacker catches up, for q = 10%:
| z | Probability |
|---|---|
| 1 | 20.5% |
| 2 | 5.1% |
| 3 | 1.3% |
| 5 | 0.09% |
| 6 | 0.02% |
Confirmations needed for the probability to drop below 0.1%: q = 10% → 5, q = 20% → 11, q = 30% → 24, q = 40% → 89.
If the attacker has more than 50% of the computing power, they always catch up in the long run. Then even many confirmations don't help.
So the number 6 is not a rule of the protocol but a proven convention. It dates from the early days: Satoshi's original software already showed payments with fewer than 6 confirmations as unconfirmed. You may decide how many confirmations to wait for based on the amount:
| Situation | Usual wait |
|---|---|
| Small amount between acquaintances | 0 to 1 confirmation |
| Normal payment, deposit to an exchange | 1 to 3 confirmations (depending on the exchange) |
| Large amount, sale of a car or a flat | 6 confirmations |
| Very large amounts, institutional payments | often more than 6 |
For you as the recipient this means: with large amounts, hand over goods or services only once the transaction is sufficiently confirmed. A screenshot or a TXID from the mempool isn't enough for that.
What this means for you as a saver
- Fewer, larger withdrawals. Every note you bring into your wallet becomes an input of its own later and costs fees when spent. One large note is cheaper to spend than twenty small ones.
- The change belongs to you. If an unknown address with a balance shows up in your wallet after a transfer, that's your change. It is secured by the same seed phrase.
- Choose the fee deliberately. If you're in no hurry, a low fee rate is enough. Your wallet shows you the fee in sats before sending; check it before you sign.
- Wait for confirmation. A deposit is only available once the recipient has seen enough confirmations. Allow some time with exchanges or merchants.
- Check the address. Nobody can take back a confirmed transaction. Compare the recipient address before sending, ideally on the screen of your hardware wallet.
Frequently asked questions
What is a UTXO?
A UTXO ("unspent transaction output") is an amount from an earlier transaction that has not been spent yet. You can picture it as a banknote: it is always spent whole, and the rest comes back as change. Your balance is the sum of your UTXOs.
Why does my change go to a new address?
For privacy. With a new address it is harder for outsiders to tell which output is the payment and which is your rest. The address still belongs to your wallet and is secured by your seed phrase.
How long does a bitcoin transaction take?
It reaches the network in seconds. The first confirmation comes after about 10 minutes on average if the fee is high enough. 6 confirmations take about an hour on average. With a low fee and a full mempool it can take longer.
Can you cancel a bitcoin transaction?
Not a confirmed one. As long as it is unconfirmed in the mempool, you can replace it with a new one at a higher fee that sends the money back to yourself. Whether this works depends on which version a miner puts into a block first.
Why does a small transfer sometimes cost more than a large one?
The fee depends on the size of the transaction in vbytes, not on the amount. If a small amount is made up of many small inputs, the transaction is large and expensive. A large amount from a single input is small and cheap.
How many confirmations do I need?
The protocol prescribes no number. For small amounts one confirmation is often enough; for large amounts 6 is the common rule. Exchanges set their own number.
Sources
- Satoshi Nakamoto: Bitcoin: A Peer-to-Peer Electronic Cash System, Oct 31, 2008, sections 2 (transactions), 5 (network) and 11 (calculations)
- bitcoin.org: Developer Guide: Transactions
- BIP 141: Segregated Witness
- BIP 340: Schnorr Signatures for secp256k1
- BIP 32: Hierarchical Deterministic Wallets, separate branches for receiving and change addresses
- Bitcoin Wiki: Confirmation
Not financial, legal or tax advice. Models are no guarantee.
The Bitcoin Power Law newsletter
An email when we publish a new article or calculator. Every issue has a one-click unsubscribe link.