<p>Spending the whole balance of the wallet will always fail, because you cannot assign the whole balance to an output and pay a fee at the same time. There are two ways to sidestep this issue:</p>
<ul>
<li>Instruct <code>sendtoaddress</code> to send the whole balance to one of your own addresses, but to take the fee out of the recipient amount per the <code>subtractfeefromamount</code> argument (on <code>send</code> it's called <code>subtract_fee_from_outputs</code> and you need to indicate which output to take from). Be sure to pick a sufficient feerate¹ to bump the parent transaction.</li>
<li>[Not recommended:] Manually calculate the fee you wish to pay and create a transaction with <code>sendrawtransaction</code> that sends <code>balance - fee</code> to a new address in your wallet. Be sure to inspect the transaction before submitting it, manually building transactions has often led to people accidentally sending too much fees.</li>
</ul>
<p>¹Bitcoin Core has a known issue where it will treat all UTXOs as though they have been confirmed for the purpose of fee calculation. When using an unconfirmed UTXO created by a transaction with a lower feerate, Bitcoin Core will not account for the necessary bump fees to achieve the intended target feerate for the child transaction. You therefore need to choose a higher feerate than where you would actually like to queue the child transaction in order to reprioritize the parent transaction. There is ongoing work to fix this issue and automatically bump unconfirmed ancestor transactions to the requested feerate in PR <a href="https://github.com/bitcoin/bitcoin/pull/26152" rel="nofollow noreferrer">#26152</a>.</p>

CC BY-SA 4.0
2022-12-12T16:15:47.100Z
2023-01-06T15:22:27.013Z
2023-01-06T15:22:27.013Z
Murch
<p>I have a Bitcoin Core wallet which has a utxo which I spent from, in a transaction where around 1% was sent to an external wallet address, with the ~99% change output remaining in the wallet, sent to a new internal change address selected by core.</p>
<p>The fee used turned out to be too low and I am still waiting for the transaction to be confirmed, and now when I attempt to spend using the balance that is displayed in the wallet (with <code>getbalance</code> endpoint), I am told there is &quot;Insufficient funds.&quot;.</p>
<p>But when I list the wallet utxos with <code>listunspent</code>, &quot;spendable&quot; has value true for the change output mentioned above - this is what I expected since my understanding is the core wallet by default will use CFPF to still spend an unconfirmed change output (please correct me if this is wrong).</p>
<p>My question is:
Why does the output listed by <code>listunspent</code> indicate that the output is 'spendable', when if I try to spend the output, it fails with an 'Insufficient funds' error?</p>
<p>Is there another reason for the wallet complaining that there is insufficient funds? Probably relevant is that it was an opt-in RBF tx, and I have already tried bumping the fee (still too low and not confirmed) but now would prefer to use CPFP as I have another transaction that I would like to make from the same unconfirmed change output.</p>

CC BY-SA 4.0
2020-11-25T21:58:28.643Z
I think you should try CPFP not using your Bitcoin Core. Sounds like the wallet application is locking that balance rather than it actually being unspendable. Something like this will clear it quickly - https://steemit.com/cryptocurrency/@coincircus/how-to-confirm-a-stuck-transaction-using-child-pays-for-parent-cpfp-the-easy-way
user1202278
CC BY-SA 4.0
2020-11-26T14:09:54.553Z
Really useful resource - thanks. To do this all within Bitcoin Core, would the way to do that be with the `createrawtransaction` RPC or using another method?
qmux
CC BY-SA 4.0
2020-11-27T16:22:57.650Z
That would only be part of it, you would still then have to `sign` the raw transaction (`signrawtransaction`) with your priv key and broadcast it (`sendrawtransaction`). http://coinb.in is quite a good resource for this with a GUI
user1202278
<bitcoin-core><unconfirmed-transactions><bitcoin-cli><replace-by-fee>
Can a 0 confirmation Bitcoin Core change output be spent?
qmux
# Can a 0 confirmation Bitcoin Core change output be spent?

(Asked by: username_0 on 2020-11-25)

I have a Bitcoin Core wallet which has a utxo which I spent from, in a transaction where around 1% was sent to an external wallet address, with the ~99% change output remaining in the wallet, sent to a new internal change address selected by core.

The fee used turned out to be too low and I am still waiting for the transaction to be confirmed, and now when I attempt to spend using the balance that is displayed in the wallet (with `getbalance` endpoint), I am told there is "Insufficient funds.".

But when I list the wallet utxos with `listunspent`, "spendable" has value true for the change output mentioned above - this is what I expected since my understanding is the core wallet by default will use CFPF to still spend an unconfirmed change output (please correct me if this is wrong).

My question is:
Why does the output listed by `listunspent` indicate that the output is 'spendable', when if I try to spend the output, it fails with an 'Insufficient funds' error?

Is there another reason for the wallet complaining that there is insufficient funds? Probably relevant is that it was an opt-in RBF tx, and I have already tried bumping the fee (still too low and not confirmed) but now would prefer to use CPFP as I have another transaction that I would like to make from the same unconfirmed change output.

**Tags:** bitcoin-core, unconfirmed-transactions, bitcoin-cli, replace-by-fee

> **Comments:**
> **username_1**: I think you should try CPFP not using your Bitcoin Core. Sounds like the wallet application is locking that balance rather than it actually being unspendable. Something like this will clear it quickly - https://steemit.com/cryptocurrency/@coincircus/how-to-confirm-a-stuck-transaction-using-child-pays-for-parent-cpfp-the-easy-way  
> **username_0**: Really useful resource - thanks. To do this all within Bitcoin Core, would the way to do that be with the `createrawtransaction` RPC or using another method?  
> **username_1**: That would only be part of it, you would still then have to `sign` the raw transaction (`signrawtransaction`) with your priv key and broadcast it (`sendrawtransaction`). http://coinb.in is quite a good resource for this with a GUI  

---

## 1 answers

### Answer by username_2 on 2022-12-12. Score: 1

Spending the whole balance of the wallet will always fail, because you cannot assign the whole balance to an output and pay a fee at the same time. There are two ways to sidestep this issue:

* Instruct `sendtoaddress` to send the whole balance to one of your own addresses, but to take the fee out of the recipient amount per the `subtractfeefromamount` argument (on `send` it's called `subtract_fee_from_outputs` and you need to indicate which output to take from). Be sure to pick a sufficient feerate¹ to bump the parent transaction.
* [Not recommended:] Manually calculate the fee you wish to pay and create a transaction with `sendrawtransaction` that sends `balance - fee` to a new address in your wallet. Be sure to inspect the transaction before submitting it, manually building transactions has often led to people accidentally sending too much fees.

¹Bitcoin Core has a known issue where it will treat all UTXOs as though they have been confirmed for the purpose of fee calculation. When using an unconfirmed UTXO created by a transaction with a lower feerate, Bitcoin Core will not account for the necessary bump fees to achieve the intended target feerate for the child transaction. You therefore need to choose a higher feerate than where you would actually like to queue the child transaction in order to reprioritize the parent transaction. There is ongoing work to fix this issue and automatically bump unconfirmed ancestor transactions to the requested feerate in PR [#26152](https://github.com/bitcoin/bitcoin/pull/26152).


---

