Skip to content

Commit 3eb041f

Browse files
committed
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.
1 parent c6e7f22 commit 3eb041f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/wallet/spend.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,9 @@ static util::Result<CreatedTransactionResult> CreateTransactionInternal(
940940

941941
// The only time that fee_needed should be less than the amount available for fees is when
942942
// we are subtracting the fee from the outputs. If this occurs at any other time, it is a bug.
943-
assert(coin_selection_params.m_subtract_fee_outputs || fee_needed <= nFeeRet);
943+
if (!coin_selection_params.m_subtract_fee_outputs && fee_needed > nFeeRet) {
944+
return util::Error{Untranslated(STR_INTERNAL_BUG("Fee needed > fee paid"))};
945+
}
944946

945947
// If there is a change output and we overpay the fees then increase the change to match the fee needed
946948
if (nChangePosInOut != -1 && fee_needed < nFeeRet) {

0 commit comments

Comments
 (0)