Using Bitcoind and Json-RPC, how to remove an unconfirmed transaction from the memory pool?

The scenario being removing the unconfirmed transaction because it's not getting confirmed, and it's preventing me from sending new transactions spending the same inputs because Bitcoind considers it a double spend.


As befits its name, the memory pool is kept in the process's memory. So if you quit and restart bitcoind, the memory pool will be cleared.

However, this may not fix your problem; unconfirmed transactions relating to your own wallet addresses are stored not only in the memory pool, but in wallet.dat, so a restart won't clear them. To accomplish that, you can start bitcoind with the recently added -zapwallettxes option. This will cause bitcoind to forget all transactions associated to your addresses, and rescan the block chain to reconstruct them. In particular, any unconfirmed transactions will be forgotten and not reconstructed.

Note that you will have to have waited long enough that other nodes on the network are no longer keeping your unconfirmed transaction in their own memory pools. If they are, then (1) they might send it back to you, defeating the purpose of this exercise, and (2) if you try to send a new transaction to replace the unconfirmed one, they may reject it as a double spend.

| improve this answer | |
  • Running this command bitcoind just sits there... how long should it take? – Serj Sagan Jun 15 '16 at 8:14
  • @SerjSagan: Bitcoind is a daemon, it runs in the background. It's supposed to just sit there and respond to commands issued with bitcoin-cli. If you want an interactive program, use bitcoin-qt. – Nate Eldredge Jun 15 '16 at 15:15
  • That doesn't answer my question about how long the -zapwallettxes part should take... I left it on for 24 hours and that seemed to do it. – Serj Sagan Jun 16 '16 at 2:41

Try the removeprunedfunds RPC command. It

deletes the specified transaction from the wallet. … This will effect wallet balances.

| improve this answer | |
  • don't know why you're voted down.. that did it for me – tobi Jun 14 '18 at 9:43

There is no RPC command available to remove objects from the mempool.

| improve this answer | |
  • 1
    outdated reply, see @Geremia's answer – tobi Jun 14 '18 at 10:59

I haven't found a good way to clear just a single transaction from the mempool, but you can shutdown bitcoind and then delete ~/.bitcoin/mempool.dat and clear the entire mempool, and then restart bitcoind

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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