Skip to content

Conversation

@stratospher
Copy link
Contributor

picks up #25269.

AmountWithFeeExceedsBalance error inside WalletModel::prepareTransaction is never thrown and remains an unused code path. This is because createTransaction does not retrieve the fee when the process fails. The fee return arg is set only at the end of the process, when the transaction is successfully created. Therefore, if the transaction creation fails, the fee is not available inside WalletModel::prepareTransaction to trigger the AmountWithFeeExceedsBalance error.

This PR re-implements the feature inside CreateTransactionInternal and adds test coverage for it.

on master on PR
Insufficient funds AmountWithFeeExceedsBalance

the unreachable code path is removed in bitcoin-core/gui#807 which requires this PR.

stratospher and others added 3 commits January 15, 2026 09:32
this is not needed for the remaining commits but good to fix
and came up in bitcoin#25269 review.

Co-authored-by: furszy <matiasfurszyfer@protonmail.com>
using total_amount variable to store either the actual total
amount or effective total amount based on whether SFFO is enabled
is confusing. keep this SFFO-based functionality in a separate
function GetTotal() and store both total_amount and effective
total amount separately.

without this when SFFO is not there, available_balance in the
next commit would yield inconsistent result:
- effective amount of preset_inputs summed with
- total amount of available_coins.
…error

This was previously implemented at the GUI level but we never hit that
code path.

Co-authored-by: furszy <matiasfurszyfer@protonmail.com>
@DrahtBot
Copy link
Contributor

DrahtBot commented Jan 15, 2026

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage & Benchmarks

For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/34299.

Reviews

See the guideline for information on the review process.
A summary of reviews will appear here.

Copy link
Member

@furszy furszy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for picking it up!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants