Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14362693
D1706.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
76 KB
Subscribers
None
D1706.id.diff
View Options
diff --git a/src/amount.h b/src/amount.h
--- a/src/amount.h
+++ b/src/amount.h
@@ -19,16 +19,18 @@
int64_t amount;
public:
- constexpr Amount() : amount(0) {}
-
template <typename T>
explicit constexpr Amount(T _camount) : amount(_camount) {
static_assert(std::is_integral<T>(),
"Only integer types can be used as amounts");
}
+ constexpr Amount() : amount(0) {}
constexpr Amount(const Amount &_camount) : amount(_camount.amount) {}
+ static constexpr Amount zero() { return Amount(0); }
+ static constexpr Amount satoshi() { return Amount(1); }
+
/**
* Implement standard operators
*/
@@ -142,7 +144,7 @@
}
};
-static const Amount SATOSHI(1);
+static const Amount SATOSHI = Amount::satoshi();
static const Amount CASH = 100 * SATOSHI;
static const Amount COIN = 100000000 * SATOSHI;
static const Amount CENT = COIN / 100;
@@ -161,7 +163,7 @@
*/
static const Amount MAX_MONEY = 21000000 * COIN;
inline bool MoneyRange(const Amount nValue) {
- return (nValue >= Amount(0) && nValue <= MAX_MONEY);
+ return nValue >= Amount::zero() && nValue <= MAX_MONEY;
}
#endif // BITCOIN_AMOUNT_H
diff --git a/src/bitcoin-tx.cpp b/src/bitcoin-tx.cpp
--- a/src/bitcoin-tx.cpp
+++ b/src/bitcoin-tx.cpp
@@ -639,7 +639,7 @@
CTxOut txout;
txout.scriptPubKey = scriptPubKey;
- txout.nValue = Amount(0);
+ txout.nValue = Amount::zero();
if (prevOut.exists("amount")) {
txout.nValue = AmountFromValue(prevOut["amount"]);
}
diff --git a/src/coins.cpp b/src/coins.cpp
--- a/src/coins.cpp
+++ b/src/coins.cpp
@@ -282,7 +282,7 @@
Amount CCoinsViewCache::GetValueIn(const CTransaction &tx) const {
if (tx.IsCoinBase()) {
- return Amount(0);
+ return Amount::zero();
}
Amount nResult(0);
@@ -309,7 +309,7 @@
double CCoinsViewCache::GetPriority(const CTransaction &tx, int nHeight,
Amount &inChainInputValue) const {
- inChainInputValue = Amount(0);
+ inChainInputValue = Amount::zero();
if (tx.IsCoinBase()) {
return 0.0;
}
diff --git a/src/compressor.cpp b/src/compressor.cpp
--- a/src/compressor.cpp
+++ b/src/compressor.cpp
@@ -161,7 +161,7 @@
Amount CTxOutCompressor::DecompressAmount(uint64_t x) {
// x = 0 OR x = 1+10*(9*n + d - 1) + e OR x = 1+10*(n - 1) + 9
if (x == 0) {
- return Amount(0);
+ return Amount::zero();
}
x--;
// x = 10*(9*n + d - 1) + e
diff --git a/src/config.h b/src/config.h
--- a/src/config.h
+++ b/src/config.h
@@ -76,10 +76,12 @@
bool UseCashAddrEncoding() const override { return false; }
void SetExcessUTXOCharge(Amount amt) override {}
- Amount GetExcessUTXOCharge() const override { return Amount(0); }
+ Amount GetExcessUTXOCharge() const override { return Amount::zero(); }
void SetMinFeePerKB(CFeeRate amt) override{};
- CFeeRate GetMinFeePerKB() const override { return CFeeRate(Amount(0)); }
+ CFeeRate GetMinFeePerKB() const override {
+ return CFeeRate(Amount::zero());
+ }
private:
std::unique_ptr<CChainParams> chainParams;
diff --git a/src/feerate.cpp b/src/feerate.cpp
--- a/src/feerate.cpp
+++ b/src/feerate.cpp
@@ -16,7 +16,7 @@
if (nSize > 0) {
nSatoshisPerK = 1000 * nFeePaid / nSize;
} else {
- nSatoshisPerK = Amount(0);
+ nSatoshisPerK = Amount::zero();
}
}
@@ -28,18 +28,18 @@
// Ensure fee is rounded up when truncated if ceil is true.
Amount nFee(0);
if (ceil) {
- nFee = Amount(nSize * nSatoshisPerK % 1000 > Amount(0)
+ nFee = Amount(nSize * nSatoshisPerK % 1000 > Amount::zero()
? nSize * nSatoshisPerK / 1000 + SATOSHI
: nSize * nSatoshisPerK / 1000);
} else {
nFee = nSize * nSatoshisPerK / 1000;
}
- if (nFee == Amount(0) && nSize != 0) {
- if (nSatoshisPerK > Amount(0)) {
+ if (nFee == Amount::zero() && nSize != 0) {
+ if (nSatoshisPerK > Amount::zero()) {
nFee = SATOSHI;
}
- if (nSatoshisPerK < Amount(0)) {
+ if (nSatoshisPerK < Amount::zero()) {
nFee = -SATOSHI;
}
}
diff --git a/src/init.cpp b/src/init.cpp
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -1600,7 +1600,7 @@
if (gArgs.IsArgSet("-excessutxocharge")) {
Amount n(0);
auto parsed = ParseMoney(gArgs.GetArg("-excessutxocharge", ""), n);
- if (!parsed || Amount(0) > n) {
+ if (!parsed || Amount::zero() > n) {
return InitError(AmountErrMsg(
"excessutxocharge", gArgs.GetArg("-excessutxocharge", "")));
}
@@ -1616,7 +1616,7 @@
if (gArgs.IsArgSet("-minrelaytxfee")) {
Amount n(0);
auto parsed = ParseMoney(gArgs.GetArg("-minrelaytxfee", ""), n);
- if (!parsed || Amount(0) == n) {
+ if (!parsed || Amount::zero() == n) {
return InitError(AmountErrMsg("minrelaytxfee",
gArgs.GetArg("-minrelaytxfee", "")));
}
@@ -1642,7 +1642,7 @@
if (gArgs.IsArgSet("-dustrelayfee")) {
Amount n(0);
auto parsed = ParseMoney(gArgs.GetArg("-dustrelayfee", ""), n);
- if (!parsed || Amount(0) == n) {
+ if (!parsed || Amount::zero() == n) {
return InitError(AmountErrMsg("dustrelayfee",
gArgs.GetArg("-dustrelayfee", "")));
}
diff --git a/src/miner.cpp b/src/miner.cpp
--- a/src/miner.cpp
+++ b/src/miner.cpp
@@ -112,7 +112,7 @@
// These counters do not include coinbase tx.
nBlockTx = 0;
- nFees = Amount(0);
+ nFees = Amount::zero();
lastFewTxs = 0;
}
diff --git a/src/net.cpp b/src/net.cpp
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -2858,8 +2858,8 @@
nPingUsecTime = 0;
fPingQueued = false;
nMinPingUsecTime = std::numeric_limits<int64_t>::max();
- minFeeFilter = Amount(0);
- lastSentFeeFilter = Amount(0);
+ minFeeFilter = Amount::zero();
+ lastSentFeeFilter = Amount::zero();
nextSendTimeFeeFilter = 0;
fPauseRecv = false;
fPauseSend = false;
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -3548,7 +3548,7 @@
const uint256 &txid = txinfo.tx->GetId();
CInv inv(MSG_TX, txid);
pto->setInventoryTxToSend.erase(txid);
- if (filterrate != Amount(0) &&
+ if (filterrate != Amount::zero() &&
txinfo.feeRate.GetFeePerK() < filterrate) {
continue;
}
@@ -3612,7 +3612,7 @@
if (!txinfo.tx) {
continue;
}
- if (filterrate != Amount(0) &&
+ if (filterrate != Amount::zero() &&
txinfo.feeRate.GetFeePerK() < filterrate) {
continue;
}
diff --git a/src/policy/fees.cpp b/src/policy/fees.cpp
--- a/src/policy/fees.cpp
+++ b/src/policy/fees.cpp
@@ -340,7 +340,7 @@
CBlockPolicyEstimator::CBlockPolicyEstimator()
: nBestSeenHeight(0), trackedTxs(0), untrackedTxs(0) {
- static_assert(MIN_FEERATE > Amount(0), "Min feerate must be nonzero");
+ static_assert(MIN_FEERATE > Amount::zero(), "Min feerate must be nonzero");
CFeeRate minFeeRate(MIN_FEERATE);
std::vector<double> vfeelist;
for (double bucketBoundary = minFeeRate.GetFeePerK() / SATOSHI;
@@ -460,14 +460,14 @@
// It's not possible to get reasonable estimates for confTarget of 1
if (confTarget <= 1 ||
(unsigned int)confTarget > feeStats.GetMaxConfirms()) {
- return CFeeRate(Amount(0));
+ return CFeeRate(Amount::zero());
}
double median = feeStats.EstimateMedianVal(
confTarget, SUFFICIENT_FEETXS, MIN_SUCCESS_PCT, true, nBestSeenHeight);
if (median < 0) {
- return CFeeRate(Amount(0));
+ return CFeeRate(Amount::zero());
}
return CFeeRate(Amount(int64_t(median)));
@@ -482,7 +482,7 @@
// Return failure if trying to analyze a target we're not tracking
if (confTarget <= 0 ||
(unsigned int)confTarget > feeStats.GetMaxConfirms()) {
- return CFeeRate(Amount(0));
+ return CFeeRate(Amount::zero());
}
// It's not possible to get reasonable estimates for confTarget of 1
@@ -508,12 +508,12 @@
pool.GetMinFee(gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) *
1000000)
.GetFeePerK();
- if (minPoolFee > Amount(0) && minPoolFee > Amount(int64_t(median))) {
+ if (minPoolFee > Amount::zero() && minPoolFee > Amount(int64_t(median))) {
return CFeeRate(minPoolFee);
}
if (median < 0) {
- return CFeeRate(Amount(0));
+ return CFeeRate(Amount::zero());
}
return CFeeRate(Amount(int64_t(median)));
@@ -537,7 +537,7 @@
FeeFilterRounder::FeeFilterRounder(const CFeeRate &minIncrementalFee) {
Amount minFeeLimit = std::max(SATOSHI, minIncrementalFee.GetFeePerK() / 2);
- feeset.insert(Amount(0));
+ feeset.insert(Amount::zero());
for (double bucketBoundary = minFeeLimit / SATOSHI;
bucketBoundary <= double(MAX_FEERATE / SATOSHI);
bucketBoundary *= FEE_SPACING) {
diff --git a/src/primitives/transaction.h b/src/primitives/transaction.h
--- a/src/primitives/transaction.h
+++ b/src/primitives/transaction.h
@@ -173,7 +173,9 @@
* spend: so dust is a spendable txout less than 294*minRelayTxFee/1000
* (in satoshis).
*/
- if (scriptPubKey.IsUnspendable()) return Amount(0);
+ if (scriptPubKey.IsUnspendable()) {
+ return Amount::zero();
+ }
size_t nSize = GetSerializeSize(*this, SER_DISK, 0);
diff --git a/src/qt/bitcoinamountfield.cpp b/src/qt/bitcoinamountfield.cpp
--- a/src/qt/bitcoinamountfield.cpp
+++ b/src/qt/bitcoinamountfield.cpp
@@ -64,7 +64,7 @@
bool valid = false;
Amount val = value(&valid);
val = val + steps * singleStep;
- val = qMin(qMax(val, Amount(0)), BitcoinUnits::maxMoney());
+ val = qMin(qMax(val, Amount::zero()), BitcoinUnits::maxMoney());
setValue(val);
}
@@ -138,14 +138,14 @@
Amount val(0);
bool valid = BitcoinUnits::parse(currentUnit, text, &val);
if (valid) {
- if (val < Amount(0) || val > BitcoinUnits::maxMoney()) {
+ if (val < Amount::zero() || val > BitcoinUnits::maxMoney()) {
valid = false;
}
}
if (valid_out) {
*valid_out = valid;
}
- return valid ? val : Amount(0);
+ return valid ? val : Amount::zero();
}
protected:
@@ -178,7 +178,7 @@
bool valid = false;
Amount val = value(&valid);
if (valid) {
- if (val > Amount(0)) {
+ if (val > Amount::zero()) {
rv |= StepDownEnabled;
}
if (val < BitcoinUnits::maxMoney()) {
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp
--- a/src/qt/bitcoingui.cpp
+++ b/src/qt/bitcoingui.cpp
@@ -1037,8 +1037,8 @@
msg += tr("Label: %1\n").arg(label);
else if (!address.isEmpty())
msg += tr("Address: %1\n").arg(address);
- message(amount < Amount(0) ? tr("Sent transaction")
- : tr("Incoming transaction"),
+ message(amount < Amount::zero() ? tr("Sent transaction")
+ : tr("Incoming transaction"),
msg, CClientUIInterface::MSG_INFORMATION);
}
#endif // ENABLE_WALLET
diff --git a/src/qt/coincontroldialog.cpp b/src/qt/coincontroldialog.cpp
--- a/src/qt/coincontroldialog.cpp
+++ b/src/qt/coincontroldialog.cpp
@@ -462,13 +462,13 @@
}
// nPayAmount
- Amount nPayAmount(0);
+ Amount nPayAmount = Amount::zero();
bool fDust = false;
CMutableTransaction txDummy;
for (const Amount amount : CoinControlDialog::payAmounts) {
nPayAmount += amount;
- if (amount > Amount(0)) {
+ if (amount > Amount::zero()) {
CTxOut txout(Amount(amount), (CScript)std::vector<uint8_t>(24, 0));
txDummy.vout.push_back(txout);
if (txout.IsDust(dustRelayFee)) {
@@ -477,7 +477,7 @@
}
}
- Amount nAmount(0);
+ Amount nAmount = Amount::zero();
Amount nPayFee(0);
Amount nAfterFee(0);
Amount nChange(0);
@@ -540,18 +540,19 @@
// already and subtract the bytes, so that fee calculation afterwards is
// accurate
if (CoinControlDialog::fSubtractFeeFromAmount) {
- if (nAmount - nPayAmount == Amount(0)) {
+ if (nAmount - nPayAmount == Amount::zero()) {
nBytes -= 34;
}
}
// Fee
nPayFee = CWallet::GetMinimumFee(nBytes, nTxConfirmTarget, mempool);
- if (nPayFee > Amount(0) && coinControl->nMinimumTotalFee > nPayFee) {
+ if (nPayFee > Amount::zero() &&
+ coinControl->nMinimumTotalFee > nPayFee) {
nPayFee = coinControl->nMinimumTotalFee;
}
- if (nPayAmount > Amount(0)) {
+ if (nPayAmount > Amount::zero()) {
nChange = nAmount - nPayAmount;
if (!CoinControlDialog::fSubtractFeeFromAmount) {
nChange -= nPayFee;
@@ -559,7 +560,7 @@
// Never create dust outputs; if we would, just add the dust to the
// fee.
- if (nChange > Amount(0) && nChange < MIN_CHANGE) {
+ if (nChange > Amount::zero() && nChange < MIN_CHANGE) {
CTxOut txout(nChange, (CScript)std::vector<uint8_t>(24, 0));
if (txout.IsDust(dustRelayFee)) {
// dust-change will be raised until no dust
@@ -567,19 +568,19 @@
nChange = txout.GetDustThreshold(dustRelayFee);
} else {
nPayFee += nChange;
- nChange = Amount(0);
+ nChange = Amount::zero();
}
}
}
- if (nChange == Amount(0) &&
+ if (nChange == Amount::zero() &&
!CoinControlDialog::fSubtractFeeFromAmount) {
nBytes -= 34;
}
}
// after fee
- nAfterFee = std::max(nAmount - nPayFee, Amount(0));
+ nAfterFee = std::max(nAmount - nPayFee, Amount::zero());
}
// actually update labels
@@ -598,13 +599,13 @@
// enable/disable "dust" and "change"
dialog->findChild<QLabel *>("labelCoinControlLowOutputText")
- ->setEnabled(nPayAmount > Amount(0));
+ ->setEnabled(nPayAmount > Amount::zero());
dialog->findChild<QLabel *>("labelCoinControlLowOutput")
- ->setEnabled(nPayAmount > Amount(0));
+ ->setEnabled(nPayAmount > Amount::zero());
dialog->findChild<QLabel *>("labelCoinControlChangeText")
- ->setEnabled(nPayAmount > Amount(0));
+ ->setEnabled(nPayAmount > Amount::zero());
dialog->findChild<QLabel *>("labelCoinControlChange")
- ->setEnabled(nPayAmount > Amount(0));
+ ->setEnabled(nPayAmount > Amount::zero());
// stats
// Quantity
@@ -621,10 +622,11 @@
l7->setText(fDust ? tr("yes") : tr("no"));
// Change
l8->setText(BitcoinUnits::formatWithUnit(nDisplayUnit, nChange));
- if (nPayFee > Amount(0) && (coinControl->nMinimumTotalFee < nPayFee)) {
+ if (nPayFee > Amount::zero() && (coinControl->nMinimumTotalFee < nPayFee)) {
l3->setText(ASYMP_UTF8 + l3->text());
l4->setText(ASYMP_UTF8 + l4->text());
- if (nChange > Amount(0) && !CoinControlDialog::fSubtractFeeFromAmount) {
+ if (nChange > Amount::zero() &&
+ !CoinControlDialog::fSubtractFeeFromAmount) {
l8->setText(ASYMP_UTF8 + l8->text());
}
}
@@ -639,7 +641,7 @@
// how many satoshis the estimated fee can vary per byte we guess wrong
double dFeeVary;
- if (payTxFee.GetFeePerK() > Amount(0)) {
+ if (payTxFee.GetFeePerK() > Amount::zero()) {
dFeeVary =
std::max(CWallet::GetRequiredFee(1000), payTxFee.GetFeePerK()) /
(1000 * SATOSHI);
@@ -670,7 +672,7 @@
// Insufficient funds
QLabel *label = dialog->findChild<QLabel *>("labelCoinControlInsuffFunds");
if (label) {
- label->setVisible(nChange < Amount(0));
+ label->setVisible(nChange < Amount::zero());
}
}
diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp
--- a/src/qt/guiutil.cpp
+++ b/src/qt/guiutil.cpp
@@ -216,7 +216,7 @@
if (rv.address.endsWith("/")) {
rv.address.truncate(rv.address.length() - 1);
}
- rv.amount = Amount(0);
+ rv.amount = Amount::zero();
#if QT_VERSION < 0x050000
QList<QPair<QString, QString>> items = uri.queryItems();
@@ -280,7 +280,7 @@
}
int paramCount = 0;
- if (info.amount != Amount(0)) {
+ if (info.amount != Amount::zero()) {
ret +=
QString("?amount=%1")
.arg(BitcoinUnits::format(BitcoinUnits::BCH, info.amount, false,
diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp
--- a/src/qt/overviewpage.cpp
+++ b/src/qt/overviewpage.cpp
@@ -77,7 +77,7 @@
iconWatchonly.paint(painter, watchonlyRect);
}
- if (amount < Amount(0)) {
+ if (amount < Amount::zero()) {
foreground = COLOR_NEGATIVE;
} else if (!confirmed) {
foreground = COLOR_UNCONFIRMED;
@@ -191,8 +191,8 @@
// only show immature (newly mined) balance if it's non-zero, so as not to
// complicate things
// for the non-mining users
- bool showImmature = immatureBalance != Amount(0);
- bool showWatchOnlyImmature = watchImmatureBalance != Amount(0);
+ bool showImmature = immatureBalance != Amount::zero();
+ bool showWatchOnlyImmature = watchImmatureBalance != Amount::zero();
// for symmetry reasons also show immature label when the watch-only one is
// shown
diff --git a/src/qt/receiverequestdialog.cpp b/src/qt/receiverequestdialog.cpp
--- a/src/qt/receiverequestdialog.cpp
+++ b/src/qt/receiverequestdialog.cpp
@@ -130,7 +130,7 @@
html += "<a href=\"" + uri + "\">" + GUIUtil::HtmlEscape(uri) + "</a><br>";
html += "<b>" + tr("Address") +
"</b>: " + GUIUtil::HtmlEscape(info.address) + "<br>";
- if (info.amount != Amount(0))
+ if (info.amount != Amount::zero())
html += "<b>" + tr("Amount") +
"</b>: " + BitcoinUnits::formatHtmlWithUnit(
model->getDisplayUnit(), info.amount) +
diff --git a/src/qt/recentrequeststablemodel.cpp b/src/qt/recentrequeststablemodel.cpp
--- a/src/qt/recentrequeststablemodel.cpp
+++ b/src/qt/recentrequeststablemodel.cpp
@@ -71,7 +71,7 @@
return rec->recipient.message;
}
case Amount:
- if (rec->recipient.amount == ::Amount(0) &&
+ if (rec->recipient.amount == ::Amount::zero() &&
role == Qt::DisplayRole)
return tr("(no amount requested)");
else if (role == Qt::EditRole)
diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp
--- a/src/qt/sendcoinsdialog.cpp
+++ b/src/qt/sendcoinsdialog.cpp
@@ -354,7 +354,7 @@
QString questionString = tr("Are you sure you want to send?");
questionString.append("<br /><br />%1");
- if (txFee > Amount(0)) {
+ if (txFee > Amount::zero()) {
// append fee string if a fee is required
questionString.append("<hr /><span style='color:#aa0000;'>");
questionString.append(BitcoinUnits::formatHtmlWithUnit(
@@ -547,8 +547,8 @@
}
void SendCoinsDialog::updateDisplayUnit() {
- setBalance(model->getBalance(), Amount(0), Amount(0), Amount(0), Amount(0),
- Amount(0));
+ setBalance(model->getBalance(), Amount::zero(), Amount::zero(),
+ Amount::zero(), Amount::zero(), Amount::zero());
ui->customFee->setDisplayUnit(model->getOptionsModel()->getDisplayUnit());
updateMinFeeLabel();
updateSmartFeeLabel();
@@ -665,10 +665,10 @@
if (ui->radioSmartFee->isChecked()) {
int nConfirmTarget =
ui->sliderSmartFee->maximum() - ui->sliderSmartFee->value() + 2;
- payTxFee = CFeeRate(Amount(0));
+ payTxFee = CFeeRate(Amount::zero());
// set nMinimumTotalFee to 0 to not accidentally pay a custom fee
- CoinControlDialog::coinControl->nMinimumTotalFee = Amount(0);
+ CoinControlDialog::coinControl->nMinimumTotalFee = Amount::zero();
// show the estimated required time for confirmation
ui->confirmationTargetLabel->setText(
@@ -685,7 +685,7 @@
// is per KB
CoinControlDialog::coinControl->nMinimumTotalFee =
ui->radioCustomAtLeast->isChecked() ? ui->customFee->value()
- : Amount(0);
+ : Amount::zero();
}
}
@@ -722,7 +722,7 @@
CFeeRate feeRate =
mempool.estimateSmartFee(nBlocksToConfirm, &estimateFoundAtBlocks);
// not enough data => minfee
- if (feeRate <= CFeeRate(Amount(0))) {
+ if (feeRate <= CFeeRate(Amount::zero())) {
ui->labelSmartFee->setText(
BitcoinUnits::formatWithUnit(
model->getOptionsModel()->getDisplayUnit(),
diff --git a/src/qt/sendcoinsentry.cpp b/src/qt/sendcoinsentry.cpp
--- a/src/qt/sendcoinsentry.cpp
+++ b/src/qt/sendcoinsentry.cpp
@@ -141,7 +141,7 @@
}
// Sending a zero amount is invalid
- if (ui->payAmount->value(0) <= Amount(0)) {
+ if (ui->payAmount->value(0) <= Amount::zero()) {
ui->payAmount->setValid(false);
retval = false;
}
diff --git a/src/qt/test/uritests.cpp b/src/qt/test/uritests.cpp
--- a/src/qt/test/uritests.cpp
+++ b/src/qt/test/uritests.cpp
@@ -26,14 +26,14 @@
QVERIFY(GUIUtil::parseBitcoinURI(scheme, uri, &rv));
QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
QVERIFY(rv.label == QString());
- QVERIFY(rv.amount == Amount(0));
+ QVERIFY(rv.amount == Amount::zero());
uri.setUrl(QString("bitcoincash:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?label="
"Wikipedia Example Address"));
QVERIFY(GUIUtil::parseBitcoinURI(scheme, uri, &rv));
QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
QVERIFY(rv.label == QString("Wikipedia Example Address"));
- QVERIFY(rv.amount == Amount(0));
+ QVERIFY(rv.amount == Amount::zero());
uri.setUrl(
QString("bitcoincash:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=0.001"));
@@ -103,7 +103,7 @@
QVERIFY(rv.address ==
QString("bitcoincash:qpm2qsznhks23z7629mms6s4cwef74vcwvy22gdx6a"));
QVERIFY(rv.label == QString());
- QVERIFY(rv.amount == Amount(0));
+ QVERIFY(rv.amount == Amount::zero());
uri.setUrl(
QString("bitcoincash:qpm2qsznhks23z7629mms6s4cwef74vcwvy22gdx6a?label="
@@ -112,7 +112,7 @@
QVERIFY(rv.address ==
QString("bitcoincash:qpm2qsznhks23z7629mms6s4cwef74vcwvy22gdx6a"));
QVERIFY(rv.label == QString("Wikipedia Example Address"));
- QVERIFY(rv.amount == Amount(0));
+ QVERIFY(rv.amount == Amount::zero());
uri.setUrl(QString(
"bitcoincash:qpm2qsznhks23z7629mms6s4cwef74vcwvy22gdx6a?amount=0.001"));
diff --git a/src/qt/transactiondesc.cpp b/src/qt/transactiondesc.cpp
--- a/src/qt/transactiondesc.cpp
+++ b/src/qt/transactiondesc.cpp
@@ -91,7 +91,7 @@
GUIUtil::HtmlEscape(wtx.mapValue["from"]) + "<br>";
} else {
// Offline transaction
- if (nNet > Amount(0)) {
+ if (nNet > Amount::zero()) {
// Credit
CTxDestination address =
DecodeDestination(rec->address, wallet->chainParams);
@@ -140,7 +140,7 @@
//
// Amount
//
- if (wtx.IsCoinBase() && nCredit == Amount(0)) {
+ if (wtx.IsCoinBase() && nCredit == Amount::zero()) {
//
// Coinbase
//
@@ -158,7 +158,7 @@
strHTML += "(" + tr("not accepted") + ")";
}
strHTML += "<br>";
- } else if (nNet > Amount(0)) {
+ } else if (nNet > Amount::zero()) {
//
// Credit
//
@@ -246,7 +246,7 @@
}
Amount nTxFee = nDebit - wtx.tx->GetValueOut();
- if (nTxFee > Amount(0))
+ if (nTxFee > Amount::zero())
strHTML += "<b>" + tr("Transaction fee") + ":</b> " +
BitcoinUnits::formatHtmlWithUnit(unit, -1 * nTxFee) +
"<br>";
diff --git a/src/qt/transactionfilterproxy.cpp b/src/qt/transactionfilterproxy.cpp
--- a/src/qt/transactionfilterproxy.cpp
+++ b/src/qt/transactionfilterproxy.cpp
@@ -20,7 +20,7 @@
TransactionFilterProxy::TransactionFilterProxy(QObject *parent)
: QSortFilterProxyModel(parent), dateFrom(MIN_DATE), dateTo(MAX_DATE),
addrPrefix(), typeFilter(ALL_TYPES), watchOnlyFilter(WatchOnlyFilter_All),
- minAmount(0), limitRows(-1), showInactive(true) {}
+ minAmount(), limitRows(-1), showInactive(true) {}
bool TransactionFilterProxy::filterAcceptsRow(
int sourceRow, const QModelIndex &sourceParent) const {
diff --git a/src/qt/transactionrecord.cpp b/src/qt/transactionrecord.cpp
--- a/src/qt/transactionrecord.cpp
+++ b/src/qt/transactionrecord.cpp
@@ -36,7 +36,7 @@
const TxId &txid = wtx.GetId();
std::map<std::string, std::string> mapValue = wtx.mapValue;
- if (nNet > Amount(0) || wtx.IsCoinBase()) {
+ if (nNet > Amount::zero() || wtx.IsCoinBase()) {
//
// Credit
//
@@ -132,9 +132,9 @@
Amount nValue = txout.nValue;
/* Add fee to first output */
- if (nTxFee > Amount(0)) {
+ if (nTxFee > Amount::zero()) {
nValue += nTxFee;
- nTxFee = Amount(0);
+ nTxFee = Amount::zero();
}
sub.debit = -1 * nValue;
@@ -144,8 +144,9 @@
//
// Mixed debit transaction, can't break down payees
//
- parts.append(TransactionRecord(
- txid, nTime, TransactionRecord::Other, "", nNet, Amount(0)));
+ parts.append(TransactionRecord(txid, nTime,
+ TransactionRecord::Other, "", nNet,
+ Amount::zero()));
parts.last().involvesWatchAddress = involvesWatchAddress;
}
}
diff --git a/src/qt/transactiontablemodel.cpp b/src/qt/transactiontablemodel.cpp
--- a/src/qt/transactiontablemodel.cpp
+++ b/src/qt/transactiontablemodel.cpp
@@ -588,7 +588,7 @@
return COLOR_UNCONFIRMED;
}
if (index.column() == Amount &&
- (rec->credit + rec->debit) < ::Amount(0)) {
+ (rec->credit + rec->debit) < ::Amount::zero()) {
return COLOR_NEGATIVE;
}
if (index.column() == ToAddress) {
diff --git a/src/qt/transactionview.cpp b/src/qt/transactionview.cpp
--- a/src/qt/transactionview.cpp
+++ b/src/qt/transactionview.cpp
@@ -338,7 +338,7 @@
&amount_parsed)) {
transactionProxyModel->setMinAmount(amount_parsed);
} else {
- transactionProxyModel->setMinAmount(Amount(0));
+ transactionProxyModel->setMinAmount(Amount::zero());
}
}
diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp
--- a/src/qt/walletmodel.cpp
+++ b/src/qt/walletmodel.cpp
@@ -213,7 +213,7 @@
rcp.fSubtractFeeFromAmount};
vecSend.push_back(recipient);
}
- if (subtotal <= Amount(0)) {
+ if (subtotal <= Amount::zero()) {
return InvalidAmount;
}
total += subtotal;
@@ -221,7 +221,7 @@
if (!validateAddress(rcp.address)) {
return InvalidAddress;
}
- if (rcp.amount <= Amount(0)) {
+ if (rcp.amount <= Amount::zero()) {
return InvalidAmount;
}
setAddress.insert(rcp.address);
diff --git a/src/qt/walletmodeltransaction.cpp b/src/qt/walletmodeltransaction.cpp
--- a/src/qt/walletmodeltransaction.cpp
+++ b/src/qt/walletmodeltransaction.cpp
@@ -65,7 +65,7 @@
}
Amount WalletModelTransaction::getTotalTransactionAmount() {
- Amount totalTransactionAmount(0);
+ Amount totalTransactionAmount = Amount::zero();
for (const SendCoinsRecipient &rcp : recipients) {
totalTransactionAmount += rcp.amount;
}
diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp
--- a/src/rpc/blockchain.cpp
+++ b/src/rpc/blockchain.cpp
@@ -861,7 +861,7 @@
CCoinsStats()
: nHeight(0), nTransactions(0), nTransactionOutputs(0), nBogoSize(0),
- nDiskSize(0), nTotalAmount(0) {}
+ nDiskSize(0), nTotalAmount() {}
};
static void ApplyStats(CCoinsStats &stats, CHashWriter &ss, const uint256 &hash,
diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp
--- a/src/rpc/mining.cpp
+++ b/src/rpc/mining.cpp
@@ -806,7 +806,7 @@
}
CFeeRate feeRate = mempool.estimateFee(nBlocks);
- if (feeRate == CFeeRate(Amount(0))) {
+ if (feeRate == CFeeRate(Amount::zero())) {
return -1.0;
}
diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp
--- a/src/rpc/rawtransaction.cpp
+++ b/src/rpc/rawtransaction.cpp
@@ -550,7 +550,7 @@
std::vector<uint8_t> data =
ParseHexV(sendTo[name_].getValStr(), "Data");
- CTxOut out(Amount(0), CScript() << OP_RETURN << data);
+ CTxOut out(Amount::zero(), CScript() << OP_RETURN << data);
rawTx.vout.push_back(out);
} else {
CTxDestination destination =
@@ -947,7 +947,7 @@
CTxOut txout;
txout.scriptPubKey = scriptPubKey;
- txout.nValue = Amount(0);
+ txout.nValue = Amount::zero();
if (prevOut.exists("amount")) {
txout.nValue =
AmountFromValue(find_value(prevOut, "amount"));
@@ -1131,7 +1131,7 @@
bool fLimitFree = false;
Amount nMaxRawTxFee = maxTxFee;
if (request.params.size() > 1 && request.params[1].get_bool()) {
- nMaxRawTxFee = Amount(0);
+ nMaxRawTxFee = Amount::zero();
}
CCoinsViewCache &view = *pcoinsTip;
diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp
--- a/src/rpc/server.cpp
+++ b/src/rpc/server.cpp
@@ -133,7 +133,7 @@
}
UniValue ValueFromAmount(const Amount amount) {
- bool sign = amount < Amount(0);
+ bool sign = amount < Amount::zero();
Amount n_abs(sign ? -amount : amount);
int64_t quotient = n_abs / COIN;
int64_t remainder = n_abs % COIN;
diff --git a/src/test/amount_tests.cpp b/src/test/amount_tests.cpp
--- a/src/test/amount_tests.cpp
+++ b/src/test/amount_tests.cpp
@@ -50,23 +50,23 @@
BOOST_CHECK_EQUAL(aval * b, Amount(aval * bval));
// Division
- if (b != Amount(0)) {
+ if (b != Amount::zero()) {
BOOST_CHECK_EQUAL(a / b, aval / bval);
BOOST_CHECK_EQUAL(a / bval, Amount(a / b));
}
- if (a != Amount(0)) {
+ if (a != Amount::zero()) {
BOOST_CHECK_EQUAL(b / a, bval / aval);
BOOST_CHECK_EQUAL(b / aval, Amount(b / a));
}
// Modulus
- if (b != Amount(0)) {
+ if (b != Amount::zero()) {
BOOST_CHECK_EQUAL(a % b, aval % bval);
BOOST_CHECK_EQUAL(a % bval, Amount(a % b));
}
- if (a != Amount(0)) {
+ if (a != Amount::zero()) {
BOOST_CHECK_EQUAL(b % a, bval % aval);
BOOST_CHECK_EQUAL(b % aval, Amount(b % a));
}
@@ -94,9 +94,9 @@
BOOST_CHECK_EQUAL(COIN + COIN, 2 * COIN);
BOOST_CHECK_EQUAL(2 * COIN + COIN, 3 * COIN);
- BOOST_CHECK_EQUAL(-1 * COIN + COIN, Amount(0));
+ BOOST_CHECK_EQUAL(-1 * COIN + COIN, Amount::zero());
- BOOST_CHECK_EQUAL(COIN - COIN, Amount(0));
+ BOOST_CHECK_EQUAL(COIN - COIN, Amount::zero());
BOOST_CHECK_EQUAL(COIN - 2 * COIN, -1 * COIN);
}
diff --git a/src/test/coins_tests.cpp b/src/test/coins_tests.cpp
--- a/src/test/coins_tests.cpp
+++ b/src/test/coins_tests.cpp
@@ -524,7 +524,7 @@
ss3 >> c3;
BOOST_CHECK_EQUAL(c3.IsCoinBase(), false);
BOOST_CHECK_EQUAL(c3.GetHeight(), 0);
- BOOST_CHECK_EQUAL(c3.GetTxOut().nValue, Amount(0));
+ BOOST_CHECK_EQUAL(c3.GetTxOut().nValue, Amount::zero());
BOOST_CHECK_EQUAL(c3.GetTxOut().scriptPubKey.size(), 0);
// scriptPubKey that ends beyond the end of the stream
diff --git a/src/test/compress_tests.cpp b/src/test/compress_tests.cpp
--- a/src/test/compress_tests.cpp
+++ b/src/test/compress_tests.cpp
@@ -40,7 +40,7 @@
}
BOOST_AUTO_TEST_CASE(compress_amounts) {
- BOOST_CHECK(TestPair(Amount(0), 0x0));
+ BOOST_CHECK(TestPair(Amount::zero(), 0x0));
BOOST_CHECK(TestPair(SATOSHI, 0x1));
BOOST_CHECK(TestPair(CENT, 0x7));
BOOST_CHECK(TestPair(COIN, 0x9));
diff --git a/src/test/feerate_tests.cpp b/src/test/feerate_tests.cpp
--- a/src/test/feerate_tests.cpp
+++ b/src/test/feerate_tests.cpp
@@ -14,14 +14,14 @@
BOOST_AUTO_TEST_CASE(GetFeeTest) {
CFeeRate feeRate;
- feeRate = CFeeRate(Amount(0));
+ feeRate = CFeeRate(Amount::zero());
// Must always return 0
- BOOST_CHECK_EQUAL(feeRate.GetFee(0), Amount(0));
- BOOST_CHECK_EQUAL(feeRate.GetFee(1e5), Amount(0));
+ BOOST_CHECK_EQUAL(feeRate.GetFee(0), Amount::zero());
+ BOOST_CHECK_EQUAL(feeRate.GetFee(1e5), Amount::zero());
feeRate = CFeeRate(Amount(1000));
// Must always just return the arg
- BOOST_CHECK_EQUAL(feeRate.GetFee(0), Amount(0));
+ BOOST_CHECK_EQUAL(feeRate.GetFee(0), Amount::zero());
BOOST_CHECK_EQUAL(feeRate.GetFee(1), SATOSHI);
BOOST_CHECK_EQUAL(feeRate.GetFee(121), Amount(121));
BOOST_CHECK_EQUAL(feeRate.GetFee(999), Amount(999));
@@ -30,7 +30,7 @@
feeRate = CFeeRate(Amount(-1000));
// Must always just return -1 * arg
- BOOST_CHECK_EQUAL(feeRate.GetFee(0), Amount(0));
+ BOOST_CHECK_EQUAL(feeRate.GetFee(0), Amount::zero());
BOOST_CHECK_EQUAL(feeRate.GetFee(1), -SATOSHI);
BOOST_CHECK_EQUAL(feeRate.GetFee(121), Amount(-121));
BOOST_CHECK_EQUAL(feeRate.GetFee(999), Amount(-999));
@@ -39,7 +39,7 @@
feeRate = CFeeRate(Amount(123));
// Truncates the result, if not integer
- BOOST_CHECK_EQUAL(feeRate.GetFee(0), Amount(0));
+ BOOST_CHECK_EQUAL(feeRate.GetFee(0), Amount::zero());
// Special case: returns 1 instead of 0
BOOST_CHECK_EQUAL(feeRate.GetFee(8), SATOSHI);
BOOST_CHECK_EQUAL(feeRate.GetFee(9), SATOSHI);
@@ -51,7 +51,7 @@
feeRate = CFeeRate(Amount(-123));
// Truncates the result, if not integer
- BOOST_CHECK_EQUAL(feeRate.GetFee(0), Amount(0));
+ BOOST_CHECK_EQUAL(feeRate.GetFee(0), Amount::zero());
// Special case: returns -1 instead of 0
BOOST_CHECK_EQUAL(feeRate.GetFee(8), -SATOSHI);
BOOST_CHECK_EQUAL(feeRate.GetFee(9), -SATOSHI);
@@ -59,7 +59,7 @@
// Check ceiling results
feeRate = CFeeRate(Amount(18));
// Truncates the result, if not integer
- BOOST_CHECK_EQUAL(feeRate.GetFeeCeiling(0), Amount(0));
+ BOOST_CHECK_EQUAL(feeRate.GetFeeCeiling(0), Amount::zero());
BOOST_CHECK_EQUAL(feeRate.GetFeeCeiling(100), Amount(2));
BOOST_CHECK_EQUAL(feeRate.GetFeeCeiling(200), Amount(4));
BOOST_CHECK_EQUAL(feeRate.GetFeeCeiling(1000), Amount(18));
@@ -67,10 +67,10 @@
// Check full constructor
// default value
BOOST_CHECK(CFeeRate(-SATOSHI, 1000) == CFeeRate(-SATOSHI));
- BOOST_CHECK(CFeeRate(Amount(0), 1000) == CFeeRate(Amount(0)));
+ BOOST_CHECK(CFeeRate(Amount::zero(), 1000) == CFeeRate(Amount::zero()));
BOOST_CHECK(CFeeRate(SATOSHI, 1000) == CFeeRate(SATOSHI));
// lost precision (can only resolve satoshis per kB)
- BOOST_CHECK(CFeeRate(SATOSHI, 1001) == CFeeRate(Amount(0)));
+ BOOST_CHECK(CFeeRate(SATOSHI, 1001) == CFeeRate(Amount::zero()));
BOOST_CHECK(CFeeRate(Amount(2), 1001) == CFeeRate(SATOSHI));
// some more integer checks
BOOST_CHECK(CFeeRate(Amount(26), 789) == CFeeRate(Amount(32)));
diff --git a/src/test/main_tests.cpp b/src/test/main_tests.cpp
--- a/src/test/main_tests.cpp
+++ b/src/test/main_tests.cpp
@@ -29,7 +29,7 @@
BOOST_CHECK_EQUAL(
GetBlockSubsidy(maxHalvings * consensusParams.nSubsidyHalvingInterval,
consensusParams),
- Amount(0));
+ Amount::zero());
}
static void TestBlockSubsidyHalvings(int nSubsidyHalvingInterval) {
diff --git a/src/test/miner_tests.cpp b/src/test/miner_tests.cpp
--- a/src/test/miner_tests.cpp
+++ b/src/test/miner_tests.cpp
@@ -137,7 +137,7 @@
// 0 fee.
tx.vout[0].nValue = Amount(5000000000LL - 1000 - 50000);
TxId freeTxId = tx.GetId();
- mempool.addUnchecked(freeTxId, entry.Fee(Amount(0)).FromTx(tx));
+ mempool.addUnchecked(freeTxId, entry.Fee(Amount::zero()).FromTx(tx));
size_t freeTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION);
// Calculate a fee on child transaction that will put the package just
@@ -177,8 +177,8 @@
// 1BCC output.
tx.vout[1].nValue = Amount(100000000);
TxId freeTxId2 = tx.GetId();
- mempool.addUnchecked(freeTxId2,
- entry.Fee(Amount(0)).SpendsCoinbase(true).FromTx(tx));
+ mempool.addUnchecked(
+ freeTxId2, entry.Fee(Amount::zero()).SpendsCoinbase(true).FromTx(tx));
// This tx can't be mined by itself.
tx.vin[0].prevout = COutPoint(freeTxId2, 0);
@@ -416,7 +416,7 @@
tx.vin.resize(1);
tx.vin[0].prevout = COutPoint();
tx.vin[0].scriptSig = CScript() << OP_0 << OP_1;
- tx.vout[0].nValue = Amount(0);
+ tx.vout[0].nValue = Amount::zero();
hash = tx.GetId();
// Give it a fee so it'll get mined.
mempool.addUnchecked(
diff --git a/src/test/multisig_tests.cpp b/src/test/multisig_tests.cpp
--- a/src/test/multisig_tests.cpp
+++ b/src/test/multisig_tests.cpp
@@ -23,7 +23,7 @@
CScript sign_multisig(CScript scriptPubKey, std::vector<CKey> keys,
CMutableTransaction mutableTransaction, int whichIn) {
uint256 hash = SignatureHash(scriptPubKey, CTransaction(mutableTransaction),
- whichIn, SigHashType(), Amount(0));
+ whichIn, SigHashType(), Amount::zero());
CScript result;
// CHECKMULTISIG bug workaround
diff --git a/src/test/policyestimator_tests.cpp b/src/test/policyestimator_tests.cpp
--- a/src/test/policyestimator_tests.cpp
+++ b/src/test/policyestimator_tests.cpp
@@ -41,7 +41,7 @@
tx.vin.resize(1);
tx.vin[0].scriptSig = garbage;
tx.vout.resize(1);
- tx.vout[0].nValue = Amount(0);
+ tx.vout[0].nValue = Amount::zero();
CFeeRate baseRate(basefee, CTransaction(tx).GetTotalSize());
// Create a fake block
@@ -89,9 +89,9 @@
// data points. So estimateFee(1,2,3) should fail and estimateFee(4)
// should return somewhere around 8*baserate. estimateFee(4) %'s
// are 100,100,100,100,90 = average 98%
- BOOST_CHECK(mpool.estimateFee(1) == CFeeRate(Amount(0)));
- BOOST_CHECK(mpool.estimateFee(2) == CFeeRate(Amount(0)));
- BOOST_CHECK(mpool.estimateFee(3) == CFeeRate(Amount(0)));
+ BOOST_CHECK(mpool.estimateFee(1) == CFeeRate(Amount::zero()));
+ BOOST_CHECK(mpool.estimateFee(2) == CFeeRate(Amount::zero()));
+ BOOST_CHECK(mpool.estimateFee(3) == CFeeRate(Amount::zero()));
BOOST_CHECK(mpool.estimateFee(4).GetFeePerK() <
8 * baseRate.GetFeePerK() + deltaFee);
BOOST_CHECK(mpool.estimateFee(4).GetFeePerK() >
@@ -132,7 +132,8 @@
BOOST_CHECK(origFeeEst[i - 1] >
mult * baseRate.GetFeePerK() - deltaFee);
} else {
- BOOST_CHECK(origFeeEst[i - 1] == CFeeRate(Amount(0)).GetFeePerK());
+ BOOST_CHECK(origFeeEst[i - 1] ==
+ CFeeRate(Amount::zero()).GetFeePerK());
}
}
@@ -143,7 +144,7 @@
mpool.removeForBlock(block, ++blocknum);
}
- BOOST_CHECK(mpool.estimateFee(1) == CFeeRate(Amount(0)));
+ BOOST_CHECK(mpool.estimateFee(1) == CFeeRate(Amount::zero()));
for (int i = 2; i < 10; i++) {
BOOST_CHECK(mpool.estimateFee(i).GetFeePerK() <
origFeeEst[i - 1] + deltaFee);
@@ -174,7 +175,7 @@
int answerFound;
for (int i = 1; i < 10; i++) {
- BOOST_CHECK(mpool.estimateFee(i) == CFeeRate(Amount(0)) ||
+ BOOST_CHECK(mpool.estimateFee(i) == CFeeRate(Amount::zero()) ||
mpool.estimateFee(i).GetFeePerK() >
origFeeEst[i - 1] - deltaFee);
Amount a1 = mpool.estimateSmartFee(i, &answerFound).GetFeePerK();
@@ -195,7 +196,7 @@
}
mpool.removeForBlock(block, 265);
block.clear();
- BOOST_CHECK(mpool.estimateFee(1) == CFeeRate(Amount(0)));
+ BOOST_CHECK(mpool.estimateFee(1) == CFeeRate(Amount::zero()));
for (int i = 2; i < 10; i++) {
BOOST_CHECK(mpool.estimateFee(i).GetFeePerK() >
origFeeEst[i - 1] - deltaFee);
@@ -225,7 +226,7 @@
mpool.removeForBlock(block, ++blocknum);
block.clear();
}
- BOOST_CHECK(mpool.estimateFee(1) == CFeeRate(Amount(0)));
+ BOOST_CHECK(mpool.estimateFee(1) == CFeeRate(Amount::zero()));
for (int i = 2; i < 10; i++) {
BOOST_CHECK(mpool.estimateFee(i).GetFeePerK() <
origFeeEst[i - 1] - deltaFee);
diff --git a/src/test/rpc_tests.cpp b/src/test/rpc_tests.cpp
--- a/src/test/rpc_tests.cpp
+++ b/src/test/rpc_tests.cpp
@@ -253,7 +253,7 @@
BOOST_CHECK(ValueFromAmount(Amount(2099999999999999LL)).write() ==
"20999999.99999999");
- BOOST_CHECK_EQUAL(ValueFromAmount(Amount(0)).write(), "0.00000000");
+ BOOST_CHECK_EQUAL(ValueFromAmount(Amount::zero()).write(), "0.00000000");
BOOST_CHECK_EQUAL(ValueFromAmount(123456789 * (COIN / 10000)).write(),
"12345.67890000");
BOOST_CHECK_EQUAL(ValueFromAmount(-1 * COIN).write(), "-1.00000000");
diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp
--- a/src/test/script_tests.cpp
+++ b/src/test/script_tests.cpp
@@ -283,7 +283,7 @@
public:
TestBuilder(const CScript &script_, const std::string &comment_, int flags_,
- bool P2SH = false, Amount nValue_ = Amount(0))
+ bool P2SH = false, Amount nValue_ = Amount::zero())
: script(script_), havePush(false), comment(comment_), flags(flags_),
scriptError(SCRIPT_ERR_OK), nValue(nValue_) {
CScript scriptPubKey = script;
@@ -333,7 +333,7 @@
TestBuilder &PushSig(const CKey &key,
SigHashType sigHashType = SigHashType(),
unsigned int lenR = 32, unsigned int lenS = 32,
- Amount amount = Amount(0),
+ Amount amount = Amount::zero(),
uint32_t flags = SCRIPT_ENABLE_SIGHASH_FORKID) {
uint256 hash = SignatureHash(script, CTransaction(spendTx), 0,
sigHashType, amount, nullptr, flags);
@@ -397,7 +397,7 @@
UniValue GetJSON() {
DoPush();
UniValue array(UniValue::VARR);
- if (nValue != Amount(0)) {
+ if (nValue != Amount::zero()) {
UniValue amount(UniValue::VARR);
amount.push_back(ValueFromAmount(nValue));
array.push_back(amount);
@@ -903,7 +903,7 @@
<< ToByteVector(keys.pubkey0.GetID())
<< OP_EQUALVERIFY << OP_CHECKSIG,
"P2PKH with invalid sighashtype", 0)
- .PushSig(keys.key0, SigHashType(0x21), 32, 32, Amount(0), 0)
+ .PushSig(keys.key0, SigHashType(0x21), 32, 32, Amount::zero(), 0)
.Push(keys.pubkey0));
tests.push_back(TestBuilder(CScript() << OP_DUP << OP_HASH160
<< ToByteVector(keys.pubkey0.GetID())
@@ -911,7 +911,7 @@
"P2PKH with invalid sighashtype and STRICTENC",
SCRIPT_VERIFY_STRICTENC)
.PushSig(keys.key0, SigHashType(0x21), 32, 32,
- Amount(0), SCRIPT_VERIFY_STRICTENC)
+ Amount::zero(), SCRIPT_VERIFY_STRICTENC)
.Push(keys.pubkey0)
// Should fail for STRICTENC
.ScriptError(SCRIPT_ERR_SIG_HASHTYPE));
@@ -1427,8 +1427,8 @@
CScript sign_multisig(CScript scriptPubKey, std::vector<CKey> keys,
CTransaction transaction) {
- uint256 hash =
- SignatureHash(scriptPubKey, transaction, 0, SigHashType(), Amount(0));
+ uint256 hash = SignatureHash(scriptPubKey, transaction, 0, SigHashType(),
+ Amount::zero());
CScript result;
//
@@ -1468,7 +1468,7 @@
<< OP_CHECKMULTISIG;
CMutableTransaction txFrom12 =
- BuildCreditingTransaction(scriptPubKey12, Amount(0));
+ BuildCreditingTransaction(scriptPubKey12, Amount::zero());
CMutableTransaction txTo12 = BuildSpendingTransaction(CScript(), txFrom12);
CScript goodsig1 =
@@ -1516,7 +1516,7 @@
<< OP_CHECKMULTISIG;
CMutableTransaction txFrom23 =
- BuildCreditingTransaction(scriptPubKey23, Amount(0));
+ BuildCreditingTransaction(scriptPubKey23, Amount::zero());
CMutableTransaction mutableTxTo23 =
BuildSpendingTransaction(CScript(), txFrom23);
@@ -1632,7 +1632,7 @@
}
CMutableTransaction txFrom = BuildCreditingTransaction(
- GetScriptForDestination(keys[0].GetPubKey().GetID()), Amount(0));
+ GetScriptForDestination(keys[0].GetPubKey().GetID()), Amount::zero());
CMutableTransaction txTo = BuildSpendingTransaction(CScript(), txFrom);
CScript &scriptPubKey = txFrom.vout[0].scriptPubKey;
CScript &scriptSig = txTo.vin[0].scriptSig;
@@ -1721,19 +1721,19 @@
// A couple of partially-signed versions:
std::vector<uint8_t> sig1;
uint256 hash1 = SignatureHash(scriptPubKey, CTransaction(txTo), 0,
- SigHashType(), Amount(0));
+ SigHashType(), Amount::zero());
BOOST_CHECK(keys[0].Sign(hash1, sig1));
sig1.push_back(SIGHASH_ALL);
std::vector<uint8_t> sig2;
uint256 hash2 = SignatureHash(
scriptPubKey, CTransaction(txTo), 0,
- SigHashType().withBaseType(BaseSigHashType::NONE), Amount(0));
+ SigHashType().withBaseType(BaseSigHashType::NONE), Amount::zero());
BOOST_CHECK(keys[1].Sign(hash2, sig2));
sig2.push_back(SIGHASH_NONE);
std::vector<uint8_t> sig3;
uint256 hash3 = SignatureHash(
scriptPubKey, CTransaction(txTo), 0,
- SigHashType().withBaseType(BaseSigHashType::SINGLE), Amount(0));
+ SigHashType().withBaseType(BaseSigHashType::SINGLE), Amount::zero());
BOOST_CHECK(keys[2].Sign(hash3, sig3));
sig3.push_back(SIGHASH_SINGLE);
diff --git a/src/test/sighash_tests.cpp b/src/test/sighash_tests.cpp
--- a/src/test/sighash_tests.cpp
+++ b/src/test/sighash_tests.cpp
@@ -147,12 +147,12 @@
uint256 shref =
SignatureHashOld(scriptCode, CTransaction(txTo), nIn, nHashType);
uint256 shold = SignatureHash(scriptCode, CTransaction(txTo), nIn,
- sigHashType, Amount(0), nullptr, 0);
+ sigHashType, Amount::zero(), nullptr, 0);
BOOST_CHECK(shold == shref);
// Check the impact of the forkid flag.
uint256 shreg = SignatureHash(scriptCode, CTransaction(txTo), nIn,
- sigHashType, Amount(0));
+ sigHashType, Amount::zero());
if (sigHashType.hasForkId()) {
BOOST_CHECK(nHashType & SIGHASH_FORKID);
BOOST_CHECK(shreg != shref);
@@ -163,32 +163,32 @@
// Make sure replay protection works as expected.
uint256 shrep = SignatureHash(scriptCode, CTransaction(txTo), nIn,
- sigHashType, Amount(0), nullptr,
+ sigHashType, Amount::zero(), nullptr,
SCRIPT_ENABLE_SIGHASH_FORKID |
SCRIPT_ENABLE_REPLAY_PROTECTION);
uint32_t newForValue = 0xff0000 | ((nHashType >> 8) ^ 0xdead);
- uint256 manualshrep =
- SignatureHash(scriptCode, CTransaction(txTo), nIn,
- sigHashType.withForkValue(newForValue), Amount(0));
+ uint256 manualshrep = SignatureHash(
+ scriptCode, CTransaction(txTo), nIn,
+ sigHashType.withForkValue(newForValue), Amount::zero());
BOOST_CHECK(shrep == manualshrep);
// Replay protection works even if the hash is of the form 0xffxxxx
uint256 shrepff = SignatureHash(
scriptCode, CTransaction(txTo), nIn,
- sigHashType.withForkValue(newForValue), Amount(0), nullptr,
+ sigHashType.withForkValue(newForValue), Amount::zero(), nullptr,
SCRIPT_ENABLE_SIGHASH_FORKID | SCRIPT_ENABLE_REPLAY_PROTECTION);
uint256 manualshrepff = SignatureHash(
scriptCode, CTransaction(txTo), nIn,
- sigHashType.withForkValue(newForValue ^ 0xdead), Amount(0));
+ sigHashType.withForkValue(newForValue ^ 0xdead), Amount::zero());
BOOST_CHECK(shrepff == manualshrepff);
uint256 shrepabcdef = SignatureHash(
scriptCode, CTransaction(txTo), nIn,
- sigHashType.withForkValue(0xabcdef), Amount(0), nullptr,
+ sigHashType.withForkValue(0xabcdef), Amount::zero(), nullptr,
SCRIPT_ENABLE_SIGHASH_FORKID | SCRIPT_ENABLE_REPLAY_PROTECTION);
uint256 manualshrepabcdef =
SignatureHash(scriptCode, CTransaction(txTo), nIn,
- sigHashType.withForkValue(0xff1342), Amount(0));
+ sigHashType.withForkValue(0xff1342), Amount::zero());
BOOST_CHECK(shrepabcdef == manualshrepabcdef);
#if defined(PRINT_SIGHASH_JSON)
@@ -264,15 +264,15 @@
}
uint256 shreg =
- SignatureHash(scriptCode, *tx, nIn, sigHashType, Amount(0));
+ SignatureHash(scriptCode, *tx, nIn, sigHashType, Amount::zero());
BOOST_CHECK_MESSAGE(shreg.GetHex() == sigHashRegHex, strTest);
uint256 shold = SignatureHash(scriptCode, *tx, nIn, sigHashType,
- Amount(0), nullptr, 0);
+ Amount::zero(), nullptr, 0);
BOOST_CHECK_MESSAGE(shold.GetHex() == sigHashOldHex, strTest);
uint256 shrep = SignatureHash(
- scriptCode, *tx, nIn, sigHashType, Amount(0), nullptr,
+ scriptCode, *tx, nIn, sigHashType, Amount::zero(), nullptr,
SCRIPT_ENABLE_SIGHASH_FORKID | SCRIPT_ENABLE_REPLAY_PROTECTION);
BOOST_CHECK_MESSAGE(shrep.GetHex() == sigHashRepHex, strTest);
}
diff --git a/src/test/test_bitcoin.cpp b/src/test/test_bitcoin.cpp
--- a/src/test/test_bitcoin.cpp
+++ b/src/test/test_bitcoin.cpp
@@ -173,7 +173,7 @@
// Hack to assume either it's completely dependent on other mempool txs or
// not at all.
Amount inChainValue =
- pool && pool->HasNoInputsOf(txn) ? txn.GetValueOut() : Amount(0);
+ pool && pool->HasNoInputsOf(txn) ? txn.GetValueOut() : Amount::zero();
return CTxMemPoolEntry(MakeTransactionRef(txn), nFee, nTime, dPriority,
nHeight, inChainValue, spendsCoinbase, sigOpCost,
diff --git a/src/test/txvalidationcache_tests.cpp b/src/test/txvalidationcache_tests.cpp
--- a/src/test/txvalidationcache_tests.cpp
+++ b/src/test/txvalidationcache_tests.cpp
@@ -29,7 +29,7 @@
CValidationState state;
return AcceptToMemoryPool(GetConfig(), mempool, state,
MakeTransactionRef(tx), false, nullptr, true,
- Amount(0));
+ Amount::zero());
}
BOOST_FIXTURE_TEST_CASE(tx_mempool_block_doublespend, TestChain100Setup) {
diff --git a/src/test/util_tests.cpp b/src/test/util_tests.cpp
--- a/src/test/util_tests.cpp
+++ b/src/test/util_tests.cpp
@@ -166,7 +166,7 @@
}
BOOST_AUTO_TEST_CASE(util_FormatMoney) {
- BOOST_CHECK_EQUAL(FormatMoney(Amount(0)), "0.00");
+ BOOST_CHECK_EQUAL(FormatMoney(Amount::zero()), "0.00");
BOOST_CHECK_EQUAL(FormatMoney(123456789 * (COIN / 10000)), "12345.6789");
BOOST_CHECK_EQUAL(FormatMoney(-1 * COIN), "-1.00");
@@ -192,7 +192,7 @@
BOOST_AUTO_TEST_CASE(util_ParseMoney) {
Amount ret(0);
BOOST_CHECK(ParseMoney("0.0", ret));
- BOOST_CHECK_EQUAL(ret, Amount(0));
+ BOOST_CHECK_EQUAL(ret, Amount::zero());
BOOST_CHECK(ParseMoney("12345.6789", ret));
BOOST_CHECK_EQUAL(ret, 123456789 * (COIN / 10000));
diff --git a/src/txmempool.cpp b/src/txmempool.cpp
--- a/src/txmempool.cpp
+++ b/src/txmempool.cpp
@@ -41,7 +41,7 @@
Amount nValueIn = tx->GetValueOut() + nFee;
assert(inChainInputValue <= nValueIn);
- feeDelta = Amount(0);
+ feeDelta = Amount::zero();
nCountWithAncestors = 1;
nSizeWithAncestors = GetTxSize();
@@ -427,7 +427,7 @@
std::map<uint256, TXModifier>::const_iterator pos = mapDeltas.find(hash);
if (pos != mapDeltas.end()) {
const TXModifier &deltas = pos->second;
- if (deltas.second != Amount(0)) {
+ if (deltas.second != Amount::zero()) {
mapTx.modify(newit, update_fee_delta(deltas.second));
}
}
@@ -1212,7 +1212,7 @@
LOCK(cs);
unsigned nTxnRemoved = 0;
- CFeeRate maxFeeRateRemoved(Amount(0));
+ CFeeRate maxFeeRateRemoved(Amount::zero());
while (!mapTx.empty() && DynamicMemoryUsage() > sizelimit) {
indexed_transaction_set::index<descendant_score>::type::iterator it =
mapTx.get<descendant_score>().begin();
@@ -1255,7 +1255,7 @@
}
}
- if (maxFeeRateRemoved > CFeeRate(Amount(0))) {
+ if (maxFeeRateRemoved > CFeeRate(Amount::zero())) {
LogPrint(BCLog::MEMPOOL,
"Removed %u txn, rolling minimum fee bumped to %s\n",
nTxnRemoved, maxFeeRateRemoved.ToString());
diff --git a/src/utilmoneystr.cpp b/src/utilmoneystr.cpp
--- a/src/utilmoneystr.cpp
+++ b/src/utilmoneystr.cpp
@@ -12,7 +12,7 @@
std::string FormatMoney(const Amount amt) {
// Note: not using straight sprintf here because we do NOT want localized
// number formatting.
- Amount amt_abs = amt > Amount(0) ? amt : -amt;
+ Amount amt_abs = amt > Amount::zero() ? amt : -amt;
std::string str = strprintf("%d.%08d", amt_abs / COIN, amt_abs % COIN);
// Right-trim excess zeros before the decimal point:
@@ -24,7 +24,7 @@
str.erase(str.size() - nTrim, nTrim);
}
- if (amt < Amount(0)) {
+ if (amt < Amount::zero()) {
str.insert((unsigned int)0, 1, '-');
}
return str;
@@ -45,7 +45,7 @@
if (*p == '.') {
p++;
Amount nMult = 10 * CENT;
- while (isdigit(*p) && (nMult > Amount(0))) {
+ while (isdigit(*p) && (nMult > Amount::zero())) {
nUnits += (*p++ - '0') * nMult;
nMult /= 10;
}
@@ -68,7 +68,7 @@
if (strWhole.size() > 10) {
return false;
}
- if (nUnits < Amount(0) || nUnits > COIN) {
+ if (nUnits < Amount::zero() || nUnits > COIN) {
return false;
}
diff --git a/src/validation.h b/src/validation.h
--- a/src/validation.h
+++ b/src/validation.h
@@ -454,7 +454,7 @@
CValidationState &state, const CTransactionRef &tx,
bool fLimitFree, bool *pfMissingInputs,
bool fOverrideMempoolLimit = false,
- const Amount nAbsurdFee = Amount(0));
+ const Amount nAbsurdFee = Amount::zero());
/** Convert CValidationState to a human-readable message for logging */
std::string FormatStateMessage(const CValidationState &state);
diff --git a/src/validation.cpp b/src/validation.cpp
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -436,7 +436,7 @@
// Check for negative or overflow output values
Amount nValueOut(0);
for (const auto &txout : tx.vout) {
- if (txout.nValue < Amount(0)) {
+ if (txout.nValue < Amount::zero()) {
return state.DoS(100, false, REJECT_INVALID,
"bad-txns-vout-negative");
}
@@ -833,7 +833,8 @@
gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) *
1000000)
.GetFee(nSize);
- if (mempoolRejectFee > Amount(0) && nModifiedFees < mempoolRejectFee) {
+ if (mempoolRejectFee > Amount::zero() &&
+ nModifiedFees < mempoolRejectFee) {
return state.DoS(0, false, REJECT_INSUFFICIENTFEE,
"mempool min fee not met", false,
strprintf("%d < %d", nFees, mempoolRejectFee));
@@ -877,7 +878,7 @@
dFreeCount += nSize;
}
- if (nAbsurdFee != Amount(0) && nFees > nAbsurdFee) {
+ if (nAbsurdFee != Amount::zero() && nFees > nAbsurdFee) {
return state.Invalid(false, REJECT_HIGHFEE, "absurdly-high-fee",
strprintf("%d > %d", nFees, nAbsurdFee));
}
@@ -1007,13 +1008,11 @@
/**
* (try to) add transaction to memory pool with a specified acceptance time.
*/
-static bool AcceptToMemoryPoolWithTime(const Config &config, CTxMemPool &pool,
- CValidationState &state,
- const CTransactionRef &tx,
- bool fLimitFree, bool *pfMissingInputs,
- int64_t nAcceptTime,
- bool fOverrideMempoolLimit = false,
- const Amount nAbsurdFee = Amount(0)) {
+static bool AcceptToMemoryPoolWithTime(
+ const Config &config, CTxMemPool &pool, CValidationState &state,
+ const CTransactionRef &tx, bool fLimitFree, bool *pfMissingInputs,
+ int64_t nAcceptTime, bool fOverrideMempoolLimit = false,
+ const Amount nAbsurdFee = Amount::zero()) {
std::vector<COutPoint> coins_to_uncache;
bool res = AcceptToMemoryPoolWorker(
config, pool, state, tx, fLimitFree, pfMissingInputs, nAcceptTime,
@@ -1185,7 +1184,7 @@
int halvings = nHeight / consensusParams.nSubsidyHalvingInterval;
// Force block reward to zero when right shift is undefined.
if (halvings >= 64) {
- return Amount(0);
+ return Amount::zero();
}
Amount nSubsidy = 50 * COIN;
@@ -1453,7 +1452,7 @@
// Tally transaction fees
Amount nTxFee = nValueIn - tx.GetValueOut();
- if (nTxFee < Amount(0)) {
+ if (nTxFee < Amount::zero()) {
return state.DoS(100, false, REJECT_INVALID, "bad-txns-fee-negative");
}
@@ -5375,7 +5374,7 @@
file >> nFeeDelta;
Amount amountdelta(nFeeDelta);
- if (amountdelta != Amount(0)) {
+ if (amountdelta != Amount::zero()) {
mempool.PrioritiseTransaction(tx->GetId(),
tx->GetId().ToString(),
prioritydummy, amountdelta);
diff --git a/src/wallet/coincontrol.h b/src/wallet/coincontrol.h
--- a/src/wallet/coincontrol.h
+++ b/src/wallet/coincontrol.h
@@ -33,8 +33,8 @@
fAllowOtherInputs = false;
fAllowWatchOnly = false;
setSelected.clear();
- nMinimumTotalFee = Amount(0);
- nFeeRate = CFeeRate(Amount(0));
+ nMinimumTotalFee = Amount::zero();
+ nFeeRate = CFeeRate(Amount::zero());
fOverrideFeeRate = false;
nConfirmTarget = 0;
}
diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp
--- a/src/wallet/rpcwallet.cpp
+++ b/src/wallet/rpcwallet.cpp
@@ -436,7 +436,7 @@
Amount curBalance = pwallet->GetBalance();
// Check amount
- if (nValue <= Amount(0)) {
+ if (nValue <= Amount::zero()) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid amount");
}
@@ -542,7 +542,7 @@
// Amount
Amount nAmount = AmountFromValue(request.params[1]);
- if (nAmount <= Amount(0)) {
+ if (nAmount <= Amount::zero()) {
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for send");
}
@@ -749,7 +749,7 @@
}
CScript scriptPubKey = GetScriptForDestination(dest);
if (!IsMine(*pwallet, scriptPubKey)) {
- return ValueFromAmount(Amount(0));
+ return ValueFromAmount(Amount::zero());
}
// Minimum confirmations
@@ -759,7 +759,7 @@
}
// Tally
- Amount nAmount(0);
+ Amount nAmount = Amount::zero();
for (const std::pair<uint256, CWalletTx> &pairWtx : pwallet->mapWallet) {
const CWalletTx &wtx = pairWtx.second;
@@ -830,7 +830,7 @@
pwallet->GetAccountAddresses(strAccount);
// Tally
- Amount nAmount(0);
+ Amount nAmount = Amount::zero();
for (const std::pair<uint256, CWalletTx> &pairWtx : pwallet->mapWallet) {
const CWalletTx &wtx = pairWtx.second;
CValidationState state;
@@ -999,7 +999,7 @@
std::string strFrom = AccountFromValue(request.params[0]);
std::string strTo = AccountFromValue(request.params[1]);
Amount nAmount = AmountFromValue(request.params[2]);
- if (nAmount <= Amount(0)) {
+ if (nAmount <= Amount::zero()) {
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for send");
}
if (request.params.size() > 3) {
@@ -1091,7 +1091,7 @@
"Invalid Bitcoin address");
}
Amount nAmount = AmountFromValue(request.params[2]);
- if (nAmount <= Amount(0)) {
+ if (nAmount <= Amount::zero()) {
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for send");
}
@@ -1236,7 +1236,7 @@
std::set<CTxDestination> destinations;
std::vector<CRecipient> vecSend;
- Amount totalAmount(0);
+ Amount totalAmount = Amount::zero();
std::vector<std::string> keys = sendTo.getKeys();
for (const std::string &name_ : keys) {
CTxDestination dest = DecodeDestination(name_, config.GetChainParams());
@@ -1255,7 +1255,7 @@
CScript scriptPubKey = GetScriptForDestination(dest);
Amount nAmount = AmountFromValue(sendTo[name_]);
- if (nAmount <= Amount(0)) {
+ if (nAmount <= Amount::zero()) {
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for send");
}
totalAmount += nAmount;
@@ -1371,7 +1371,7 @@
std::vector<uint256> txids;
bool fIsWatchonly;
tallyitem() {
- nAmount = Amount(0);
+ nAmount = Amount::zero();
nConf = std::numeric_limits<int>::max();
fIsWatchonly = false;
}
@@ -1446,7 +1446,7 @@
continue;
}
- Amount nAmount(0);
+ Amount nAmount = Amount::zero();
int nConf = std::numeric_limits<int>::max();
bool fIsWatchonly = false;
if (it != mapTally.end()) {
@@ -1629,7 +1629,7 @@
bool involvesWatchonly = wtx.IsFromMe(ISMINE_WATCH_ONLY);
// Sent
- if ((!listSent.empty() || nFee != Amount(0)) &&
+ if ((!listSent.empty() || nFee != Amount::zero()) &&
(fAllAccounts || strAccount == strSentAccount)) {
for (const COutputEntry &s : listSent) {
UniValue entry(UniValue::VOBJ);
@@ -1952,7 +1952,7 @@
pwallet->mapAddressBook) {
// This address belongs to me
if (IsMine(*pwallet, entry.first) & includeWatchonly) {
- mapAccountBalances[entry.second.name] = Amount(0);
+ mapAccountBalances[entry.second.name] = Amount::zero();
}
}
@@ -2255,8 +2255,8 @@
Amount nCredit = wtx.GetCredit(filter);
Amount nDebit = wtx.GetDebit(filter);
Amount nNet = nCredit - nDebit;
- Amount nFee =
- (wtx.IsFromMe(filter) ? wtx.tx->GetValueOut() - nDebit : Amount(0));
+ Amount nFee = (wtx.IsFromMe(filter) ? wtx.tx->GetValueOut() - nDebit
+ : Amount::zero());
entry.push_back(Pair("amount", ValueFromAmount(nNet - nFee)));
if (wtx.IsFromMe(filter)) {
@@ -3298,7 +3298,7 @@
bool includeWatching = false;
bool lockUnspents = false;
bool reserveChangeKey = true;
- CFeeRate feeRate = CFeeRate(Amount(0));
+ CFeeRate feeRate = CFeeRate(Amount::zero());
bool overrideEstimatedFeerate = false;
UniValue subtractFeeFromOutputs;
std::set<int> setSubtractFeeFromOutputs;
diff --git a/src/wallet/test/accounting_tests.cpp b/src/wallet/test/accounting_tests.cpp
--- a/src/wallet/test/accounting_tests.cpp
+++ b/src/wallet/test/accounting_tests.cpp
@@ -54,8 +54,8 @@
BOOST_CHECK(pwalletMain->nOrderPosNext == 3);
BOOST_CHECK(2 == results.size());
- BOOST_CHECK(results[Amount(0)].nTime == 1333333333);
- BOOST_CHECK(results[Amount(0)].strComment.empty());
+ BOOST_CHECK(results[Amount::zero()].nTime == 1333333333);
+ BOOST_CHECK(results[Amount::zero()].strComment.empty());
BOOST_CHECK(1 == vpwtx[0]->nOrderPos);
BOOST_CHECK(results[Amount(2)].nTime == 1333333336);
BOOST_CHECK(results[Amount(2)].strOtherAccount == "c");
@@ -69,7 +69,7 @@
BOOST_CHECK(results.size() == 3);
BOOST_CHECK(pwalletMain->nOrderPosNext == 4);
- BOOST_CHECK(results[Amount(0)].nTime == 1333333333);
+ BOOST_CHECK(results[Amount::zero()].nTime == 1333333333);
BOOST_CHECK(1 == vpwtx[0]->nOrderPos);
BOOST_CHECK(results[Amount(2)].nTime == 1333333336);
BOOST_CHECK(results[Amount(3)].nTime == 1333333330);
diff --git a/src/wallet/test/wallet_tests.cpp b/src/wallet/test/wallet_tests.cpp
--- a/src/wallet/test/wallet_tests.cpp
+++ b/src/wallet/test/wallet_tests.cpp
@@ -615,7 +615,7 @@
// Call GetImmatureCredit() once before adding the key to the wallet to
// cache the current immature credit amount, which is 0.
- BOOST_CHECK_EQUAL(wtx.GetImmatureCredit(), Amount(0));
+ BOOST_CHECK_EQUAL(wtx.GetImmatureCredit(), Amount::zero());
// Invalidate the cached value, add the key, and make sure a new immature
// credit amount is calculated.
diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h
--- a/src/wallet/wallet.h
+++ b/src/wallet/wallet.h
@@ -347,15 +347,15 @@
fImmatureWatchCreditCached = false;
fAvailableWatchCreditCached = false;
fChangeCached = false;
- nDebitCached = Amount(0);
- nCreditCached = Amount(0);
- nImmatureCreditCached = Amount(0);
- nAvailableCreditCached = Amount(0);
- nWatchDebitCached = Amount(0);
- nWatchCreditCached = Amount(0);
- nAvailableWatchCreditCached = Amount(0);
- nImmatureWatchCreditCached = Amount(0);
- nChangeCached = Amount(0);
+ nDebitCached = Amount::zero();
+ nCreditCached = Amount::zero();
+ nImmatureCreditCached = Amount::zero();
+ nAvailableCreditCached = Amount::zero();
+ nWatchDebitCached = Amount::zero();
+ nWatchCreditCached = Amount::zero();
+ nAvailableWatchCreditCached = Amount::zero();
+ nImmatureWatchCreditCached = Amount::zero();
+ nChangeCached = Amount::zero();
nOrderPos = -1;
}
@@ -436,7 +436,7 @@
const isminefilter &filter) const;
bool IsFromMe(const isminefilter &filter) const {
- return (GetDebit(filter) > Amount(0));
+ return (GetDebit(filter) > Amount::zero());
}
// True if only scriptSigs are different
@@ -530,7 +530,7 @@
CAccountingEntry() { SetNull(); }
void SetNull() {
- nCreditDebit = Amount(0);
+ nCreditDebit = Amount::zero();
nTime = 0;
strAccount.clear();
strOtherAccount.clear();
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -1400,7 +1400,7 @@
}
}
- return Amount(0);
+ return Amount::zero();
}
isminetype CWallet::IsMine(const CTxOut &txout) const {
@@ -1414,7 +1414,7 @@
": value out of range");
}
- return (IsMine(txout) & filter) ? txout.nValue : Amount(0);
+ return (IsMine(txout) & filter) ? txout.nValue : Amount::zero();
}
bool CWallet::IsChange(const CTxOut &txout) const {
@@ -1447,7 +1447,7 @@
": value out of range");
}
- return (IsChange(txout) ? txout.nValue : Amount(0));
+ return (IsChange(txout) ? txout.nValue : Amount::zero());
}
bool CWallet::IsMine(const CTransaction &tx) const {
@@ -1461,7 +1461,7 @@
}
bool CWallet::IsFromMe(const CTransaction &tx) const {
- return GetDebit(tx, ISMINE_ALL) > Amount(0);
+ return GetDebit(tx, ISMINE_ALL) > Amount::zero();
}
Amount CWallet::GetDebit(const CTransaction &tx,
@@ -1640,7 +1640,7 @@
std::list<COutputEntry> &listSent, Amount &nFee,
std::string &strSentAccount,
const isminefilter &filter) const {
- nFee = Amount(0);
+ nFee = Amount::zero();
listReceived.clear();
listSent.clear();
strSentAccount = strFromAccount;
@@ -1648,7 +1648,7 @@
// Compute fee:
Amount nDebit = GetDebit(filter);
// debit>0 means we signed/sent this transaction.
- if (nDebit > Amount(0)) {
+ if (nDebit > Amount::zero()) {
Amount nValueOut = tx->GetValueOut();
nFee = (nDebit - nValueOut);
}
@@ -1660,7 +1660,7 @@
// Only need to handle txouts if AT LEAST one of these is true:
// 1) they debit from us (sent)
// 2) the output is to us (received)
- if (nDebit > Amount(0)) {
+ if (nDebit > Amount::zero()) {
// Don't report 'change' txouts
if (pwallet->IsChange(txout)) {
continue;
@@ -1684,7 +1684,7 @@
// If we are debited by the transaction, add the output as a "sent"
// entry.
- if (nDebit > Amount(0)) {
+ if (nDebit > Amount::zero()) {
listSent.push_back(output);
}
@@ -1837,7 +1837,7 @@
Amount CWalletTx::GetDebit(const isminefilter &filter) const {
if (tx->vin.empty()) {
- return Amount(0);
+ return Amount::zero();
}
Amount debit(0);
@@ -1868,7 +1868,7 @@
// Must wait until coinbase is safely deep enough in the chain before
// valuing it.
if (IsCoinBase() && GetBlocksToMaturity() > 0) {
- return Amount(0);
+ return Amount::zero();
}
Amount credit(0);
@@ -1907,18 +1907,18 @@
return nImmatureCreditCached;
}
- return Amount(0);
+ return Amount::zero();
}
Amount CWalletTx::GetAvailableCredit(bool fUseCache) const {
if (pwallet == 0) {
- return Amount(0);
+ return Amount::zero();
}
// Must wait until coinbase is safely deep enough in the chain before
// valuing it.
if (IsCoinBase() && GetBlocksToMaturity() > 0) {
- return Amount(0);
+ return Amount::zero();
}
if (fUseCache && fAvailableCreditCached) {
@@ -1954,18 +1954,18 @@
return nImmatureWatchCreditCached;
}
- return Amount(0);
+ return Amount::zero();
}
Amount CWalletTx::GetAvailableWatchOnlyCredit(const bool &fUseCache) const {
if (pwallet == 0) {
- return Amount(0);
+ return Amount::zero();
}
// Must wait until coinbase is safely deep enough in the chain before
// valuing it.
if (IsCoinBase() && GetBlocksToMaturity() > 0) {
- return Amount(0);
+ return Amount::zero();
}
if (fUseCache && fAvailableWatchCreditCached) {
@@ -2235,7 +2235,7 @@
// Loop through tx outputs and add incoming payments. For outgoing txs,
// treat change outputs specially, as part of the amount debited.
Amount debit = wtx.GetDebit(filter);
- const bool outgoing = debit > Amount(0);
+ const bool outgoing = debit > Amount::zero();
for (const CTxOut &out : wtx.tx->vout) {
if (outgoing && IsChange(out)) {
debit -= out.nValue;
@@ -2320,7 +2320,8 @@
isminetype mine = IsMine(pcoin->tx->vout[i]);
if (!(IsSpent(wtxid, i)) && mine != ISMINE_NO &&
!IsLockedCoin((*it).first, i) &&
- (pcoin->tx->vout[i].nValue > Amount(0) || fIncludeZeroValue) &&
+ (pcoin->tx->vout[i].nValue > Amount::zero() ||
+ fIncludeZeroValue) &&
(!coinControl || !coinControl->HasSelected() ||
coinControl->fAllowOtherInputs ||
coinControl->IsSelected(COutPoint((*it).first, i)))) {
@@ -2385,7 +2386,7 @@
std::set<std::pair<const CWalletTx *, unsigned int>> &setCoinsRet,
Amount &nValueRet) const {
setCoinsRet.clear();
- nValueRet = Amount(0);
+ nValueRet = Amount::zero();
// List of values less than target
std::pair<Amount, std::pair<const CWalletTx *, unsigned int>>
@@ -2671,7 +2672,7 @@
int nChangePosRequest = nChangePosInOut;
unsigned int nSubtractFeeFromAmount = 0;
for (const auto &recipient : vecSend) {
- if (nValue < Amount(0) || recipient.nAmount < Amount(0)) {
+ if (nValue < Amount::zero() || recipient.nAmount < Amount::zero()) {
strFailReason = _("Transaction amounts must not be negative");
return false;
}
@@ -2732,7 +2733,7 @@
std::vector<COutput> vAvailableCoins;
AvailableCoins(vAvailableCoins, true, coinControl);
- nFeeRet = Amount(0);
+ nFeeRet = Amount::zero();
// Start with no fee and loop until there is enough fee.
while (true) {
nChangePosInOut = nChangePosRequest;
@@ -2765,8 +2766,8 @@
if (txout.IsDust(dustRelayFee)) {
if (recipient.fSubtractFeeFromAmount &&
- nFeeRet > Amount(0)) {
- if (txout.nValue < Amount(0)) {
+ nFeeRet > Amount::zero()) {
+ if (txout.nValue < Amount::zero()) {
strFailReason = _("The transaction amount is "
"too small to pay the fee");
} else {
@@ -2810,7 +2811,7 @@
}
const Amount nChange = nValueIn - nValueToSelect;
- if (nChange > Amount(0)) {
+ if (nChange > Amount::zero()) {
// Fill a vout to ourself.
// TODO: pass in scriptChange instead of reservekey so change
// transaction isn't always pay-to-bitcoin-address.
@@ -2934,7 +2935,7 @@
Amount nFeeNeeded =
GetMinimumFee(nBytes, currentConfirmationTarget, mempool);
- if (coinControl && nFeeNeeded > Amount(0) &&
+ if (coinControl && nFeeNeeded > Amount::zero() &&
coinControl->nMinimumTotalFee > nFeeNeeded) {
nFeeNeeded = coinControl->nMinimumTotalFee;
}
@@ -3035,8 +3036,8 @@
DEFAULT_WALLET_REJECT_LONG_CHAINS)) {
// Lastly, ensure this tx will pass the mempool's chain limits.
LockPoints lp;
- CTxMemPoolEntry entry(wtxNew.tx, Amount(0), 0, 0, 0, Amount(0), false,
- 0, lp);
+ CTxMemPoolEntry entry(wtxNew.tx, Amount::zero(), 0, 0, 0,
+ Amount::zero(), false, 0, lp);
CTxMemPool::setEntries setAncestors;
size_t nLimitAncestors =
gArgs.GetArg("-limitancestorcount", DEFAULT_ANCESTOR_LIMIT);
@@ -3144,13 +3145,13 @@
const CTxMemPool &pool, Amount targetFee) {
Amount nFeeNeeded = targetFee;
// User didn't set: use -txconfirmtarget to estimate...
- if (nFeeNeeded == Amount(0)) {
+ if (nFeeNeeded == Amount::zero()) {
int estimateFoundTarget = nConfirmTarget;
nFeeNeeded = pool.estimateSmartFee(nConfirmTarget, &estimateFoundTarget)
.GetFee(nTxBytes);
// ... unless we don't have enough mempool data for estimatefee, then
// use fallbackFee.
- if (nFeeNeeded == Amount(0)) {
+ if (nFeeNeeded == Amount::zero()) {
nFeeNeeded = fallbackFee.GetFee(nTxBytes);
}
}
@@ -3575,11 +3576,11 @@
}
Amount n = IsSpent(walletEntry.first, i)
- ? Amount(0)
+ ? Amount::zero()
: pcoin->tx->vout[i].nValue;
if (!balances.count(addr)) {
- balances[addr] = Amount(0);
+ balances[addr] = Amount::zero();
}
balances[addr] += n;
}
@@ -4410,7 +4411,7 @@
if (gArgs.IsArgSet("-mintxfee")) {
Amount n(0);
auto parsed = ParseMoney(gArgs.GetArg("-mintxfee", ""), n);
- if (!parsed || Amount(0) == n) {
+ if (!parsed || Amount::zero() == n) {
return InitError(
AmountErrMsg("mintxfee", gArgs.GetArg("-mintxfee", "")));
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, May 12, 01:41 (3 h, 20 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5776903
Default Alt Text
D1706.id.diff (76 KB)
Attached To
D1706: Amount(0) => Amount::zero()
Event Timeline
Log In to Comment