Back to lessons

Chapter 6 - 0 of 10 quizzes passed

Transactions, Change and Fees

Bitcoin transactions do not subtract from a balance; they consume old outputs and create new ones.

  • Trace a transaction from inputs to outputs, change, and miner fee
  • Calculate a fee from weight and fee rate, and explain what happens when a transaction is stuck

The UTXO model

Bitcoin does not keep account balances. It keeps unspent transaction outputs, or UTXOs: coins with locks on them.

  • A UTXO is a specific amount locked to a spending condition.
  • Your wallet’s “balance” is the sum of the UTXOs it can spend.
  • Full nodes keep the set of all UTXOs, so they can check a new transaction without replaying every block.

Inputs and outputs

A transaction consumes old outputs and creates new ones.

  • Inputs point at earlier outputs and unlock them, usually with a signature and a public key.
  • Outputs create new locks, each with an amount.
  • Inputs are spent whole, never partially. Send 1 BTC from a 5 BTC coin and the wallet adds a change output back to you.
  • Whatever the outputs do not claim becomes the miner fee.

What a transaction contains

Here is the payment from the worked example below, decoded field by field. Blue is what is spent, green is what the recipient gets, purple is your change, and red is the fee.

Decoded transaction (illustrative; ids shortened)
version2Which rule set the transaction uses.

Inputs (1): the coins being spent

prevout7f3a…c91e : 0Points at an earlier output worth 0.50000000 BTC.
witnesssignature + public keyProves the owner of the key approved this spend.
sequence0xfffffffdBIP125 opt-in signal. Bitcoin Core accepts the replacement without it by default since version 28, and version 29 removed the opt-out (RBF).

Outputs (2): the new coins created

output 00.10000000 BTCLocked to the recipient's address (bc1q…).
output 10.39998880 BTCChange, locked to a new address of your own.
locktime0Valid in any block; no time delay.

Not written anywhere

fee1,120 satsInputs minus outputs. The miner claims the difference.
txidhash of the transactionIts name on the network: double SHA-256 of the data above, without the witness.

Scripts are the locks

Each output carries a script that says who can spend it. “Sending to an address” is shorthand for creating an output with a particular lock; the ledger enforces the script, not a name or an account.

  • P2WPKH: one signature from the key that matches the committed public-key hash.
  • Multisig: M of N signatures, such as any 2 of 3 keys or 3 of 5.
  • Taproot: a key path, plus an optional tree of script paths.
  • The spending input supplies the witness data that satisfies the script.

Fees are a rate, not a flat amount

Miners are paid for block space, not for the amount of bitcoin moved.

  • Size is measured in virtual bytes (vB). Inputs, outputs and witness data all add size.
  • Fee rate is quoted in satoshis per virtual byte (sat/vB).
  • Fee = size × fee rate. A simple 1-input, 2-output segwit transaction is about 140 vB; at 10 sat/vB that is 1,400 sats.
  • More inputs mean a bigger transaction and a higher fee at the same rate.

The mempool and confirmation targeting

Valid unconfirmed transactions wait in each node’s mempool: a waiting room, not a single shared queue.

  • Miners fill a candidate block with the highest fee rates first.
  • When blocks are full, a low-fee transaction can wait a long time.
  • Stuck? Replace it with a higher-fee version (replace-by-fee, RBF; full-RBF is the Bitcoin Core default since version 28), or spend one of its outputs in a child that pays extra (CPFP).

What a mempool entry contains

Each node keeps its own record of every waiting transaction. These are the fields Bitcoin Core reports for one entry, and where it sits in the queue.

One mempool entry, as a node stores it
txid / wtxid7c2e…04abIds without and with witness data.
vsize140 vBWeight 560 WU; the block-space it needs.
fee1,120 satsInputs minus outputs.
fee rate8 sat/vBFee ÷ vsize. Miners sort by this.
timefirst seenWhen this node received it.
ancestors / descendants0 / 0Unconfirmed parents or children it depends on (CPFP packages).
bip125-replaceableyesCarries the opt-in signal. Under full-RBF no signal is needed, but a replacement must still pay more and meet the node’s replacement rules.

Where it waits: sorted by fee rate

  1. 45 sat/vBExchange withdrawal
  2. 22 sat/vBPayment
  3. 12 sat/vBPayment
  4. Next block fills up here (≈ 10 sat/vB)
  5. 8 sat/vBYour transaction
  6. 3 sat/vBConsolidation

At 8 sat/vB, yours waits for a later block unless fees fall or you bump it with RBF or CPFP.

Fee estimation in practice

Wallets estimate a fee rate from recent blocks and the current mempool.

  • A “fast” target uses a higher rate than an “economy” target.
  • Paying more is not a tip; it is a bid for scarce block space.
  • When the mempool clears, the same transaction could have confirmed for less. When blocks are full, a low bid can wait for hours.
  • Good wallets show the tradeoff in time, not just in satoshis.

A worked example

You have one UTXO of 0.5 BTC and send 0.1 BTC. Your wallet picks 8 sat/vB and estimates 140 vB.

Step by step

1. Price the space 140 vB × 8 sat/vB = 1,120 sats

2. Split the input

Input0.50000000 BTC
To recipient0.10000000 BTC
Change to you0.39998880 BTC
Fee (no output; miner claims it)0.00001120 BTC

3. Check it balances 0.50000000 BTC − 0.10000000 BTC − 0.39998880 BTC = 0.00001120 BTC

Except for the miner’s coinbase transaction, which creates new coins, outputs can never add up to more than the inputs; a transaction that creates value is invalid.

Privacy and failure modes

Change outputs and address reuse make transactions linkable. Coin control lets you choose which UTXOs to spend, which matters for privacy and for not dragging a large coin into a small payment. Common ways a payment goes wrong:

  • It never propagates to other nodes.
  • It sits below the current fee floor.
  • It is replaced by a higher-fee version.
  • It is evicted when mempools fill up, or Bitcoin Core drops it from its own mempool after about two weeks. It is not cancelled: it can be rebroadcast and still confirm.
  • “Unconfirmed” is not a promise. More confirmations generally reduce reversal risk, but no fixed count guarantees finality; the receiver picks a threshold for the amount at stake.

What you should take away

A transaction consumes UTXOs and creates new outputs. The fee is the input value minus the output value, priced by weight and fee rate. Mempool policy, RBF, CPFP, and change management decide whether it confirms quickly and what it reveals.

Retrieve, then apply

Calculate change for a 200,000 sat input, a 50,000 sat payment, and a 150 vB transaction at 6 sat/vB.

Check your explanation

Fee = 150 × 6 = 900 sats. Change = 200,000 − 50,000 − 900 = 149,100 sats. Recipient and change outputs sum to 199,100 sats.

Checkpoint

Question 1 of 3

One input is 500,000 sats. Outputs are 100,000 sats to the recipient and 398,600 sats change. What is the fee?

Question 2 of 3

A transaction is 200 vB at 5 sat/vB. What fee does it pay?

Question 3 of 3

Your transaction is stuck because its fee rate is too low. What can you do?

Sources

Reviewed 2026-10-25 · not financial advice