2817 | @@ -2820,6 +2818,12 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CWalletT
2818 | }
2819 | }
2820 |
2821 | + // If subtracting fee from recipients, we now know what fee we
2822 | + // need to subtract, we have no reason to reselect inputs
2823 | + if (nSubtractFeeFromAmount && nFeeRet == 0) {
Nit, nSubtractFeeFromAmount > 0.
nFeeRet == 0 should not be necessary? So the first iteration should have enough inputs for when nSubtractFeeFromAmount > 0, or am I missing something?
Actually, because of
// Never create dust outputs; if we would, just
// add the dust to the fee.
if (IsDust(newTxOut, discard_rate))
{
nChangePosInOut = -1;
nFeeRet += nChange;
}
nFeeRet can be > 0, and in that case there is no need to pick new inputs too.
Good catch. The nFeeRet == 0 check wasn't really doing anything useful anyway, because pick_new_inputs doesn't ever get reset to true. But the prior check that I edited the comment on asserts that we are always on our final pass if pick_new_inputs is false.