wallet: re-activate “AmountWithFeeExceedsBalance” error #34299

pull stratospher wants to merge 3 commits into bitcoin:master from stratospher:2025_12_fix_amountwithfeeexceedsbalance changing 6 files +74 −21
  1. stratospher commented at 9:06 am on January 15, 2026: 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

    the unreachable code path is removed in https://github.com/bitcoin-core/gui/pull/807 which requires this PR.

  2. wallet: fix, make 'total_effective_amount' optional actually optional
    this is not needed for the remaining commits but good to fix
    and came up in #25269 review.
    
    Co-authored-by: furszy <matiasfurszyfer@protonmail.com>
    c467325aaf
  3. wallet: clarify PreSelectedInputs total_amount
    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.
    af3f3bfd57
  4. wallet: introduce "tx amount exceeds balance when fees are included" error
    This was previously implemented at the GUI level but we never hit that
    code path.
    
    Co-authored-by: furszy <matiasfurszyfer@protonmail.com>
    f66d5bc099
  5. DrahtBot added the label Wallet on Jan 15, 2026
  6. DrahtBot commented at 9:06 am on January 15, 2026: contributor

    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.

  7. furszy commented at 2:48 pm on January 15, 2026: member
    Thanks for picking it up!
  8. furszy commented at 2:16 am on January 21, 2026: member

    q: in af3f3bfd57bf8869030153ecf3695f07ae7dd805, wouldn’t be better to replace PreSelectedInputs for CoinsResult? (and then remove PreSelectedInputs).

    The outputs we add through FetchSelectedInputs can be of type UNKNOWN during the CoinsResult.Add call (their type doesn’t matter, they must be selected anyway).


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-01-22 09:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me