THAMER
Sovereign Bitcoin Wallet

WALLET AI BITCOIN

Your Bitcoin Wallet. Your Keys. Your Engine.

Self-hosted Bitcoin software built for developers, applications, and AI agents.

CREATE WALLET

Bitcoin Mempool Conflicts: Double Spends, Replacement Detection, and Payment State

permalink THAMER
#bitcoin#conflicts#double-spend#mempool#rbf

A Bitcoin outpoint identifies one previously created transaction output. Two transactions that spend the same outpoint conflict: they cannot both become part of the same valid chain history. Before confirmation, however, different peers may see different candidates. This makes mempool observation useful but inherently provisional.

Where conflicts arise

A sender may create a higher-fee replacement to accelerate confirmation. The replacement may preserve the payment output, change the payment output, or omit it. A wallet may also accidentally rebroadcast competing transactions after a restore or coin-selection error. Observers cannot infer benign intent merely from an increased fee.

An individual Bitcoin node usually does not retain every conflicting candidate in its mempool. Its local policy determines which transaction, if any, is accepted. A node may first see transaction A while another peer sees transaction B. This divergence is not a consensus failure: the eventual valid block determines the confirmed spend on the active chain.

Observe outpoints, not only transaction IDs

A payment system that watches only the original TXID may miss a replacement. Track the expected recipient script and amount, the input outpoints when available, the original TXID, and subsequent observed transactions. When a conflict appears, reassess whether the expected output is still present and whether the received amount satisfies the invoice.

A replacement transaction can create an equivalent payment output but have a different TXID. Equally, a transaction can have a higher fee while eliminating the merchant's output. Do not mark a payment successful just because a replacement was accepted by a local node.

A practical payment state model

Use distinct states such as seen_unconfirmed, conflicted, confirmed, and reorg_pending. A seen_unconfirmed event means only that a transaction was observed by the monitoring system. It does not prove settlement. A conflicted state signals that the observed payment may no longer be the candidate most likely to confirm.

When a block arrives, verify the relevant transaction against the active chain and update the state. After a reorganization, re-evaluate confirmations and UTXO spends. Avoid irreversible fulfillment based solely on an event emitted by a single mempool observer unless the business explicitly accepts that exposure.

Policy and operational caveats

Local mempool eviction is not the same as a confirmed double spend. A transaction may disappear because of expiry, feerate pressure, node restart, or other local conditions. Likewise, a replacement accepted by one node is not necessarily propagated everywhere.

For debugging, inspect getmempoolentry, getrawmempool, getrawtransaction where available, and the transaction's chain status. Bitcoin Core versions differ in RPC fields and replacement behavior; validate against the deployed release.

Primary references

BIP125 — Opt-in Full Replace-by-Fee Signaling: https://github.com/bitcoin/bips/blob/master/bip-0125.mediawiki

Bitcoin Core RPC reference: https://bitcoincore.org/en/doc/

Questions & Answers

Explore all questions →

Latest from the Lab

THAMER illustrated developer portrait and signature

ABOUT THE DEVELOPER

Independent Software Developer specializing in Bitcoin Script, Golang, and AI Agents.

Software engineering · Independent research · Open-source projects