Bitcoin's Quiet Defense Against Miners Rewriting History

You're a miner. A block just landed with 3 BTC worth of fees inside it, and your hardware is already humming through the next candidate. The math surfaces unbidden: ignore that block, remine it, claim those fees yourself. No theft, no hack. Just incentives following their own cold logic. So why don't you?

The short answer is anti-fee-sniping. The longer answer is one of Bitcoin's more elegant pieces of game theory, baked quietly into wallet software that most users will never think about once.

The Attack That Doesn't Happen Much (But Could)

Fee sniping is the attack where a miner, instead of building on the current chain tip, deliberately remines a recent block to capture its transaction fees. If block 850,000 contained unusually high fees, a miner with enough hashrate might calculate that reorging it is worth the candle.

The economics are brutally simple. Honest mining on block 850,001 earns whatever fees are in the mempool right now, plus the block subsidy. Fee sniping on block 850,000 earns those same fees plus the fees from that earlier block, plus the subsidy. If the fee differential is large enough and your hashrate is high enough, the attack looks rational.

It compounds. A miner could theoretically reorg two or three blocks back, hoovering up fees from each. The deeper the reorg, the harder it gets, but the reward scales up accordingly. This is not a theoretical edge case dreamed up by academics. It is a live incentive that gets more dangerous as the block subsidy shrinks across successive halvings and fees make up a larger fraction of miner revenue. I think most casual observers badly underestimate how seriously this trajectory should be taken.

How Wallets Quietly Tilt the Table

Anti-fee-sniping is a countermeasure built into transaction construction, not the consensus rules themselves. The mechanism operates through a single transaction field.

Every Bitcoin transaction contains a field called `nLocktime`. Normally it sits at zero, meaning the transaction can be included in any block. Wallets that implement anti-fee-sniping set `nLocktime` to the current block height. A transaction broadcast when the chain is at block 850,000 gets `nLocktime` set to 850,000.

Result: the transaction becomes invalid in any block below height 850,001.

A miner trying to reorg block 850,000 and stuff it with fresh mempool transactions hits a wall. Every modern, properly-constructed transaction refuses to go in. The reorged block can only contain older transactions with `nLocktime` values low enough to be valid at that height, and those transactions are already confirmed, already spent. The reorged block is nearly empty, a husk.

An empty block earns only the subsidy. The entire fee advantage evaporates.

So the miner runs the numbers again. Honest mining on block 850,001: subsidy plus current mempool fees. Fee sniping on block 850,000: subsidy only, minus the opportunity cost of every gigahash burned on the reorg. The attack goes from attractive to obviously losing.

A Worked Scenario

Suppose two miners, call them Rashida and Tomas, both run significant operations. A block lands at height 850,000 with an unusually high fee total, 2 BTC above the typical average, because a batch of high-priority institutional transactions cleared together.

Tomas notices and considers the reorg. His pool controls roughly 8% of global hashrate. To have a 50% chance of mining two blocks in a row faster than the rest of the network mines one, he'd need something close to 50% of hashrate, which he doesn't have. Setting the probability problem aside entirely, when he models the transaction set available for his reorged block 850,000, the mempool is full of transactions locked to height 850,000 or above. His reorged block would be nearly empty. He'd earn one subsidy instead of two subsidies plus two blocks of fees. He mines forward.

Rashida, on the same network, doesn't even run the numbers. Her wallet software has been setting `nLocktime` correctly on every transaction she has ever broadcast. She has no idea anti-fee-sniping exists.

That's the point.

The Small Randomness Trick

There's a subtlety worth knowing. If every wallet set `nLocktime` to exactly the current block height, all transactions would carry an identical fingerprint. Blockchain analysts could trivially distinguish modern wallets from older ones, or cluster transactions by software. A real privacy leak.

So implementations like Bitcoin Core introduce a small random offset. Roughly 10% of the time, `nLocktime` is set to current height minus one, two, or three blocks rather than the exact current height. The security guarantee weakens only marginally: a miner would need to go four or more blocks back to find a mempool of unprotected transactions, at which point the required hashrate makes the attack prohibitively expensive regardless of fee incentives. The privacy benefit is genuine. Your transaction looks less like a machine-stamped artifact, more like noise.

If you pull up a transaction you've broadcast from a modern wallet and see an `nLocktime` value matching the recent block height give or take a few, that's exactly what you're looking at.

The Honest Caveat

Anti-fee-sniping is not a hard consensus rule. Nodes won't reject a transaction with `nLocktime` set to zero. The protection works because wallets choose to implement it, and because enough of them do to make the attack unprofitable in practice. A wallet that ignores the convention doesn't break the network. It just contributes a few transactions that a fee-sniper could theoretically use as filler.

The attack becomes more dangerous over time, not less. As Bitcoin's block subsidy continues halving, fees will eventually dominate miner revenue. A block containing 10 BTC in fees is a far more tempting reorg target than one containing 0.1 BTC. Anti-fee-sniping is doing more work in the background with every passing epoch, and the ecosystem's reliance on widespread wallet adoption of this convention will only grow.

Think of it less like a lock and more like a levy wall, holding not because the concrete is impenetrable but because enough people agreed to build it in the same place.

Most of Bitcoin's security works this way: not a single barrier but a layered accumulation of incentives, each one making the attack slightly less worth attempting. Anti-fee-sniping is one quiet layer. It has never announced itself, and it doesn't need to.