<p>Normally bitcoind does not give such notification, but Bitcoind supports connection via ZeroMQ. Mayby by this interface you will get more notification. </p>

CC BY-SA 3.0
2017-06-06T08:15:26.917Z
2017-06-06T08:15:26.917Z
user49723
<p><code>bitcoind</code> has a debugging option named <code>mempoolrej</code>. You can enable this by adding</p>

<pre><code>debug=mempoolrej
</code></pre>

<p>to your bitcoin.conf file.</p>

<p>This debugging options tells <code>bitcoind</code> to print out information about the transactions that it rejects from the mempool, including why. You can thus enable this option and tail and grep the <code>debug.log</code> file looking for the string</p>

<pre><code>was not accepted
</code></pre>

<p>This string is only found in the <code>mempoolrej</code> message which is of the form </p>

<pre><code>&lt;txid&gt; from peer=&lt;peer id&gt; was not accepted: &lt;reason&gt;
</code></pre>

<p>The <code>reason</code> you are looking for is <code>txn-mempool-conflict</code>. So you can tail and grep for the entire string:</p>

<pre><code>was not accepted: txn-mempool-conflict
</code></pre>

<p>Then with some bash-fu you can make this notify you whenever this string is found in the <code>debug.log</code> file.</p>

CC BY-SA 3.0
2018-01-03T04:43:14.467Z
2018-01-03T04:43:14.467Z
Ava Chow
<p>I want to get statistics on how many percentage of unconfirmed tx in the mempool are having attempted double spends and having what value. For this I want to get notification when an unconfirmed tx arrives that is conflicting with existing tx in mempool. I understand that bitcoind will accept the first transaction it sees and reject the next one, can I configure/patch bitcoind to send me notification on such double spend attempt ?</p>

<p>PS: I understand that a double spend can happen by directly including new tx in the next block without ever showing up in unconfirmed tx list. I think that requires direct access to mining pool and enough guarantees that the block will be mined. For my experiment, I am fine with ignoring this case as it has low probability.</p>

<bitcoind><unconfirmed-transactions><doublespend><mempool>
Detecting unconfirmed double spends using bitcoind
dark knight
# Detecting unconfirmed double spends using bitcoind

(Asked by: username_0 on 2017-06-05)

I want to get statistics on how many percentage of unconfirmed tx in the mempool are having attempted double spends and having what value. For this I want to get notification when an unconfirmed tx arrives that is conflicting with existing tx in mempool. I understand that bitcoind will accept the first transaction it sees and reject the next one, can I configure/patch bitcoind to send me notification on such double spend attempt ?

PS: I understand that a double spend can happen by directly including new tx in the next block without ever showing up in unconfirmed tx list. I think that requires direct access to mining pool and enough guarantees that the block will be mined. For my experiment, I am fine with ignoring this case as it has low probability.

**Tags:** bitcoind, unconfirmed-transactions, doublespend, mempool


---

## 2 answers

### Answer by username_2 on 2018-01-03. Score: 4 | Accepted answer

bitcoind has a debugging option named mempoolrej. You can enable this by adding
debug=mempoolrej

to your bitcoin.conf file.
This debugging options tells bitcoind to print out information about the transactions that it rejects from the mempool, including why. You can thus enable this option and tail and grep the debug.log file looking for the string
was not accepted

This string is only found in the mempoolrej message which is of the form 
 from peer= was not accepted: 

The reason you are looking for is txn-mempool-conflict. So you can tail and grep for the entire string:
was not accepted: txn-mempool-conflict

Then with some bash-fu you can make this notify you whenever this string is found in the debug.log file.


---

### Answer by username_1 on 2017-06-06. Score: 0

Normally bitcoind does not give such notification, but Bitcoind supports connection via ZeroMQ. Mayby by this interface you will get more notification.


---

