diff --git a/src/qt/coincontroldialog.cpp b/src/qt/coincontroldialog.cpp --- a/src/qt/coincontroldialog.cpp +++ b/src/qt/coincontroldialog.cpp @@ -457,16 +457,16 @@ nPayAmount += amount; if (amount > 0) { - CTxOut txout(amount, (CScript)std::vector(24, 0)); + CTxOut txout(Amount(amount), (CScript)std::vector(24, 0)); txDummy.vout.push_back(txout); if (txout.IsDust(dustRelayFee)) fDust = true; } } - CAmount nAmount = 0; - CAmount nPayFee = 0; - CAmount nAfterFee = 0; - CAmount nChange = 0; + Amount nAmount(0); + Amount nPayFee(0); + Amount nAfterFee(0); + Amount nChange(0); unsigned int nBytes = 0; unsigned int nBytesInputs = 0; double dPriority = 0; @@ -534,8 +534,7 @@ if (nAmount - nPayAmount == 0) nBytes -= 34; // Fee - nPayFee = CWallet::GetMinimumFee(nBytes, nTxConfirmTarget, mempool) - .GetSatoshis(); + nPayFee = CWallet::GetMinimumFee(nBytes, nTxConfirmTarget, mempool); if (nPayFee > 0 && coinControl->nMinimumTotalFee > nPayFee) nPayFee = coinControl->nMinimumTotalFee.GetSatoshis(); @@ -561,7 +560,7 @@ // Never create dust outputs; if we would, just add the dust to the // fee. - if (nChange > 0 && nChange < MIN_CHANGE) { + if (nChange > 0 && nChange < MIN_CHANGE.GetSatoshis()) { CTxOut txout(nChange, (CScript)std::vector(24, 0)); if (txout.IsDust(dustRelayFee)) { // dust-change will be raised until no dust @@ -581,7 +580,7 @@ } // after fee - nAfterFee = std::max(nAmount - nPayFee, 0); + nAfterFee = std::max(nAmount - nPayFee, Amount(0)); } // actually update labels @@ -612,18 +611,22 @@ // Quantity l1->setText(QString::number(nQuantity)); // Amount - l2->setText(BitcoinUnits::formatWithUnit(nDisplayUnit, nAmount)); + l2->setText( + BitcoinUnits::formatWithUnit(nDisplayUnit, nAmount.GetSatoshis())); // Fee - l3->setText(BitcoinUnits::formatWithUnit(nDisplayUnit, nPayFee)); + l3->setText( + BitcoinUnits::formatWithUnit(nDisplayUnit, nPayFee.GetSatoshis())); // After Fee - l4->setText(BitcoinUnits::formatWithUnit(nDisplayUnit, nAfterFee)); + l4->setText( + BitcoinUnits::formatWithUnit(nDisplayUnit, nAfterFee.GetSatoshis())); // Bytes l5->setText(((nBytes > 0) ? ASYMP_UTF8 : "") + QString::number(nBytes)); // Dust l7->setText(fDust ? tr("yes") : tr("no")); // Change - l8->setText(BitcoinUnits::formatWithUnit(nDisplayUnit, nChange)); - if (nPayFee > 0 && (coinControl->nMinimumTotalFee < nPayFee)) { + l8->setText( + BitcoinUnits::formatWithUnit(nDisplayUnit, nChange.GetSatoshis())); + if (nPayFee > Amount(0) && (coinControl->nMinimumTotalFee < nPayFee)) { l3->setText(ASYMP_UTF8 + l3->text()); l4->setText(ASYMP_UTF8 + l4->text()); if (nChange > 0 && !CoinControlDialog::fSubtractFeeFromAmount) { @@ -726,10 +729,10 @@ itemWalletAddress->setText(COLUMN_ADDRESS, sWalletAddress); } - CAmount nSum = 0; + Amount nSum(0); int nChildren = 0; for (const COutput &out : coins.second) { - nSum += out.tx->tx->vout[out.i].nValue.GetSatoshis(); + nSum += out.tx->tx->vout[out.i].nValue; nChildren++; CCoinControlWidgetItem *itemOutput; @@ -825,9 +828,10 @@ itemWalletAddress->setText(COLUMN_CHECKBOX, "(" + QString::number(nChildren) + ")"); itemWalletAddress->setText( - COLUMN_AMOUNT, BitcoinUnits::format(nDisplayUnit, nSum)); + COLUMN_AMOUNT, + BitcoinUnits::format(nDisplayUnit, nSum.GetSatoshis())); itemWalletAddress->setData(COLUMN_AMOUNT, Qt::UserRole, - QVariant((qlonglong)nSum)); + QVariant((qlonglong)nSum.GetSatoshis())); } } diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -260,7 +260,7 @@ bool isDust(const QString &address, const CAmount &amount) { CTxDestination dest = DecodeDestination(address.toStdString()); CScript script = GetScriptForDestination(dest); - CTxOut txOut(amount, script); + CTxOut txOut(Amount(amount), script); return txOut.IsDust(dustRelayFee); } diff --git a/src/qt/paymentserver.cpp b/src/qt/paymentserver.cpp --- a/src/qt/paymentserver.cpp +++ b/src/qt/paymentserver.cpp @@ -572,7 +572,7 @@ } // Extract and check amounts - CTxOut txOut(sendingTo.second, sendingTo.first); + CTxOut txOut(Amount(sendingTo.second), sendingTo.first); if (txOut.IsDust(dustRelayFee)) { Q_EMIT message( tr("Payment request error"), @@ -802,7 +802,7 @@ } bool PaymentServer::verifyAmount(const CAmount &requestAmount) { - bool fVerified = MoneyRange(requestAmount); + bool fVerified = MoneyRange(Amount(requestAmount)); if (!fVerified) { qWarning() << QString("PaymentServer::%1: Payment request amount out " "of allowed range (%2, allowed 0 - %3).") diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp --- a/src/qt/sendcoinsdialog.cpp +++ b/src/qt/sendcoinsdialog.cpp @@ -665,10 +665,10 @@ if (ui->radioSmartFee->isChecked()) { int nConfirmTarget = ui->sliderSmartFee->maximum() - ui->sliderSmartFee->value() + 2; - payTxFee = CFeeRate(0); + payTxFee = CFeeRate(Amount(0)); // set nMinimumTotalFee to 0 to not accidentally pay a custom fee - CoinControlDialog::coinControl->nMinimumTotalFee = 0; + CoinControlDialog::coinControl->nMinimumTotalFee = Amount(0); // show the estimated required time for confirmation ui->confirmationTargetLabel->setText( @@ -676,14 +676,14 @@ nConfirmTarget * Params().GetConsensus().nPowTargetSpacing) + " / " + tr("%n block(s)", "", nConfirmTarget)); } else { - payTxFee = CFeeRate(ui->customFee->value()); + payTxFee = CFeeRate(Amount(ui->customFee->value())); // if user has selected to set a minimum absolute fee, pass the value to // coincontrol // set nMinimumTotalFee to 0 in case of user has selected that the fee // is per KB - CoinControlDialog::coinControl->nMinimumTotalFee = - ui->radioCustomAtLeast->isChecked() ? ui->customFee->value() : 0; + CoinControlDialog::coinControl->nMinimumTotalFee = Amount( + ui->radioCustomAtLeast->isChecked() ? ui->customFee->value() : 0); } } @@ -720,7 +720,7 @@ CFeeRate feeRate = mempool.estimateSmartFee(nBlocksToConfirm, &estimateFoundAtBlocks); // not enough data => minfee - if (feeRate <= CFeeRate(0)) { + if (feeRate <= CFeeRate(Amount(0))) { ui->labelSmartFee->setText( BitcoinUnits::formatWithUnit( model->getOptionsModel()->getDisplayUnit(), diff --git a/src/qt/transactiondesc.cpp b/src/qt/transactiondesc.cpp --- a/src/qt/transactiondesc.cpp +++ b/src/qt/transactiondesc.cpp @@ -133,11 +133,11 @@ // // Amount // - if (wtx.IsCoinBase() && nCredit == 0) { + if (wtx.IsCoinBase() && nCredit == Amount(0)) { // // Coinbase // - Amount nUnmatured = 0; + Amount nUnmatured(0); for (const CTxOut &txout : wtx.tx->vout) { nUnmatured += wallet->GetCredit(txout, ISMINE_ALL); } @@ -232,7 +232,7 @@ } Amount nTxFee = nDebit - wtx.tx->GetValueOut(); - if (nTxFee > 0) + if (nTxFee > Amount(0)) strHTML += "" + tr("Transaction fee") + ": " + BitcoinUnits::formatHtmlWithUnit( unit, -nTxFee.GetSatoshis()) + diff --git a/src/qt/transactionrecord.cpp b/src/qt/transactionrecord.cpp --- a/src/qt/transactionrecord.cpp +++ b/src/qt/transactionrecord.cpp @@ -90,7 +90,7 @@ if (fAllFromMe && fAllToMe) { // Payment to self - CAmount nChange = wtx.GetChange().GetSatoshis(); + Amount nChange = wtx.GetChange(); parts.append(TransactionRecord(hash, nTime, TransactionRecord::SendToSelf, "", @@ -127,13 +127,13 @@ sub.address = mapValue["to"]; } - CAmount nValue = txout.nValue.GetSatoshis(); + Amount nValue = txout.nValue; /* Add fee to first output */ - if (nTxFee > 0) { - nValue += nTxFee.GetSatoshis(); - nTxFee = 0; + if (nTxFee > Amount(0)) { + nValue += nTxFee; + nTxFee = Amount(0); } - sub.debit = -nValue; + sub.debit = -nValue.GetSatoshis(); parts.append(sub); } diff --git a/src/qt/transactionview.cpp b/src/qt/transactionview.cpp --- a/src/qt/transactionview.cpp +++ b/src/qt/transactionview.cpp @@ -333,7 +333,7 @@ void TransactionView::changedAmount(const QString &amount) { if (!transactionProxyModel) return; - CAmount amount_parsed = 0; + CAmount amount_parsed(0); if (BitcoinUnits::parse(model->getOptionsModel()->getDisplayUnit(), amount, &amount_parsed)) { transactionProxyModel->setMinAmount(amount_parsed); diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -57,7 +57,7 @@ CAmount WalletModel::getBalance(const CCoinControl *coinControl) const { if (coinControl) { - Amount nBalance = 0; + Amount nBalance(0); std::vector vCoins; wallet->AvailableCoins(vCoins, true, coinControl); for (const COutput &out : vCoins) { @@ -206,7 +206,7 @@ CScript scriptPubKey(scriptStr, scriptStr + out.script().size()); CAmount nAmount = out.amount(); - CRecipient recipient = {scriptPubKey, nAmount, + CRecipient recipient = {scriptPubKey, Amount(nAmount), rcp.fSubtractFeeFromAmount}; vecSend.push_back(recipient); } @@ -226,7 +226,7 @@ CScript scriptPubKey = GetScriptForDestination( DecodeDestination(rcp.address.toStdString())); - CRecipient recipient = {scriptPubKey, rcp.amount, + CRecipient recipient = {scriptPubKey, Amount(rcp.amount), rcp.fSubtractFeeFromAmount}; vecSend.push_back(recipient); @@ -248,7 +248,7 @@ transaction.newPossibleKeyChange(wallet); - Amount nFeeRequired = 0; + Amount nFeeRequired(0); int nChangePosRet = -1; std::string strFailReason; diff --git a/src/qt/walletmodeltransaction.h b/src/qt/walletmodeltransaction.h --- a/src/qt/walletmodeltransaction.h +++ b/src/qt/walletmodeltransaction.h @@ -27,7 +27,7 @@ CWalletTx *getTransaction(); unsigned int getTransactionSize(); - void setTransactionFee(const CAmount &newFee); + void setTransactionFee(const CAmount newFee); CAmount getTransactionFee(); CAmount getTotalTransactionAmount(); diff --git a/src/qt/walletmodeltransaction.cpp b/src/qt/walletmodeltransaction.cpp --- a/src/qt/walletmodeltransaction.cpp +++ b/src/qt/walletmodeltransaction.cpp @@ -34,7 +34,7 @@ return fee; } -void WalletModelTransaction::setTransactionFee(const CAmount &newFee) { +void WalletModelTransaction::setTransactionFee(const CAmount newFee) { fee = newFee; } @@ -42,7 +42,7 @@ int i = 0; for (SendCoinsRecipient &rcp : recipients) { if (rcp.paymentRequest.IsInitialized()) { - Amount subtotal = 0; + Amount subtotal(0); const payments::PaymentDetails &details = rcp.paymentRequest.getDetails(); for (int j = 0; j < details.outputs_size(); j++) { @@ -63,11 +63,11 @@ } CAmount WalletModelTransaction::getTotalTransactionAmount() { - CAmount totalTransactionAmount = 0; + Amount totalTransactionAmount(0); for (const SendCoinsRecipient &rcp : recipients) { totalTransactionAmount += rcp.amount; } - return totalTransactionAmount; + return totalTransactionAmount.GetSatoshis(); } void WalletModelTransaction::newPossibleKeyChange(CWallet *wallet) {