diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -3132,10 +3132,6 @@ // to meet nFeeNeeded result in a transaction that requires less // fee than the prior iteration. - // TODO: The case where nSubtractFeeFromAmount > 0 remains to be - // addressed because it requires returning the fee to the payees - // and not the change output. - // If we have no change and a big enough excess fee, then try to // construct transaction again only without picking new inputs. // We now know we only need the smaller fee (because of reduced @@ -3169,7 +3165,9 @@ break; } else if (!pick_new_inputs) { // This shouldn't happen, we should have had enough excess fee - // to pay for the new output and still meet nFeeNeeded + // to pay for the new output and still meet nFeeNeeded. + // Or we should have just subtracted fee from recipients and + // nFeeNeeded should not have changed. strFailReason = _("Transaction fee and change calculation failed"); return false; @@ -3191,6 +3189,12 @@ } } + // If subtracting fee from recipients, we now know what fee we + // need to subtract, we have no reason to reselect inputs. + if (nSubtractFeeFromAmount > 0) { + pick_new_inputs = false; + } + // Include more fee and try again. nFeeRet = nFeeNeeded; continue;