<p>As mentioned in comments: quit bitcoin core and restart it with <code>zapwallettxes</code> flag:</p>

<pre><code>bitcoin-qt.exe -zapwallettxes=1
-or-
bitcoin-qt.exe -zapwallettxes=2
</code></pre>

<p><a href="https://en.bitcoin.it/wiki/Running_Bitcoin" rel="nofollow noreferrer">As per bitcoin wiki</a>:</p>

<blockquote>
  <p>-zapwallettxes=   Delete all wallet transactions and only
  recover those parts of the blockchain through -rescan on startup (1 =
  keep tx meta data e.g. account owner and payment request information,
  2 = drop tx meta data)</p>
</blockquote>

<p>It will take some time to rescan all blocks.</p>

<p><strong>Update:</strong> It did not worked in my case. Transaction stayed in mempool. So I have had to restore older wallet.dat and run full rescan again.</p>

<p><strong>Update2:</strong> Starting from bitcoin core 0.14.0, the <a href="https://bitcoin.stackexchange.com/a/46162/13124">mempool will be saved to disk</a>. So none of above solutions helped in my case. Closing wallet and deleting <code>mempool.dat</code> finally did the job.</p>

CC BY-SA 4.0
2021-03-01T08:12:44.290Z
zapwallettxes has been removed and replaced with "abandontransaction"
Janus Troelsen
CC BY-SA 3.0
2017-05-09T12:48:32.707Z
2017-05-10T09:25:54.473Z
2017-05-10T09:25:54.473Z
Anton Krouglov
<p>As mentioned: double spend it if you still can. And when you do that <strong>dont forget to put a high enough fee</strong> (10 times the auto-calculated one for instance just to be sure, will only be a few cents anyway) so that it jumps the mempool and gets confirmed in the next block.</p>

CC BY-SA 3.0
2016-12-15T15:05:22.823Z
The input had not been spent, so there's no need to double spend. Restarting the client with "-zapwallettxes" is all I needed to do. Thanks!
Buster
CC BY-SA 4.0
2021-02-22T21:55:54.247Z
A "double spend" means to create two transactions using the same unspent input. If the input has been spent, then it is NOT a double spend, it's just an invalid transaction.
Rebroad
CC BY-SA 3.0
2016-12-14T18:33:32.427Z
2016-12-14T18:33:32.427Z
l1b3rty
<p>I did a trick back in the day when I send btc I did not mean to. If you have a backup of your wallet then load this up on a new machine and u can send the coins from that address to another, thus double spending and voiding your initial first transaction. So long as first transaction has not been broardcast then this should be possible.</p>

CC BY-SA 3.0
2016-12-15T15:05:54.143Z
Not relevant in this case, but thanks!
Buster
CC BY-SA 3.0
2016-12-14T17:13:01.227Z
2016-12-14T17:13:01.227Z
Fuzzybear
<p>The best way is to abandon the transaction as zapping the wallet takes a LONG time for the rescan. In order to fool bitcoin into thinking the transaction has not been broadcast, you need to shut down bitcoin-qt, rename mempool.dat to mempool.dat.old, add "walletbroadcast=0" to bitcoin.conf, and re-run bitcoin-qt. Then you can abandon the tx, then you can shutdown bitcoin-qt, rename mempool.dat.old back to mempool.dat and remove the walletbroadcast line from bitcoin.conf.</p>

<p>Given the tx was broadcast (as the error "Transaction not eligible for abandonment (code -5)" means this), there is still some risk that it will make its way into a block, given the valid tx could have been stored somewhere. The only way to ensure it doesn't make it into a block, is to create another transaction using the same input and get this into a block.</p>

<p>Also, see this for an explanation from one of the bitcoin core developers on issues you might encounter with abandoning the transaction: <a href="https://github.com/bitcoin/bitcoin/issues/11060#issuecomment-323124996" rel="nofollow noreferrer">https://github.com/bitcoin/bitcoin/issues/11060#issuecomment-323124996</a></p>

CC BY-SA 4.0
2021-02-21T18:00:20.317Z
The steps outlined here to recoup the unspent/unconfirmed coins in the wallet work as expcected. Unclear on the following, just want a second opinion from anyone who knows. " The only way to ensure it doesn't make it into a block, is to create another transaction using the same input and get this into a block." This means A) the transaction can still be processed from the mempool as it was broadcasted to the network, correct? B) "using the same input" - I'm assuming that this means making a duplicate transaction matching the send to address and amount, just with a higher fee so it can be proce
Greg
CC BY-SA 4.0
2021-02-22T21:45:20.947Z
A) "the mempool" - there is no single mempool - they (transactions) are stored on computers, and can be stored indefinitely.
B) No, the send to address and amount can be different, it's just the input that needs to be made invalid (by making it spent).
Rebroad
CC BY-SA 4.0
2021-04-27T09:56:07.677Z
so the reply to the question A) is yes, there is nothing you can do to be sure that an already broadcast and valid transaction will not included in a block.
leevancleef
CC BY-SA 4.0
2020-05-17T12:01:13.090Z
2020-05-17T12:07:45.090Z
2020-05-17T12:07:45.090Z
Rebroad
<p>In Bitcoin Core, is it possible to cancel a transaction whose status is:</p>

<pre><code>"Status: 0/offline, has not been successfully broadcast yet"
</code></pre>

<p>The client hasn't caught up with the network. It looks like it's going to do that first, and then send the transaction.</p>

<p>Is that right, or is the transaction already irrevocable?</p>

<p>If I can cancel the transaction, what's the best way to do that?</p>

<p>I tried <code>abandontransaction</code> but it gives the error:</p>

<pre><code>Transaction not eligible for abandonment (code -5)
</code></pre>

CC BY-SA 3.0
2016-12-12T21:31:49.620Z
First of all, quit Bitcoin Core.  Disconnect the machine from the Internet to be even safer.  The `-zapwallettxes` option might do what you want, but I am not certain.
Nate Eldredge
CC BY-SA 3.0
2016-12-13T01:40:25.930Z
Could you check if the transaction is confirmed, or if the transaction is in the memory pool (`getrawmempool`) ?
Nick ODell
CC BY-SA 3.0
2016-12-13T01:45:01.397Z
@NickODell, confirmed as in confirmations? It has none. I'll check getrawmempool now.
Buster
CC BY-SA 3.0
2016-12-13T01:46:00.710Z
@Buster confirmed as in confirmations.
Nick ODell
CC BY-SA 3.0
2016-12-13T01:51:56.060Z
@NickODell, getrawmempool shows one transaction, which is the one I'd like to cancel. So `-zapwallettxes`?
Buster
CC BY-SA 3.0
2016-12-13T01:55:11.943Z
Yeah, the transaction in the memory pool is preventing abandontransaction from removing it from your wallet.
Nick ODell
<bitcoin-core><revert-transaction>
Can I cancel a transaction that has not been successfully broadcast yet?
Buster
# Can I cancel a transaction that has not been successfully broadcast yet?

(Asked by: username_0 on 2016-12-12)

In Bitcoin Core, is it possible to cancel a transaction whose status is:

```
"Status: 0/offline, has not been successfully broadcast yet"

```

The client hasn't caught up with the network. It looks like it's going to do that first, and then send the transaction.

Is that right, or is the transaction already irrevocable?

If I can cancel the transaction, what's the best way to do that?

I tried `abandontransaction` but it gives the error:

```
Transaction not eligible for abandonment (code -5)

```

**Tags:** bitcoin-core, revert-transaction

> **Comments:**
> **username_1**: First of all, quit Bitcoin Core.  Disconnect the machine from the Internet to be even safer.  The `-zapwallettxes` option might do what you want, but I am not certain.  
> **username_2**: Could you check if the transaction is confirmed, or if the transaction is in the memory pool (`getrawmempool`) ?  
> **username_0**: @username_2, confirmed as in confirmations? It has none. I'll check getrawmempool now.  
> **username_2**: @username_0 confirmed as in confirmations.  
> **username_0**: @username_2, getrawmempool shows one transaction, which is the one I'd like to cancel. So `-zapwallettxes`?  
> **username_2**: Yeah, the transaction in the memory pool is preventing abandontransaction from removing it from your wallet.  

---

## 4 answers

### Answer by username_3 on 2017-05-09. Score: 0 | Accepted answer

As mentioned in comments: quit bitcoin core and restart it with `zapwallettxes` flag:

```
bitcoin-qt.exe -zapwallettxes=1
-or-
bitcoin-qt.exe -zapwallettxes=2

```

[As per bitcoin wiki](https://en.bitcoin.it/wiki/Running_Bitcoin):

> -zapwallettxes= Delete all wallet transactions and only
> recover those parts of the blockchain through -rescan on startup (1 =
> keep tx meta data e.g. account owner and payment request information,
> 2 = drop tx meta data)

It will take some time to rescan all blocks.

**Update:** It did not worked in my case. Transaction stayed in mempool. So I have had to restore older wallet.dat and run full rescan again.

**Update2:** Starting from bitcoin core 0.14.0, the [mempool will be saved to disk](https://bitcoin.stackexchange.com/a/46162/13124). So none of above solutions helped in my case. Closing wallet and deleting `mempool.dat` finally did the job.

> **Comments:**
> **username_4**: zapwallettxes has been removed and replaced with "abandontransaction"  

---

### Answer by username_5 on 2016-12-14. Score: 1

As mentioned: double spend it if you still can. And when you do that **dont forget to put a high enough fee** (10 times the auto-calculated one for instance just to be sure, will only be a few cents anyway) so that it jumps the mempool and gets confirmed in the next block.

> **Comments:**
> **username_0**: The input had not been spent, so there's no need to double spend. Restarting the client with "-zapwallettxes" is all I needed to do. Thanks!  
> **username_6**: A "double spend" means to create two transactions using the same unspent input. If the input has been spent, then it is NOT a double spend, it's just an invalid transaction.  

---

### Answer by username_7 on 2016-12-14. Score: 1

I did a trick back in the day when I send btc I did not mean to. If you have a backup of your wallet then load this up on a new machine and u can send the coins from that address to another, thus double spending and voiding your initial first transaction. So long as first transaction has not been broardcast then this should be possible.

> **Comments:**
> **username_0**: Not relevant in this case, but thanks!  

---

### Answer by username_6 on 2020-05-17. Score: 0

The best way is to abandon the transaction as zapping the wallet takes a LONG time for the rescan. In order to fool bitcoin into thinking the transaction has not been broadcast, you need to shut down bitcoin-qt, rename mempool.dat to mempool.dat.old, add "walletbroadcast=0" to bitcoin.conf, and re-run bitcoin-qt. Then you can abandon the tx, then you can shutdown bitcoin-qt, rename mempool.dat.old back to mempool.dat and remove the walletbroadcast line from bitcoin.conf.

Given the tx was broadcast (as the error "Transaction not eligible for abandonment (code -5)" means this), there is still some risk that it will make its way into a block, given the valid tx could have been stored somewhere. The only way to ensure it doesn't make it into a block, is to create another transaction using the same input and get this into a block.

Also, see this for an explanation from one of the bitcoin core developers on issues you might encounter with abandoning the transaction: <https://github.com/bitcoin/bitcoin/issues/11060#issuecomment-323124996>

> **Comments:**
> **username_8**: The steps outlined here to recoup the unspent/unconfirmed coins in the wallet work as expcected. Unclear on the following, just want a second opinion from anyone who knows. " The only way to ensure it doesn't make it into a block, is to create another transaction using the same input and get this into a block." This means A) the transaction can still be processed from the mempool as it was broadcasted to the network, correct? B) "using the same input" - I'm assuming that this means making a duplicate transaction matching the send to address and amount, just with a higher fee so it can be proce  
> **username_6**: A) "the mempool" - there is no single mempool - they (transactions) are stored on computers, and can be stored indefinitely. B) No, the send to address and amount can be different, it's just the input that needs to be made invalid (by making it spent).  
> **username_9**: so the reply to the question A) is yes, there is nothing you can do to be sure that an already broadcast and valid transaction will not included in a block.  

---

