Changeset View
Changeset View
Standalone View
Standalone View
src/qt/coincontroldialog.cpp
Show First 20 Lines • Show All 444 Lines • ▼ Show 20 Lines | void CoinControlDialog::updateLabelLocked() { | ||||
} else | } else | ||||
ui->labelLocked->setVisible(false); | ui->labelLocked->setVisible(false); | ||||
} | } | ||||
void CoinControlDialog::updateLabels(WalletModel *model, QDialog *dialog) { | void CoinControlDialog::updateLabels(WalletModel *model, QDialog *dialog) { | ||||
if (!model) return; | if (!model) return; | ||||
// nPayAmount | // nPayAmount | ||||
CAmount nPayAmount = 0; | CAmount nPayAmount(0); | ||||
bool fDust = false; | bool fDust = false; | ||||
CMutableTransaction txDummy; | CMutableTransaction txDummy; | ||||
for (const CAmount &amount : CoinControlDialog::payAmounts) { | for (const CAmount &amount : CoinControlDialog::payAmounts) { | ||||
nPayAmount += amount; | nPayAmount += amount; | ||||
if (amount > 0) { | if (amount > 0) { | ||||
CTxOut txout(amount, (CScript)std::vector<uint8_t>(24, 0)); | CTxOut txout(Amount(amount), (CScript)std::vector<uint8_t>(24, 0)); | ||||
txDummy.vout.push_back(txout); | txDummy.vout.push_back(txout); | ||||
if (txout.IsDust(dustRelayFee)) fDust = true; | if (txout.IsDust(dustRelayFee)) fDust = true; | ||||
} | } | ||||
} | } | ||||
CAmount nAmount = 0; | CAmount nAmount(0); | ||||
CAmount nPayFee = 0; | CAmount nPayFee(0); | ||||
CAmount nAfterFee = 0; | CAmount nAfterFee(0); | ||||
CAmount nChange = 0; | CAmount nChange(0); | ||||
unsigned int nBytes = 0; | unsigned int nBytes = 0; | ||||
unsigned int nBytesInputs = 0; | unsigned int nBytesInputs = 0; | ||||
double dPriority = 0; | double dPriority = 0; | ||||
double dPriorityInputs = 0; | double dPriorityInputs = 0; | ||||
unsigned int nQuantity = 0; | unsigned int nQuantity = 0; | ||||
int nQuantityUncompressed = 0; | int nQuantityUncompressed = 0; | ||||
bool fAllowFree = false; | bool fAllowFree = false; | ||||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | if (nQuantity > 0) { | ||||
// already and subtract the bytes, so that fee calculation afterwards is | // already and subtract the bytes, so that fee calculation afterwards is | ||||
// accurate | // accurate | ||||
if (CoinControlDialog::fSubtractFeeFromAmount) | if (CoinControlDialog::fSubtractFeeFromAmount) | ||||
if (nAmount - nPayAmount == 0) nBytes -= 34; | if (nAmount - nPayAmount == 0) nBytes -= 34; | ||||
// Fee | // Fee | ||||
nPayFee = CWallet::GetMinimumFee(nBytes, nTxConfirmTarget, mempool) | nPayFee = CWallet::GetMinimumFee(nBytes, nTxConfirmTarget, mempool) | ||||
.GetSatoshis(); | .GetSatoshis(); | ||||
if (nPayFee > 0 && coinControl->nMinimumTotalFee > nPayFee) | if (nPayFee > 0 && | ||||
coinControl->nMinimumTotalFee.GetSatoshis() > nPayFee) | |||||
deadalnix: nPayFee should be an Amount. | |||||
nPayFee = coinControl->nMinimumTotalFee.GetSatoshis(); | nPayFee = coinControl->nMinimumTotalFee.GetSatoshis(); | ||||
// Allow free? (require at least hard-coded threshold and default to | // Allow free? (require at least hard-coded threshold and default to | ||||
// that if no estimate) | // that if no estimate) | ||||
double mempoolEstimatePriority = | double mempoolEstimatePriority = | ||||
mempool.estimateSmartPriority(nTxConfirmTarget); | mempool.estimateSmartPriority(nTxConfirmTarget); | ||||
// 29 = 180 - 151 (uncompressed public keys are over the limit. max 151 | // 29 = 180 - 151 (uncompressed public keys are over the limit. max 151 | ||||
// bytes of the input are ignored for priority) | // bytes of the input are ignored for priority) | ||||
dPriority = dPriorityInputs / | dPriority = dPriorityInputs / | ||||
(nBytes - nBytesInputs + (nQuantityUncompressed * 29)); | (nBytes - nBytesInputs + (nQuantityUncompressed * 29)); | ||||
double dPriorityNeeded = | double dPriorityNeeded = | ||||
std::max(mempoolEstimatePriority, AllowFreeThreshold()); | std::max(mempoolEstimatePriority, AllowFreeThreshold()); | ||||
fAllowFree = (dPriority >= dPriorityNeeded); | fAllowFree = (dPriority >= dPriorityNeeded); | ||||
if (fSendFreeTransactions) | if (fSendFreeTransactions) | ||||
if (fAllowFree && nBytes <= MAX_FREE_TRANSACTION_CREATE_SIZE) | if (fAllowFree && nBytes <= MAX_FREE_TRANSACTION_CREATE_SIZE) | ||||
nPayFee = 0; | nPayFee = 0; | ||||
if (nPayAmount > 0) { | if (nPayAmount > 0) { | ||||
nChange = nAmount - nPayAmount; | nChange = nAmount - nPayAmount; | ||||
if (!CoinControlDialog::fSubtractFeeFromAmount) nChange -= nPayFee; | if (!CoinControlDialog::fSubtractFeeFromAmount) 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 > 0 && nChange < MIN_CHANGE) { | if (nChange > 0 && nChange < MIN_CHANGE.GetSatoshis()) { | ||||
deadalnixUnsubmitted Not Done Inline Actionsdito for nChange. deadalnix: dito for nChange. | |||||
CTxOut txout(nChange, (CScript)std::vector<uint8_t>(24, 0)); | CTxOut txout(Amount(nChange), | ||||
(CScript)std::vector<uint8_t>(24, 0)); | |||||
if (txout.IsDust(dustRelayFee)) { | if (txout.IsDust(dustRelayFee)) { | ||||
// dust-change will be raised until no dust | // dust-change will be raised until no dust | ||||
if (CoinControlDialog::fSubtractFeeFromAmount) { | if (CoinControlDialog::fSubtractFeeFromAmount) { | ||||
nChange = | nChange = | ||||
txout.GetDustThreshold(dustRelayFee).GetSatoshis(); | txout.GetDustThreshold(dustRelayFee).GetSatoshis(); | ||||
} else { | } else { | ||||
nPayFee += nChange; | nPayFee += nChange; | ||||
nChange = 0; | nChange = 0; | ||||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | void CoinControlDialog::updateLabels(WalletModel *model, QDialog *dialog) { | ||||
// After Fee | // After Fee | ||||
l4->setText(BitcoinUnits::formatWithUnit(nDisplayUnit, nAfterFee)); | l4->setText(BitcoinUnits::formatWithUnit(nDisplayUnit, nAfterFee)); | ||||
// Bytes | // Bytes | ||||
l5->setText(((nBytes > 0) ? ASYMP_UTF8 : "") + QString::number(nBytes)); | l5->setText(((nBytes > 0) ? ASYMP_UTF8 : "") + QString::number(nBytes)); | ||||
// Dust | // Dust | ||||
l7->setText(fDust ? tr("yes") : tr("no")); | l7->setText(fDust ? tr("yes") : tr("no")); | ||||
// Change | // Change | ||||
l8->setText(BitcoinUnits::formatWithUnit(nDisplayUnit, nChange)); | l8->setText(BitcoinUnits::formatWithUnit(nDisplayUnit, nChange)); | ||||
if (nPayFee > 0 && (coinControl->nMinimumTotalFee < nPayFee)) { | if (nPayFee > 0 && | ||||
(coinControl->nMinimumTotalFee.GetSatoshis() < nPayFee)) { | |||||
deadalnixUnsubmitted Not Done Inline Actionsdito deadalnix: dito | |||||
l3->setText(ASYMP_UTF8 + l3->text()); | l3->setText(ASYMP_UTF8 + l3->text()); | ||||
l4->setText(ASYMP_UTF8 + l4->text()); | l4->setText(ASYMP_UTF8 + l4->text()); | ||||
if (nChange > 0 && !CoinControlDialog::fSubtractFeeFromAmount) { | if (nChange > 0 && !CoinControlDialog::fSubtractFeeFromAmount) { | ||||
l8->setText(ASYMP_UTF8 + l8->text()); | l8->setText(ASYMP_UTF8 + l8->text()); | ||||
} | } | ||||
} | } | ||||
// turn label red when dust | // turn label red when dust | ||||
▲ Show 20 Lines • Show All 86 Lines • ▼ Show 20 Lines | for (const std::pair<QString, std::vector<COutput>> &coins : mapCoins) { | ||||
// label | // label | ||||
itemWalletAddress->setText(COLUMN_LABEL, sWalletLabel); | itemWalletAddress->setText(COLUMN_LABEL, sWalletLabel); | ||||
// address | // address | ||||
itemWalletAddress->setText(COLUMN_ADDRESS, sWalletAddress); | itemWalletAddress->setText(COLUMN_ADDRESS, sWalletAddress); | ||||
} | } | ||||
CAmount nSum = 0; | CAmount nSum(0); | ||||
int nChildren = 0; | int nChildren = 0; | ||||
for (const COutput &out : coins.second) { | for (const COutput &out : coins.second) { | ||||
nSum += out.tx->tx->vout[out.i].nValue.GetSatoshis(); | nSum += out.tx->tx->vout[out.i].nValue.GetSatoshis(); | ||||
nChildren++; | nChildren++; | ||||
CCoinControlWidgetItem *itemOutput; | CCoinControlWidgetItem *itemOutput; | ||||
if (treeMode) { | if (treeMode) { | ||||
itemOutput = new CCoinControlWidgetItem(itemWalletAddress); | itemOutput = new CCoinControlWidgetItem(itemWalletAddress); | ||||
▲ Show 20 Lines • Show All 108 Lines • Show Last 20 Lines |
nPayFee should be an Amount.