<p>I'm trying to clear up some uncertainties around the mempool</p>

<p>A tx comes in, its validated, and no other transactions have currently marked any of its inputs. Tx gets added to mempool.</p>

<p>If a double spend comes in (i.e a tx that uses any marked inputs it is discarded, maybe we mark it as a double spend attempt.</p>

<p>If a block is committed, any txs in the mempool referencing spent inputs are removed from the mempool. If the Tx being removed is not equivalent to the one being added that Tx is marked as an orphan (if you wanted tx orphan tracking)</p>

<p>If a block is rolled back, consumed unspents are restored, tx is added back into mempool as unconfirmed. </p>

<p>Is that roughly correct? I feel like there are some edge cases around mempool and block roll back that this doesn't address.</p>

CC BY-SA 3.0
2015-06-22T23:34:27.307Z
Transactions spending outputs already spent by another transaction in the mempool are just rejected.
Claris
CC BY-SA 3.0
2015-06-23T07:37:28.677Z
@Bitcoin: Bitcoin-XT apparently collects them and marks them as a double spend attempt.
Murch
CC BY-SA 3.0
2015-06-23T18:39:58.053Z
@Murch Just an FYI, Tom Harding's patches (as incorporated into Bitcoin XT and also Bitcoin Core for a very short time) not only track double spend attempts and notify the user if appropriate, they relay them to other nodes so that others are also aware of them (assuming of course the double-spend isn't sent directly to a miner which doesn't do double-spend relaying).
Christopher Gurnee
<bitcoin-core><utxo><mempool><chain-reorganization>
Mempool tracking
Matt
# Mempool tracking

(Asked by: username_0 on 2015-06-22)

I'm trying to clear up some uncertainties around the mempool

A tx comes in, its validated, and no other transactions have currently marked any of its inputs. Tx gets added to mempool.

If a double spend comes in (i.e a tx that uses any marked inputs it is discarded, maybe we mark it as a double spend attempt.

If a block is committed, any txs in the mempool referencing spent inputs are removed from the mempool. If the Tx being removed is not equivalent to the one being added that Tx is marked as an orphan (if you wanted tx orphan tracking)

If a block is rolled back, consumed unspents are restored, tx is added back into mempool as unconfirmed.

Is that roughly correct? I feel like there are some edge cases around mempool and block roll back that this doesn't address.

**Tags:** bitcoin-core, utxo, mempool, chain-reorganization

> **Comments:**
> **username_1**: Transactions spending outputs already spent by another transaction in the mempool are just rejected.  
> **username_2**: @Bitcoin: Bitcoin-XT apparently collects them and marks them as a double spend attempt.  
> **username_3**: @username_2 Just an FYI, Tom Harding's patches (as incorporated into Bitcoin XT and also Bitcoin Core for a very short time) not only track double spend attempts and notify the user if appropriate, they relay them to other nodes so that others are also aware of them (assuming of course the double-spend isn't sent directly to a miner which doesn't do double-spend relaying).  

---

## 0 answers

