aboutsummaryrefslogtreecommitdiff
path: root/src/wallet
diff options
context:
space:
mode:
authorAndrew Chow <github@achow101.com>2022-11-30 10:48:05 -0500
committerAndrew Chow <github@achow101.com>2022-12-05 12:59:22 -0500
commit3eb041f014870954db564369a4be4bd0dea48fbe (patch)
treeae8803d401fea8db79a39bb2d6c615a3d2fa5236 /src/wallet
parentc6e7f224c119f47af250a9e0c5b185cb98b30c4c (diff)
downloadbitcoin-3eb041f014870954db564369a4be4bd0dea48fbe.tar.xz
wallet: Change coin selection fee assert to error
Returning an error instead of asserting for the low fee check will be better as it does not crash the node and instructs users to report the bug.
Diffstat (limited to 'src/wallet')
-rw-r--r--src/wallet/spend.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/wallet/spend.cpp b/src/wallet/spend.cpp
index 8c0d56a1cb..178b5ff395 100644
--- a/src/wallet/spend.cpp
+++ b/src/wallet/spend.cpp
@@ -940,7 +940,9 @@ static util::Result<CreatedTransactionResult> CreateTransactionInternal(
// The only time that fee_needed should be less than the amount available for fees is when
// we are subtracting the fee from the outputs. If this occurs at any other time, it is a bug.
- assert(coin_selection_params.m_subtract_fee_outputs || fee_needed <= nFeeRet);
+ if (!coin_selection_params.m_subtract_fee_outputs && fee_needed > nFeeRet) {
+ return util::Error{Untranslated(STR_INTERNAL_BUG("Fee needed > fee paid"))};
+ }
// If there is a change output and we overpay the fees then increase the change to match the fee needed
if (nChangePosInOut != -1 && fee_needed < nFeeRet) {