From 3eb041f014870954db564369a4be4bd0dea48fbe Mon Sep 17 00:00:00 2001 From: Andrew Chow Date: Wed, 30 Nov 2022 10:48:05 -0500 Subject: [PATCH] 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. --- src/wallet/spend.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/wallet/spend.cpp b/src/wallet/spend.cpp index 8c0d56a1cb0..178b5ff395a 100644 --- a/src/wallet/spend.cpp +++ b/src/wallet/spend.cpp @@ -940,7 +940,9 @@ static util::Result 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) {