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.

2 Answers 2


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


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

<txid> from peer=<peer id> was not accepted: <reason>

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.


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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.