← Socratic Seminar #52 ← → or space to navigate

Bitcoin Core #36040 · merged 2026-11-20

Don't backdate the locktime when bumping fees

A random privacy feature could give a fee bump an older locktime than the transaction it replaces. No natural wallet does that, so it marked the replacement as made by Bitcoin Core or Electrum.

Author: Bicaru20 · Fixes #26526 (0xB10C, 2022) · github.com/bitcoin/bitcoin/pull/36040

Background

Anti-fee-sniping sets nLockTime to the tip

  • Core sets each new transaction's nLockTime to the current block height, so it can only be mined in the next block. That makes re-mining the last block to steal its fees (fee sniping) less attractive.
  • 10% of the time it backdates the locktime by a random 0 to 99 blocks, so transactions that are signed and broadcast later (high-latency mixnets, some CoinJoins) don't stand out.
  • Electrum does something similar.
  • Problem: bumpfee builds the replacement as a fresh transaction, and rolls the dice again.

The fingerprint

The replacement can land below the original

Block height number line. Original tx A has locktime 1000. Before the fix, the replacement B created at height 1002 could be backdated anywhere from 903 to 1002, e.g. 962, below A. After the fix it is limited to 1000 to 1002. Before B's locktime is drawn from tip − 99 … tip, ignoring A ← range starts at 903 A lock 1000 B lock 962 B.locktime < A.locktime → only Core/Electrum do this After A's locktime becomes the floor (minimum_height) A lock 1000 B 1000–1002 9409609801000 tip 1002

Example: A was signed at height 1000; the bump happens at 1002. Heights are illustrative.

How common?

Rare, which is exactly why it identifies you

1,000,000+

RBF replacements in the PR's dataset, 2025-05-01 to 2026-06-01.

~200–300 a week

Replacements with a locktime lower than the transaction they replaced.

< 2%

Of all replaced transactions, on average. Few enough that each one points to a Core or Electrum bumpfee.

Reported by 0xB10C in issue #26526 (Nov 2022), with a matching Electrum issue #8073.

The fix

Pass the old locktime in as a floor

// src/wallet/feebumper.cpp · CreateRateBumpTransaction()
+    new_coin_control.m_minimum_locktime = tx->nLockTime;

// src/wallet/spend.cpp · DiscourageFeeSniping(..., minimum_height)
-        if (rng_fast.randrange(10) == 0) {
-            tx.nLockTime = std::max(0, int(tx.nLockTime) - int(rng_fast.randrange(100)));
+        if (rng_fast.randrange(10) == 0 && tx.nLockTime > minimum_height) {
+            int range = std::min(100, int(block_height - static_cast<int>(minimum_height) + 1));
+            tx.nLockTime = int(tx.nLockTime) - int(rng_fast.randrange(range));
  • The 10% backdating roll stays, but the result never goes below the original's locktime; if the original was at the tip, there's no room to backdate.
  • Only bumpfee sets the floor; every other send passes 0 and behaves exactly as before.

Edge cases

Keeping the other fingerprints constant

Wallet not synced

Previously locktime 0. Now it uses the floor, so a bump never goes below the original, and normal sends still get a constant 0.

Floor above our tip

If the original's locktime is ahead of our lagging node, use 0, so the tx stays final and doesn't reveal how far behind we are.

Tested bounds

A new unit test checks backdated locktimes always stay within 99 blocks of the tip and never below the floor.

Discussion

Questions for the room

  • The issue sat open for four years. How many other wallet fingerprints are hiding in RBF behavior (fee steps, input order, change position)?
  • Does random backdating still buy privacy, now that every replacement keeps a floor?
  • Electrum has the same behavior. Should wallets coordinate on one anti-fee-sniping policy?
  • Is anti-fee-sniping still worth it while the subsidy dominates block rewards?