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.
This commit is contained in:
Andrew Chow 2022-11-30 10:48:05 -05:00
parent c6e7f224c1
commit 3eb041f014

View file

@ -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) {