Skip to content

Commit 6506d71

Browse files
random-zebrafurszy
authored andcommitted
[BUG] Fix isDust label in coincontrol
Github-Pull: #2111 Rebased-From: 0e08e40
1 parent 805552c commit 6506d71

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

src/qt/coincontroldialog.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -510,16 +510,6 @@ void CoinControlDialog::getTotals(CAmount& nPayAmount, CAmount& nAmount, CAmount
510510
nBytes = 0;
511511
fDust = false;
512512

513-
// todo: fix dust - compute nPayAmount later
514-
for (const auto& amount : payAmounts) {
515-
nPayAmount += amount.first;
516-
if (amount.first > 0) {
517-
CTxOut txout(amount.first, (CScript)std::vector<unsigned char>(24, 0));
518-
if (IsDust(txout, ::minRelayTxFee))
519-
fDust = true;
520-
}
521-
}
522-
523513
std::vector<OutPointWrapper> vCoinControl;
524514
coinControl->ListSelected(vCoinControl);
525515

@@ -551,9 +541,14 @@ void CoinControlDialog::getTotals(CAmount& nPayAmount, CAmount& nAmount, CAmount
551541
// always assume +1 (p2pkh) output for change here
552542
nBytes += (fSelectTransparent ? CTXOUT_REGULAR_SIZE : OUTPUTDESCRIPTION_SIZE);
553543
for (const auto& a : payAmounts) {
544+
nPayAmount += a.first;
554545
bool shieldedOut = a.second;
555546
if (shieldedOut) nShieldOuts++;
556547
else nTransOuts++;
548+
if (a.first > 0 && !fDust) {
549+
if (a.first < (shieldedOut ? GetShieldedDustThreshold(minRelayTxFee) : GetDustThreshold(minRelayTxFee)))
550+
fDust = true;
551+
}
557552
nBytes += (shieldedOut ? OUTPUTDESCRIPTION_SIZE
558553
: (forDelegation ? P2CS_OUT_SIZE : CTXOUT_REGULAR_SIZE));
559554
}
@@ -658,7 +653,8 @@ void CoinControlDialog::updateLabels()
658653
toolTip1 += tr("This means a fee of at least %1 per kB is required.").arg(BitcoinUnits::formatWithUnit(nDisplayUnit, CWallet::GetRequiredFee(1000))) + "<br /><br />";
659654
toolTip1 += tr("Can vary +/- 1 byte per input.");
660655

661-
QString toolTip3 = tr("This label turns red, if any recipient receives an amount smaller than %1.").arg(BitcoinUnits::formatWithUnit(nDisplayUnit, ::minRelayTxFee.GetFee(546)));
656+
QString toolTip3 = tr("This label turns red, if recipient receives an amount smaller than %1 (transparent) / %2 (shield)."
657+
).arg(BitcoinUnits::formatWithUnit(nDisplayUnit, GetDustThreshold(minRelayTxFee))).arg(BitcoinUnits::formatWithUnit(nDisplayUnit, GetShieldedDustThreshold(minRelayTxFee)));
662658

663659
// how many satoshis the estimated fee can vary per byte we guess wrong
664660
double dFeeVary;

0 commit comments

Comments
 (0)