MASTERING-BITCOIN · Interactive Practice | Unit 10 · Video 5

Stealing the Past: How Bitcoin Wallets Defend Against Fee Sniping

IKey Concepts Reference

Concept Definition
Miner Revenue R=Subsidy+FeesR = \text{Subsidy} + \text{Fees}
**Subsidy at halving } h|S_h = 50 / 2^h$ BTC (halves every 4 years)
nLockTime rule Tx is valid only if block heightnLockTime\text{block height} \geq \text{nLockTime}
Anti-fee-sniping Wallets set nLockTime=tip+1\text{nLockTime} = \text{tip} + 1

IIVisualization 1: The Shrinking Security Budget

Bitcoin's block reward has two parts: the subsidy (freshly minted coins) and transaction fees. The subsidy halves every 4 years. As it shrinks, fees become a larger fraction of miner revenue — and the incentive to fee-snipe grows.

Use the slider to move through halving epochs and watch the security budget shift.

⚙ interactive visualization — coming to this page format soon

Notice: Drag the halving slider to the right. The blue bar (subsidy) shrinks dramatically while the orange bar (fees) stays the same or grows. The point where fees rival the subsidy is exactly when fee sniping becomes economically attractive.

IIIVisualization 2: Mine Forward vs. Remine the Tip

A rational miner has a choice at the chain tip:

Use the sliders to explore: when does remining become profitable?

⚙ interactive visualization — coming to this page format soon

Reflect: With today's subsidy (~3.125 BTC), how much would mempool fees need to spike before remining becomes profitable? Now drop the subsidy to 0.1 BTC (a far-future halving). How does the picture change?

IVVisualization 3: The nLockTime Defense

Each transaction has a field nLockTime — the earliest block height at which it can be confirmed. Modern wallets set nLockTime = tip + 1.

Pick a transaction's nLockTime and the block height an attacker is trying to mine. The visualization shows whether consensus accepts the transaction in that block.

⚙ interactive visualization — coming to this page format soon

Reflect: Set nLockTime = 100001 (the wallet default when the tip is 100,000). Now try to put that transaction in block 100,000 — exactly what a fee-sniping attacker would attempt. The transaction is rejected. The attacker cannot steal the fresh mempool fees by remining.

VQuiz Questions

Question 1

What does the nLockTime field of a Bitcoin transaction specify?

Correct! nLockTime is a floor, not a ceiling — it's the minimum height for the transaction to be valid.

Not quite. nLockTime defines the earliest (minimum) block height — it's a lower bound on when the tx can be confirmed.

Show solution

Solution:

nLockTime specifies the earliest block height at which a transaction is valid. If nLockTime = 100001, then the transaction can be included in block 100,001 or any later block, but not in block 100,000 or earlier.

Wallets exploit this for anti-fee-sniping by setting nLockTime = tip + 1. Under normal forward progress, this is invisible — the transaction was going into the next block anyway. But if an attacker tries to remine the current tip, the transaction's nLockTime makes it ineligible for that older block.

Question 2

True or False: Anti-fee-sniping (setting nLockTime = tip + 1) completely prevents miners from reorganizing the blockchain.

Correct! nLockTime doesn't prevent reorgs — it just removes the fee incentive for shallow ones.

Not quite. The defense is narrower than that. Re-read the script's nuance section.

Show solution

Solution: False.

Anti-fee-sniping does not prevent reorgs in general. Miners can still rewrite blocks — they retain whatever mining power they have. What nLockTime removes is the economic incentive for shallow reorgs by making the newest, juiciest mempool transactions ineligible for the older block being remined.

The attacker can still attempt to remine, but they can't scoop up the highest-fee transactions broadcast since the tip was found. With the subsidy still dominating revenue today, this kills any rational motive for fee-sniping reorgs.

Question 3

The chain tip is at block 100,000, which contained 0.05 BTC in fees. Since then, the mempool has filled with high-fee transactions totaling 0.40 BTC. The subsidy is 3.125 BTC.

An attacker considers remining block 100,000 with the new mempool transactions, forfeiting the chance to mine block 100,001. What is their net gain (or loss) compared to honestly mining forward?

Correct! The extra 0.35 BTC in fees is nowhere near enough to offset forfeiting a 3.125 BTC subsidy.

Not quite. Remember: by remining, the attacker keeps one subsidy but gives up the chance to mine the next block. The opportunity cost is a full subsidy.

Show solution

Solution:

Compare the two options:

  • Mine forward (honest): earn subsidy + new mempool fees = 3.125+0.40=3.5253.125 + 0.40 = 3.525 BTC
  • Remine the tip: earn one subsidy + new mempool fees = 3.125+0.40=3.5253.125 + 0.40 = 3.525 BTC, but they forfeit mining block 100,001 (skipping the next subsidy).

Net comparison vs. honest mining: Net gain=(extra fees gained)(forfeited subsidy)\text{Net gain} = (\text{extra fees gained}) - (\text{forfeited subsidy}) =(0.400.05)3.125=0.353.125=2.775 BTC= (0.40 - 0.05) - 3.125 = 0.35 - 3.125 = -2.775 \text{ BTC}

The attacker loses 2.775 BTC compared to mining forward. This is exactly why fee sniping is uneconomic today — the subsidy dwarfs any plausible fee differential.

Question 4

Why is anti-fee-sniping considered a preemptive defense rather than one solving a problem that exists today?

Correct! It's a defense for a future where fees, not subsidy, dominate miner revenue.

Not quite. Think about how miner incentives change as the subsidy halves over time.

Show solution

Solution:

Bitcoin's subsidy halves every ~4 years: 50 → 25 → 12.5 → 6.25 → 3.125 → ... approaching zero. Once the subsidy is small relative to fees, the math flips:

  • Today: Skipping a 3.125 BTC subsidy to grab maybe 0.3 BTC extra fees is a clear loss.
  • Future: When the subsidy is, say, 0.1 BTC and fees are 2 BTC, remining the tip to capture better mempool fees becomes profitable.

That's the moment fee sniping transitions from theoretical to tempting. Anti-fee-sniping is built into wallets now, decades early, so the protocol's incentive structure is already protected when the security budget shifts from subsidy-dominated to fee-dominated.

Solved: 0 / 4