Skip to content

Commit 6171826

Browse files
committed
Don't create change at the dust limit, even if it means paying more than expected
1 parent 228c319 commit 6171826

File tree

2 files changed

+4
-29
lines changed

2 files changed

+4
-29
lines changed

src/qt/coincontroldialog.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -524,13 +524,10 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
524524
CTxOut txout(nChange, (CScript)std::vector<unsigned char>(24, 0));
525525
if (IsDust(txout, ::dustRelayFee))
526526
{
527-
if (CoinControlDialog::fSubtractFeeFromAmount) // dust-change will be raised until no dust
528-
nChange = GetDustThreshold(txout, ::dustRelayFee);
529-
else
530-
{
531-
nPayFee += nChange;
532-
nChange = 0;
533-
}
527+
nPayFee += nChange;
528+
nChange = 0;
529+
if (CoinControlDialog::fSubtractFeeFromAmount)
530+
nBytes -= 34; // we didn't detect lack of change above
534531
}
535532
}
536533

src/wallet/wallet.cpp

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2633,28 +2633,6 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CWalletT
26332633

26342634
CTxOut newTxOut(nChange, scriptChange);
26352635

2636-
// We do not move dust-change to fees, because the sender would end up paying more than requested.
2637-
// This would be against the purpose of the all-inclusive feature.
2638-
// So instead we raise the change and deduct from the recipient.
2639-
if (nSubtractFeeFromAmount > 0 && IsDust(newTxOut, ::dustRelayFee))
2640-
{
2641-
CAmount nDust = GetDustThreshold(newTxOut, ::dustRelayFee) - newTxOut.nValue;
2642-
newTxOut.nValue += nDust; // raise change until no more dust
2643-
for (unsigned int i = 0; i < vecSend.size(); i++) // subtract from first recipient
2644-
{
2645-
if (vecSend[i].fSubtractFeeFromAmount)
2646-
{
2647-
txNew.vout[i].nValue -= nDust;
2648-
if (IsDust(txNew.vout[i], ::dustRelayFee))
2649-
{
2650-
strFailReason = _("The transaction amount is too small to send after the fee has been deducted");
2651-
return false;
2652-
}
2653-
break;
2654-
}
2655-
}
2656-
}
2657-
26582636
// Never create dust outputs; if we would, just
26592637
// add the dust to the fee.
26602638
if (IsDust(newTxOut, ::dustRelayFee))

0 commit comments

Comments
 (0)