Changeset View
Changeset View
Standalone View
Standalone View
src/qt/coincontroldialog.cpp
Show First 20 Lines • Show All 458 Lines • ▼ Show 20 Lines | void CoinControlDialog::updateLabels(WalletModel *model, QDialog *dialog) { | ||||
// nPayAmount | // nPayAmount | ||||
Amount nPayAmount = Amount::zero(); | Amount nPayAmount = Amount::zero(); | ||||
bool fDust = false; | bool fDust = false; | ||||
CMutableTransaction txDummy; | CMutableTransaction txDummy; | ||||
for (const Amount &amount : CoinControlDialog::payAmounts) { | for (const Amount &amount : CoinControlDialog::payAmounts) { | ||||
nPayAmount += amount; | nPayAmount += amount; | ||||
if (amount > Amount::zero()) { | if (amount > Amount::zero()) { | ||||
CTxOut txout(amount, | // Assumes a p2pkh script size | ||||
static_cast<CScript>(std::vector<uint8_t>(24, 0))); | CTxOut txout(amount, CScript() << std::vector<uint8_t>(24, 0)); | ||||
txDummy.vout.push_back(txout); | txDummy.vout.push_back(txout); | ||||
fDust |= IsDust(txout, model->node().getDustRelayFee()); | fDust |= IsDust(txout, model->node().getDustRelayFee()); | ||||
} | } | ||||
} | } | ||||
Amount nAmount = Amount::zero(); | Amount nAmount = Amount::zero(); | ||||
Amount nPayFee = Amount::zero(); | Amount nPayFee = Amount::zero(); | ||||
Amount nAfterFee = Amount::zero(); | Amount nAfterFee = Amount::zero(); | ||||
▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | if (nQuantity > 0) { | ||||
nChange = nAmount - nPayAmount; | nChange = nAmount - nPayAmount; | ||||
if (!CoinControlDialog::fSubtractFeeFromAmount) { | if (!CoinControlDialog::fSubtractFeeFromAmount) { | ||||
nChange -= nPayFee; | nChange -= nPayFee; | ||||
} | } | ||||
// Never create dust outputs; if we would, just add the dust to the | // Never create dust outputs; if we would, just add the dust to the | ||||
// fee. | // fee. | ||||
if (nChange > Amount::zero() && nChange < MIN_CHANGE) { | if (nChange > Amount::zero() && nChange < MIN_CHANGE) { | ||||
CTxOut txout(nChange, | // Assumes a p2pkh script size | ||||
static_cast<CScript>(std::vector<uint8_t>(24, 0))); | CTxOut txout(nChange, CScript() << std::vector<uint8_t>(24, 0)); | ||||
if (IsDust(txout, model->node().getDustRelayFee())) { | if (IsDust(txout, model->node().getDustRelayFee())) { | ||||
nPayFee += nChange; | nPayFee += nChange; | ||||
nChange = Amount::zero(); | nChange = Amount::zero(); | ||||
if (CoinControlDialog::fSubtractFeeFromAmount) { | if (CoinControlDialog::fSubtractFeeFromAmount) { | ||||
// we didn't detect lack of change above | // we didn't detect lack of change above | ||||
nBytes -= 34; | nBytes -= 34; | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 269 Lines • Show Last 20 Lines |