Page MenuHomePhabricator

D577.id1514.diff
No OneTemporary

D577.id1514.diff

diff --git a/src/amount.h b/src/amount.h
--- a/src/amount.h
+++ b/src/amount.h
@@ -111,37 +111,37 @@
* for the creation of coins out of thin air modification could lead to a fork.
*/
static const Amount MAX_MONEY = 21000000 * COIN;
-inline bool MoneyRange(const CAmount &nValue) {
+inline bool MoneyRange(const Amount nValue) {
return (nValue >= 0 && nValue <= MAX_MONEY);
}
/**
- * Fee rate in satoshis per kilobyte: CAmount / kB
+ * Fee rate in satoshis per kilobyte: Amount / kB
*/
class CFeeRate {
private:
// unit is satoshis-per-1,000-bytes
- CAmount nSatoshisPerK;
+ Amount nSatoshisPerK;
public:
/** Fee rate of 0 satoshis per kB */
CFeeRate() : nSatoshisPerK(0) {}
- explicit CFeeRate(const CAmount &_nSatoshisPerK)
+ explicit CFeeRate(const Amount _nSatoshisPerK)
: nSatoshisPerK(_nSatoshisPerK) {}
/**
* Constructor for a fee rate in satoshis per kB. The size in bytes must not
* exceed (2^63 - 1)
*/
- CFeeRate(const CAmount &nFeePaid, size_t nBytes);
+ CFeeRate(const Amount nFeePaid, size_t nBytes);
CFeeRate(const CFeeRate &other) { nSatoshisPerK = other.nSatoshisPerK; }
/**
* Return the fee in satoshis for the given size in bytes.
*/
- CAmount GetFee(size_t nBytes) const;
+ Amount GetFee(size_t nBytes) const;
/**
* Return the fee in satoshis for a size of 1000 bytes
*/
- CAmount GetFeePerK() const { return GetFee(1000); }
+ Amount GetFeePerK() const { return GetFee(1000); }
friend bool operator<(const CFeeRate &a, const CFeeRate &b) {
return a.nSatoshisPerK < b.nSatoshisPerK;
}
diff --git a/src/amount.cpp b/src/amount.cpp
--- a/src/amount.cpp
+++ b/src/amount.cpp
@@ -14,29 +14,29 @@
amount % COIN.GetSatoshis(), CURRENCY_UNIT);
}
-CFeeRate::CFeeRate(const CAmount &nFeePaid, size_t nBytes_) {
+CFeeRate::CFeeRate(const Amount nFeePaid, size_t nBytes_) {
assert(nBytes_ <= uint64_t(std::numeric_limits<int64_t>::max()));
int64_t nSize = int64_t(nBytes_);
if (nSize > 0) {
- nSatoshisPerK = nFeePaid * 1000 / nSize;
+ nSatoshisPerK = 1000 * nFeePaid / nSize;
} else {
nSatoshisPerK = 0;
}
}
-CAmount CFeeRate::GetFee(size_t nBytes_) const {
+Amount CFeeRate::GetFee(size_t nBytes_) const {
assert(nBytes_ <= uint64_t(std::numeric_limits<int64_t>::max()));
int64_t nSize = int64_t(nBytes_);
- CAmount nFee = nSatoshisPerK * nSize / 1000;
+ Amount nFee = nSize * nSatoshisPerK / 1000;
if (nFee == 0 && nSize != 0) {
if (nSatoshisPerK > 0) {
- nFee = CAmount(1);
+ nFee = Amount(1);
}
if (nSatoshisPerK < 0) {
- nFee = CAmount(-1);
+ nFee = Amount(-1);
}
}
@@ -44,6 +44,7 @@
}
std::string CFeeRate::ToString() const {
- return strprintf("%d.%08d %s/kB", nSatoshisPerK / COIN.GetSatoshis(),
- nSatoshisPerK % COIN.GetSatoshis(), CURRENCY_UNIT);
+ return strprintf(
+ "%d.%08d %s/kB", nSatoshisPerK.GetSatoshis() / COIN.GetSatoshis(),
+ nSatoshisPerK.GetSatoshis() % COIN.GetSatoshis(), CURRENCY_UNIT);
}
diff --git a/src/bench/mempool_eviction.cpp b/src/bench/mempool_eviction.cpp
--- a/src/bench/mempool_eviction.cpp
+++ b/src/bench/mempool_eviction.cpp
@@ -19,7 +19,8 @@
LockPoints lp;
pool.addUnchecked(tx.GetId(),
CTxMemPoolEntry(MakeTransactionRef(tx), nFee, nTime,
- dPriority, nHeight, tx.GetValueOut(),
+ dPriority, nHeight,
+ tx.GetValueOut().GetSatoshis(),
spendsCoinbase, sigOpCost, lp));
}
diff --git a/src/bitcoin-tx.cpp b/src/bitcoin-tx.cpp
--- a/src/bitcoin-tx.cpp
+++ b/src/bitcoin-tx.cpp
@@ -668,7 +668,7 @@
}
const CScript &prevPubKey = coin.GetTxOut().scriptPubKey;
- const CAmount &amount = coin.GetTxOut().nValue;
+ const CAmount amount = coin.GetTxOut().nValue.GetSatoshis();
SignatureData sigdata;
// Only sign SIGHASH_SINGLE if there's a corresponding output:
diff --git a/src/coins.cpp b/src/coins.cpp
--- a/src/coins.cpp
+++ b/src/coins.cpp
@@ -278,7 +278,7 @@
CAmount nResult = 0;
for (size_t i = 0; i < tx.vin.size(); i++) {
- nResult += GetOutputFor(tx.vin[i]).nValue;
+ nResult += GetOutputFor(tx.vin[i]).nValue.GetSatoshis();
}
return nResult;
@@ -311,9 +311,9 @@
continue;
}
if (int64_t(coin.GetHeight()) <= nHeight) {
- dResult +=
- double(coin.GetTxOut().nValue) * (nHeight - coin.GetHeight());
- inChainInputValue += coin.GetTxOut().nValue;
+ dResult += double(coin.GetTxOut().nValue.GetSatoshis()) *
+ (nHeight - coin.GetHeight());
+ inChainInputValue += coin.GetTxOut().nValue.GetSatoshis();
}
}
return tx.ComputePriority(dResult);
diff --git a/src/compressor.h b/src/compressor.h
--- a/src/compressor.h
+++ b/src/compressor.h
@@ -95,8 +95,8 @@
CTxOut &txout;
public:
- static uint64_t CompressAmount(uint64_t nAmount);
- static uint64_t DecompressAmount(uint64_t nAmount);
+ static uint64_t CompressAmount(Amount nAmount);
+ static Amount DecompressAmount(uint64_t nAmount);
CTxOutCompressor(CTxOut &txoutIn) : txout(txoutIn) {}
diff --git a/src/compressor.cpp b/src/compressor.cpp
--- a/src/compressor.cpp
+++ b/src/compressor.cpp
@@ -139,7 +139,8 @@
// - 1) + 9
// (this is decodable, as d is in [1-9] and e is in [0-9])
-uint64_t CTxOutCompressor::CompressAmount(uint64_t n) {
+uint64_t CTxOutCompressor::CompressAmount(Amount amt) {
+ uint64_t n = amt.GetSatoshis();
if (n == 0) {
return 0;
}
@@ -158,7 +159,7 @@
}
}
-uint64_t CTxOutCompressor::DecompressAmount(uint64_t x) {
+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 0;
@@ -181,5 +182,5 @@
n *= 10;
e--;
}
- return n;
+ return Amount(int64_t(n));
}
diff --git a/src/core_write.cpp b/src/core_write.cpp
--- a/src/core_write.cpp
+++ b/src/core_write.cpp
@@ -217,7 +217,8 @@
UniValue out(UniValue::VOBJ);
- UniValue outValue(UniValue::VNUM, FormatMoney(txout.nValue));
+ UniValue outValue(UniValue::VNUM,
+ FormatMoney(txout.nValue.GetSatoshis()));
out.pushKV("value", outValue);
out.pushKV("n", (int64_t)i);
diff --git a/src/miner.cpp b/src/miner.cpp
--- a/src/miner.cpp
+++ b/src/miner.cpp
@@ -107,7 +107,7 @@
ParseMoney(GetArg("-blockmintxfee", ""), n);
blockMinFeeRate = CFeeRate(n);
} else {
- blockMinFeeRate = CFeeRate(DEFAULT_BLOCK_MIN_TX_FEE);
+ blockMinFeeRate = CFeeRate(Amount(int64_t(DEFAULT_BLOCK_MIN_TX_FEE)));
}
LOCK(cs_main);
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -129,7 +129,7 @@
/** Expiration-time ordered list of (expire time, relay map entry) pairs,
* protected by cs_main). */
std::deque<std::pair<int64_t, MapRelay::iterator>> vRelayExpiration;
-} // anon namespace
+} // namespace
//////////////////////////////////////////////////////////////////////////////
//
@@ -667,7 +667,7 @@
}
}
-} // anon namespace
+} // namespace
bool GetNodeStateStats(NodeId nodeid, CNodeStateStats &stats) {
LOCK(cs_main);
@@ -3797,16 +3797,18 @@
GetBoolArg("-feefilter", DEFAULT_FEEFILTER) &&
!(pto->fWhitelisted &&
GetBoolArg("-whitelistforcerelay", DEFAULT_WHITELISTFORCERELAY))) {
- CAmount currentFilter =
+ Amount currentFilter =
mempool
.GetMinFee(GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) *
1000000)
.GetFeePerK();
int64_t timeNow = GetTimeMicros();
if (timeNow > pto->nextSendTimeFeeFilter) {
- static CFeeRate default_feerate(DEFAULT_MIN_RELAY_TX_FEE);
+ static CFeeRate default_feerate =
+ CFeeRate(Amount(int64_t(DEFAULT_MIN_RELAY_TX_FEE)));
static FeeFilterRounder filterRounder(default_feerate);
- CAmount filterToSend = filterRounder.round(currentFilter);
+ Amount filterToSend =
+ filterRounder.round(currentFilter.GetSatoshis());
// If we don't allow free transactions, then we always have a fee
// filter of at least minRelayTxFee
if (GetArg("-limitfreerelay", DEFAULT_LIMITFREERELAY) <= 0) {
@@ -3817,7 +3819,7 @@
if (filterToSend != pto->lastSentFeeFilter) {
connman.PushMessage(
pto, msgMaker.Make(NetMsgType::FEEFILTER, filterToSend));
- pto->lastSentFeeFilter = filterToSend;
+ pto->lastSentFeeFilter = filterToSend.GetSatoshis();
}
pto->nextSendTimeFeeFilter =
PoissonNextSend(timeNow, AVG_FEEFILTER_BROADCAST_INTERVAL);
diff --git a/src/policy/fees.cpp b/src/policy/fees.cpp
--- a/src/policy/fees.cpp
+++ b/src/policy/fees.cpp
@@ -339,10 +339,11 @@
CBlockPolicyEstimator::CBlockPolicyEstimator(const CFeeRate &_minRelayFee)
: nBestSeenHeight(0), trackedTxs(0), untrackedTxs(0) {
static_assert(MIN_FEERATE > 0, "Min feerate must be nonzero");
- minTrackedFee = _minRelayFee < CFeeRate(MIN_FEERATE) ? CFeeRate(MIN_FEERATE)
- : _minRelayFee;
+ minTrackedFee = _minRelayFee < CFeeRate(Amount(int64_t(MIN_FEERATE)))
+ ? CFeeRate(Amount(int64_t(MIN_FEERATE)))
+ : _minRelayFee;
std::vector<double> vfeelist;
- for (double bucketBoundary = minTrackedFee.GetFeePerK();
+ for (double bucketBoundary = minTrackedFee.GetFeePerK().GetSatoshis();
bucketBoundary <= MAX_FEERATE; bucketBoundary *= FEE_SPACING) {
vfeelist.push_back(bucketBoundary);
}
@@ -383,7 +384,7 @@
mapMemPoolTxs[txid].blockHeight = txHeight;
mapMemPoolTxs[txid].bucketIndex =
- feeStats.NewTx(txHeight, double(feeRate.GetFeePerK()));
+ feeStats.NewTx(txHeight, double(feeRate.GetFeePerK().GetSatoshis()));
}
bool CBlockPolicyEstimator::processBlockTx(unsigned int nBlockHeight,
@@ -409,7 +410,8 @@
// Feerates are stored and reported as BCC-per-kb:
CFeeRate feeRate(entry->GetFee(), entry->GetTxSize());
- feeStats.Record(blocksToConfirm, (double)feeRate.GetFeePerK());
+ feeStats.Record(blocksToConfirm,
+ (double)feeRate.GetFeePerK().GetSatoshis());
return true;
}
@@ -467,7 +469,7 @@
return CFeeRate(0);
}
- return CFeeRate(median);
+ return CFeeRate(Amount(int64_t(median)));
}
CFeeRate CBlockPolicyEstimator::estimateSmartFee(int confTarget,
@@ -501,11 +503,11 @@
// If mempool is limiting txs , return at least the min feerate from the
// mempool
- CAmount minPoolFee =
+ Amount minPoolFee =
pool.GetMinFee(GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) *
1000000)
.GetFeePerK();
- if (minPoolFee > 0 && minPoolFee > median) {
+ if (minPoolFee > 0 && minPoolFee > int64_t(median)) {
return CFeeRate(minPoolFee);
}
@@ -513,7 +515,7 @@
return CFeeRate(0);
}
- return CFeeRate(median);
+ return CFeeRate(Amount(int64_t(median)));
}
double CBlockPolicyEstimator::estimatePriority(int confTarget) {
@@ -528,7 +530,7 @@
}
// If mempool is limiting txs, no priority txs are allowed
- CAmount minPoolFee =
+ Amount minPoolFee =
pool.GetMinFee(GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) *
1000000)
.GetFeePerK();
@@ -556,11 +558,11 @@
}
FeeFilterRounder::FeeFilterRounder(const CFeeRate &minIncrementalFee) {
- CAmount minFeeLimit =
- std::max(CAmount(1), minIncrementalFee.GetFeePerK() / 2);
+ Amount minFeeLimit =
+ std::max(Amount(1), minIncrementalFee.GetFeePerK() / 2);
feeset.insert(0);
- for (double bucketBoundary = minFeeLimit; bucketBoundary <= MAX_FEERATE;
- bucketBoundary *= FEE_SPACING) {
+ for (double bucketBoundary = minFeeLimit.GetSatoshis();
+ bucketBoundary <= MAX_FEERATE; bucketBoundary *= FEE_SPACING) {
feeset.insert(bucketBoundary);
}
}
diff --git a/src/policy/policy.cpp b/src/policy/policy.cpp
--- a/src/policy/policy.cpp
+++ b/src/policy/policy.cpp
@@ -140,6 +140,7 @@
return true;
}
-CFeeRate incrementalRelayFee = CFeeRate(DEFAULT_INCREMENTAL_RELAY_FEE);
-CFeeRate dustRelayFee = CFeeRate(DUST_RELAY_TX_FEE);
+CFeeRate incrementalRelayFee =
+ CFeeRate(Amount(int64_t(DEFAULT_INCREMENTAL_RELAY_FEE)));
+CFeeRate dustRelayFee = CFeeRate(Amount(int64_t(DUST_RELAY_TX_FEE)));
unsigned int nBytesPerSigOp = DEFAULT_BYTES_PER_SIGOP;
diff --git a/src/primitives/transaction.h b/src/primitives/transaction.h
--- a/src/primitives/transaction.h
+++ b/src/primitives/transaction.h
@@ -125,12 +125,12 @@
*/
class CTxOut {
public:
- CAmount nValue;
+ Amount nValue;
CScript scriptPubKey;
CTxOut() { SetNull(); }
- CTxOut(const CAmount &nValueIn, CScript scriptPubKeyIn);
+ CTxOut(const Amount &nValueIn, CScript scriptPubKeyIn);
ADD_SERIALIZE_METHODS;
@@ -147,7 +147,7 @@
bool IsNull() const { return (nValue == -1); }
- CAmount GetDustThreshold(const CFeeRate &minRelayTxFee) const {
+ Amount GetDustThreshold(const CFeeRate &minRelayTxFee) const {
// "Dust" is defined in terms of CTransaction::minRelayTxFee, which has
// units satoshis-per-kilobyte. If you'd pay more than 1/3 in fees to
// spend something, then we consider it dust. A typical spendable
@@ -269,7 +269,7 @@
uint256 GetHash() const;
// Return sum of txouts.
- CAmount GetValueOut() const;
+ Amount GetValueOut() const;
// GetValueIn() is a method on CCoinsViewCache, because
// inputs must be known to compute value in.
diff --git a/src/primitives/transaction.cpp b/src/primitives/transaction.cpp
--- a/src/primitives/transaction.cpp
+++ b/src/primitives/transaction.cpp
@@ -40,14 +40,15 @@
return str;
}
-CTxOut::CTxOut(const CAmount &nValueIn, CScript scriptPubKeyIn) {
+CTxOut::CTxOut(const Amount &nValueIn, CScript scriptPubKeyIn) {
nValue = nValueIn;
scriptPubKey = scriptPubKeyIn;
}
std::string CTxOut::ToString() const {
return strprintf("CTxOut(nValue=%d.%08d, scriptPubKey=%s)",
- nValue / COIN.GetSatoshis(), nValue % COIN.GetSatoshis(),
+ nValue.GetSatoshis() / COIN.GetSatoshis(),
+ nValue.GetSatoshis() % COIN.GetSatoshis(),
HexStr(scriptPubKey).substr(0, 30));
}
@@ -83,8 +84,8 @@
: nVersion(tx.nVersion), vin(std::move(tx.vin)), vout(std::move(tx.vout)),
nLockTime(tx.nLockTime), hash(ComputeHash()) {}
-CAmount CTransaction::GetValueOut() const {
- CAmount nValueOut = 0;
+Amount CTransaction::GetValueOut() const {
+ Amount nValueOut = 0;
for (std::vector<CTxOut>::const_iterator it(vout.begin()); it != vout.end();
++it) {
nValueOut += it->nValue;
diff --git a/src/qt/coincontroldialog.cpp b/src/qt/coincontroldialog.cpp
--- a/src/qt/coincontroldialog.cpp
+++ b/src/qt/coincontroldialog.cpp
@@ -493,11 +493,12 @@
nQuantity++;
// Amount
- nAmount += out.tx->tx->vout[out.i].nValue;
+ nAmount += out.tx->tx->vout[out.i].nValue.GetSatoshis();
// Priority
dPriorityInputs +=
- (double)out.tx->tx->vout[out.i].nValue * (out.nDepth + 1);
+ (double)out.tx->tx->vout[out.i].nValue.GetSatoshis() *
+ (out.nDepth + 1);
// Bytes
CTxDestination address;
@@ -563,7 +564,8 @@
if (txout.IsDust(dustRelayFee)) {
// dust-change will be raised until no dust
if (CoinControlDialog::fSubtractFeeFromAmount) {
- nChange = txout.GetDustThreshold(dustRelayFee);
+ nChange =
+ txout.GetDustThreshold(dustRelayFee).GetSatoshis();
} else {
nPayFee += nChange;
nChange = 0;
@@ -639,14 +641,14 @@
double dFeeVary;
if (payTxFee.GetFeePerK() > 0) {
dFeeVary = (double)std::max(CWallet::GetRequiredFee(1000),
- payTxFee.GetFeePerK()) /
+ payTxFee.GetFeePerK().GetSatoshis()) /
1000;
} else {
- dFeeVary =
- (double)std::max(
- CWallet::GetRequiredFee(1000),
- mempool.estimateSmartFee(nTxConfirmTarget).GetFeePerK()) /
- 1000;
+ dFeeVary = (double)std::max(CWallet::GetRequiredFee(1000),
+ mempool.estimateSmartFee(nTxConfirmTarget)
+ .GetFeePerK()
+ .GetSatoshis()) /
+ 1000;
}
QString toolTip4 =
tr("Can vary +/- %1 satoshi(s) per input.").arg(dFeeVary);
@@ -724,7 +726,7 @@
CAmount nSum = 0;
int nChildren = 0;
for (const COutput &out : coins.second) {
- nSum += out.tx->tx->vout[out.i].nValue;
+ nSum += out.tx->tx->vout[out.i].nValue.GetSatoshis();
nChildren++;
CCoinControlWidgetItem *itemOutput;
@@ -769,12 +771,14 @@
// amount
itemOutput->setText(
COLUMN_AMOUNT,
- BitcoinUnits::format(nDisplayUnit,
- out.tx->tx->vout[out.i].nValue));
+ BitcoinUnits::format(
+ nDisplayUnit,
+ out.tx->tx->vout[out.i].nValue.GetSatoshis()));
// padding so that sorting works correctly
itemOutput->setData(
COLUMN_AMOUNT, Qt::UserRole,
- QVariant((qlonglong)out.tx->tx->vout[out.i].nValue));
+ QVariant(
+ (qlonglong)out.tx->tx->vout[out.i].nValue.GetSatoshis()));
// date
itemOutput->setText(COLUMN_DATE,
diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp
--- a/src/qt/sendcoinsdialog.cpp
+++ b/src/qt/sendcoinsdialog.cpp
@@ -721,7 +721,7 @@
ui->labelSmartFee->setText(
BitcoinUnits::formatWithUnit(
model->getOptionsModel()->getDisplayUnit(),
- std::max(CWallet::fallbackFee.GetFeePerK(),
+ std::max(CWallet::fallbackFee.GetFeePerK().GetSatoshis(),
CWallet::GetRequiredFee(1000))) +
"/kB");
// (Smart fee not initialized yet. This usually takes a few blocks...)
@@ -731,7 +731,8 @@
ui->labelSmartFee->setText(
BitcoinUnits::formatWithUnit(
model->getOptionsModel()->getDisplayUnit(),
- std::max(feeRate.GetFeePerK(), CWallet::GetRequiredFee(1000))) +
+ std::max(feeRate.GetFeePerK().GetSatoshis(),
+ CWallet::GetRequiredFee(1000))) +
"/kB");
ui->labelSmartFee2->hide();
ui->labelFeeEstimation->setText(
diff --git a/src/qt/transactiondesc.cpp b/src/qt/transactiondesc.cpp
--- a/src/qt/transactiondesc.cpp
+++ b/src/qt/transactiondesc.cpp
@@ -205,15 +205,15 @@
}
}
- strHTML +=
- "<b>" + tr("Debit") + ":</b> " +
- BitcoinUnits::formatHtmlWithUnit(unit, -txout.nValue) +
- "<br>";
+ strHTML += "<b>" + tr("Debit") + ":</b> " +
+ BitcoinUnits::formatHtmlWithUnit(
+ unit, -txout.nValue.GetSatoshis()) +
+ "<br>";
if (toSelf)
- strHTML +=
- "<b>" + tr("Credit") + ":</b> " +
- BitcoinUnits::formatHtmlWithUnit(unit, txout.nValue) +
- "<br>";
+ strHTML += "<b>" + tr("Credit") + ":</b> " +
+ BitcoinUnits::formatHtmlWithUnit(
+ unit, txout.nValue.GetSatoshis()) +
+ "<br>";
}
if (fAllToMe) {
@@ -228,10 +228,11 @@
"<br>";
}
- CAmount nTxFee = nDebit - wtx.tx->GetValueOut();
+ Amount nTxFee = nDebit - wtx.tx->GetValueOut();
if (nTxFee > 0)
strHTML += "<b>" + tr("Transaction fee") + ":</b> " +
- BitcoinUnits::formatHtmlWithUnit(unit, -nTxFee) +
+ BitcoinUnits::formatHtmlWithUnit(
+ unit, -nTxFee.GetSatoshis()) +
"<br>";
} else {
//
@@ -355,7 +356,8 @@
QString::fromStdString(EncodeDestination(address));
}
strHTML = strHTML + " " + tr("Amount") + "=" +
- BitcoinUnits::formatHtmlWithUnit(unit, vout.nValue);
+ BitcoinUnits::formatHtmlWithUnit(
+ unit, vout.nValue.GetSatoshis());
strHTML =
strHTML + " IsMine=" +
(wallet->IsMine(vout) & ISMINE_SPENDABLE ? tr("true")
diff --git a/src/qt/transactionrecord.cpp b/src/qt/transactionrecord.cpp
--- a/src/qt/transactionrecord.cpp
+++ b/src/qt/transactionrecord.cpp
@@ -51,7 +51,7 @@
TransactionRecord sub(hash, nTime);
CTxDestination address;
sub.idx = i; // vout index
- sub.credit = txout.nValue;
+ sub.credit = txout.nValue.GetSatoshis();
sub.involvesWatchAddress = mine & ISMINE_WATCH_ONLY;
if (ExtractDestination(txout.scriptPubKey, address) &&
IsMine(*wallet, address)) {
@@ -101,7 +101,7 @@
//
// Debit
//
- CAmount nTxFee = nDebit - wtx.tx->GetValueOut();
+ Amount nTxFee = nDebit - wtx.tx->GetValueOut();
for (unsigned int nOut = 0; nOut < wtx.tx->vout.size(); nOut++) {
const CTxOut &txout = wtx.tx->vout[nOut];
@@ -126,10 +126,10 @@
sub.address = mapValue["to"];
}
- CAmount nValue = txout.nValue;
+ CAmount nValue = txout.nValue.GetSatoshis();
/* Add fee to first output */
if (nTxFee > 0) {
- nValue += nTxFee;
+ nValue += nTxFee.GetSatoshis();
nTxFee = 0;
}
sub.debit = -nValue;
diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp
--- a/src/qt/walletmodel.cpp
+++ b/src/qt/walletmodel.cpp
@@ -57,14 +57,14 @@
CAmount WalletModel::getBalance(const CCoinControl *coinControl) const {
if (coinControl) {
- CAmount nBalance = 0;
+ Amount nBalance = 0;
std::vector<COutput> vCoins;
wallet->AvailableCoins(vCoins, true, coinControl);
for (const COutput &out : vCoins) {
if (out.fSpendable) nBalance += out.tx->tx->vout[out.i].nValue;
}
- return nBalance;
+ return nBalance.GetSatoshis();
}
return wallet->GetBalance();
diff --git a/src/qt/walletmodeltransaction.cpp b/src/qt/walletmodeltransaction.cpp
--- a/src/qt/walletmodeltransaction.cpp
+++ b/src/qt/walletmodeltransaction.cpp
@@ -42,7 +42,7 @@
int i = 0;
for (SendCoinsRecipient &rcp : recipients) {
if (rcp.paymentRequest.IsInitialized()) {
- CAmount subtotal = 0;
+ Amount subtotal = 0;
const payments::PaymentDetails &details =
rcp.paymentRequest.getDetails();
for (int j = 0; j < details.outputs_size(); j++) {
@@ -52,11 +52,11 @@
subtotal += walletTransaction->tx->vout[i].nValue;
i++;
}
- rcp.amount = subtotal;
+ rcp.amount = subtotal.GetSatoshis();
} else {
// normal recipient (no payment request)
if (i == nChangePosRet) i++;
- rcp.amount = walletTransaction->tx->vout[i].nValue;
+ rcp.amount = walletTransaction->tx->vout[i].nValue.GetSatoshis();
i++;
}
}
diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp
--- a/src/rpc/blockchain.cpp
+++ b/src/rpc/blockchain.cpp
@@ -877,9 +877,9 @@
for (const auto output : outputs) {
ss << VARINT(output.first + 1);
ss << *(const CScriptBase *)(&output.second.GetTxOut().scriptPubKey);
- ss << VARINT(output.second.GetTxOut().nValue);
+ ss << VARINT(output.second.GetTxOut().nValue.GetSatoshis());
stats.nTransactionOutputs++;
- stats.nTotalAmount += output.second.GetTxOut().nValue;
+ stats.nTotalAmount += output.second.GetTxOut().nValue.GetSatoshis();
stats.nBogoSize +=
32 /* txid */ + 4 /* vout index */ + 4 /* height + coinbase */ +
8 /* amount */ + 2 /* scriptPubKey len */ +
diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp
--- a/src/rpc/mining.cpp
+++ b/src/rpc/mining.cpp
@@ -800,7 +800,8 @@
result.push_back(Pair("transactions", transactions));
result.push_back(Pair("coinbaseaux", aux));
result.push_back(
- Pair("coinbasevalue", (int64_t)pblock->vtx[0]->vout[0].nValue));
+ Pair("coinbasevalue",
+ (int64_t)pblock->vtx[0]->vout[0].nValue.GetSatoshis()));
result.push_back(
Pair("longpollid", chainActive.Tip()->GetBlockHash().GetHex() +
i64tostr(nTransactionsUpdatedLast)));
diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp
--- a/src/rpc/rawtransaction.cpp
+++ b/src/rpc/rawtransaction.cpp
@@ -555,7 +555,7 @@
}
CScript scriptPubKey = GetScriptForDestination(destination);
- CAmount nAmount = AmountFromValue(sendTo[name_]);
+ CAmount nAmount = AmountFromValue(sendTo[name_]).GetSatoshis();
CTxOut out(nAmount, scriptPubKey);
rawTx.vout.push_back(out);
@@ -1027,7 +1027,7 @@
}
const CScript &prevPubKey = coin.GetTxOut().scriptPubKey;
- const CAmount &amount = coin.GetTxOut().nValue;
+ const CAmount &amount = coin.GetTxOut().nValue.GetSatoshis();
SignatureData sigdata;
// Only sign SIGHASH_SINGLE if there's a corresponding output:
diff --git a/src/rpc/server.h b/src/rpc/server.h
--- a/src/rpc/server.h
+++ b/src/rpc/server.h
@@ -27,7 +27,7 @@
void OnStopped(std::function<void()> slot);
void OnPreCommand(std::function<void(const CRPCCommand &)> slot);
void OnPostCommand(std::function<void(const CRPCCommand &)> slot);
-}
+} // namespace RPCServer
class CBlockIndex;
class Config;
@@ -191,9 +191,9 @@
UniValue execute(Config &config, const JSONRPCRequest &request) const;
/**
- * Returns a list of registered commands
- * @returns List of registered commands.
- */
+ * Returns a list of registered commands
+ * @returns List of registered commands.
+ */
std::vector<std::string> listCommands() const;
/**
@@ -217,8 +217,8 @@
extern std::vector<uint8_t> ParseHexO(const UniValue &o, std::string strKey);
extern int64_t nWalletUnlockTime;
-extern CAmount AmountFromValue(const UniValue &value);
-extern UniValue ValueFromAmount(const CAmount &amount);
+extern Amount AmountFromValue(const UniValue &value);
+extern UniValue ValueFromAmount(const Amount &amount);
extern double GetDifficulty(const CBlockIndex *blockindex = nullptr);
extern std::string HelpRequiringPassphrase();
extern std::string HelpExampleCli(const std::string &methodname,
diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp
--- a/src/rpc/server.cpp
+++ b/src/rpc/server.cpp
@@ -111,7 +111,7 @@
}
}
-CAmount AmountFromValue(const UniValue &value) {
+Amount AmountFromValue(const UniValue &value) {
if (!value.isNum() && !value.isStr())
throw JSONRPCError(RPC_TYPE_ERROR, "Amount is not a number or string");
CAmount amount;
@@ -119,12 +119,13 @@
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount");
if (!MoneyRange(amount))
throw JSONRPCError(RPC_TYPE_ERROR, "Amount out of range");
- return amount;
+ return Amount(amount);
}
-UniValue ValueFromAmount(const CAmount &amount) {
- bool sign = amount < 0;
- int64_t n_abs = (sign ? -amount : amount);
+UniValue ValueFromAmount(const Amount &amount) {
+ int64_t amt = amount.GetSatoshis();
+ bool sign = amt < 0;
+ int64_t n_abs = (sign ? -amt : amt);
int64_t quotient = n_abs / COIN.GetSatoshis();
int64_t remainder = n_abs % COIN.GetSatoshis();
return UniValue(UniValue::VNUM, strprintf("%s%d.%08d", sign ? "-" : "",
diff --git a/src/script/interpreter.h b/src/script/interpreter.h
--- a/src/script/interpreter.h
+++ b/src/script/interpreter.h
@@ -122,7 +122,7 @@
uint256 SignatureHash(const CScript &scriptCode, const CTransaction &txTo,
unsigned int nIn, uint32_t nHashType,
- const CAmount &amount,
+ const Amount &amount,
const PrecomputedTransactionData *cache = nullptr,
uint32_t flags = SCRIPT_ENABLE_SIGHASH_FORKID);
@@ -149,7 +149,7 @@
private:
const CTransaction *txTo;
unsigned int nIn;
- const CAmount amount;
+ const Amount amount;
const PrecomputedTransactionData *txdata;
protected:
@@ -159,10 +159,10 @@
public:
TransactionSignatureChecker(const CTransaction *txToIn, unsigned int nInIn,
- const CAmount &amountIn)
+ const Amount &amountIn)
: txTo(txToIn), nIn(nInIn), amount(amountIn), txdata(nullptr) {}
TransactionSignatureChecker(const CTransaction *txToIn, unsigned int nInIn,
- const CAmount &amountIn,
+ const Amount &amountIn,
const PrecomputedTransactionData &txdataIn)
: txTo(txToIn), nIn(nInIn), amount(amountIn), txdata(&txdataIn) {}
bool CheckSig(const std::vector<uint8_t> &scriptSig,
@@ -178,8 +178,7 @@
public:
MutableTransactionSignatureChecker(const CMutableTransaction *txToIn,
- unsigned int nInIn,
- const CAmount &amount)
+ unsigned int nInIn, const Amount &amount)
: TransactionSignatureChecker(&txTo, nInIn, amount), txTo(*txToIn) {}
};
diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp
--- a/src/script/interpreter.cpp
+++ b/src/script/interpreter.cpp
@@ -31,7 +31,7 @@
return false;
}
-} // anon namespace
+} // namespace
bool CastToBool(const valtype &vch) {
for (size_t i = 0; i < vch.size(); i++) {
@@ -1339,7 +1339,7 @@
return ss.GetHash();
}
-} // anon namespace
+} // namespace
PrecomputedTransactionData::PrecomputedTransactionData(
const CTransaction &txTo) {
@@ -1350,7 +1350,7 @@
uint256 SignatureHash(const CScript &scriptCode, const CTransaction &txTo,
unsigned int nIn, uint32_t nHashType,
- const CAmount &amount,
+ const Amount &amount,
const PrecomputedTransactionData *cache, uint32_t flags) {
if ((nHashType & SIGHASH_FORKID) &&
(flags & SCRIPT_ENABLE_SIGHASH_FORKID)) {
@@ -1389,7 +1389,7 @@
// nSequence may already be contain in hashSequence.
ss << txTo.vin[nIn].prevout;
ss << static_cast<const CScriptBase &>(scriptCode);
- ss << amount;
+ ss << amount.GetSatoshis();
ss << txTo.vin[nIn].nSequence;
// Outputs (none/one/all, depending on flags)
ss << hashOutputs;
diff --git a/src/script/sign.h b/src/script/sign.h
--- a/src/script/sign.h
+++ b/src/script/sign.h
@@ -42,7 +42,7 @@
public:
TransactionSignatureCreator(const CKeyStore *keystoreIn,
const CTransaction *txToIn, unsigned int nInIn,
- const CAmount &amountIn,
+ const CAmount amountIn,
uint32_t nHashTypeIn = SIGHASH_ALL);
const BaseSignatureChecker &Checker() const { return checker; }
bool CreateSig(std::vector<uint8_t> &vchSig, const CKeyID &keyid,
@@ -55,8 +55,7 @@
public:
MutableTransactionSignatureCreator(const CKeyStore *keystoreIn,
const CMutableTransaction *txToIn,
- unsigned int nInIn,
- const CAmount &amount,
+ unsigned int nInIn, const CAmount amount,
uint32_t nHashTypeIn)
: TransactionSignatureCreator(keystoreIn, &tx, nInIn, amount,
nHashTypeIn),
@@ -87,7 +86,7 @@
/** Produce a script signature for a transaction. */
bool SignSignature(const CKeyStore &keystore, const CScript &fromPubKey,
CMutableTransaction &txTo, unsigned int nIn,
- const CAmount &amount, uint32_t nHashType);
+ const CAmount amount, uint32_t nHashType);
bool SignSignature(const CKeyStore &keystore, const CTransaction &txFrom,
CMutableTransaction &txTo, unsigned int nIn,
uint32_t nHashType);
diff --git a/src/script/sign.cpp b/src/script/sign.cpp
--- a/src/script/sign.cpp
+++ b/src/script/sign.cpp
@@ -16,7 +16,7 @@
TransactionSignatureCreator::TransactionSignatureCreator(
const CKeyStore *keystoreIn, const CTransaction *txToIn, unsigned int nInIn,
- const CAmount &amountIn, uint32_t nHashTypeIn)
+ const CAmount amountIn, uint32_t nHashTypeIn)
: BaseSignatureCreator(keystoreIn), txTo(txToIn), nIn(nInIn),
amount(amountIn), nHashType(nHashTypeIn), checker(txTo, nIn, amountIn) {}
@@ -182,7 +182,7 @@
bool SignSignature(const CKeyStore &keystore, const CScript &fromPubKey,
CMutableTransaction &txTo, unsigned int nIn,
- const CAmount &amount, uint32_t nHashType) {
+ const CAmount amount, uint32_t nHashType) {
assert(nIn < txTo.vin.size());
CTransaction txToConst(txTo);
@@ -203,8 +203,8 @@
assert(txin.prevout.n < txFrom.vout.size());
const CTxOut &txout = txFrom.vout[txin.prevout.n];
- return SignSignature(keystore, txout.scriptPubKey, txTo, nIn, txout.nValue,
- nHashType);
+ return SignSignature(keystore, txout.scriptPubKey, txTo, nIn,
+ txout.nValue.GetSatoshis(), nHashType);
}
static std::vector<valtype> CombineMultisig(
@@ -283,7 +283,7 @@
return result;
}
};
-}
+} // namespace
static Stacks CombineSignatures(const CScript &scriptPubKey,
const BaseSignatureChecker &checker,
@@ -364,7 +364,7 @@
}
};
const DummySignatureChecker dummyChecker;
-}
+} // namespace
const BaseSignatureChecker &DummySignatureCreator::Checker() const {
return dummyChecker;
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
@@ -78,8 +78,8 @@
BOOST_CHECK_EQUAL(feeRate.GetFee(1), 1);
BOOST_CHECK_EQUAL(feeRate.GetFee(121), 121);
BOOST_CHECK_EQUAL(feeRate.GetFee(999), 999);
- BOOST_CHECK_EQUAL(feeRate.GetFee(1e3), 1e3);
- BOOST_CHECK_EQUAL(feeRate.GetFee(9e3), 9e3);
+ BOOST_CHECK_EQUAL(feeRate.GetFee(1000), 1000);
+ BOOST_CHECK_EQUAL(feeRate.GetFee(9000), 9000);
feeRate = CFeeRate(-1000);
// Must always just return -1 * arg
@@ -87,8 +87,8 @@
BOOST_CHECK_EQUAL(feeRate.GetFee(1), -1);
BOOST_CHECK_EQUAL(feeRate.GetFee(121), -121);
BOOST_CHECK_EQUAL(feeRate.GetFee(999), -999);
- BOOST_CHECK_EQUAL(feeRate.GetFee(1e3), -1e3);
- BOOST_CHECK_EQUAL(feeRate.GetFee(9e3), -9e3);
+ BOOST_CHECK_EQUAL(feeRate.GetFee(1000), -1000);
+ BOOST_CHECK_EQUAL(feeRate.GetFee(9000), -9000);
feeRate = CFeeRate(123);
// Truncates the result, if not integer
@@ -99,8 +99,8 @@
BOOST_CHECK_EQUAL(feeRate.GetFee(121), 14);
BOOST_CHECK_EQUAL(feeRate.GetFee(122), 15);
BOOST_CHECK_EQUAL(feeRate.GetFee(999), 122);
- BOOST_CHECK_EQUAL(feeRate.GetFee(1e3), 123);
- BOOST_CHECK_EQUAL(feeRate.GetFee(9e3), 1107);
+ BOOST_CHECK_EQUAL(feeRate.GetFee(1000), 123);
+ BOOST_CHECK_EQUAL(feeRate.GetFee(9000), 1107);
feeRate = CFeeRate(-123);
// Truncates the result, if not integer
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
@@ -156,7 +156,7 @@
if (insecure_rand() % 5 == 0 || coin.IsSpent()) {
CTxOut txout;
- txout.nValue = insecure_rand();
+ txout.nValue = Amount(int64_t(insecure_rand()));
if (insecure_rand() % 16 == 0 && coin.IsSpent()) {
txout.scriptPubKey.assign(1 + (insecure_rand() & 0x3F),
OP_RETURN);
@@ -295,7 +295,7 @@
std::set<COutPoint> duplicate_coins;
std::set<COutPoint> utxoset;
- for (unsigned int i = 0; i < NUM_SIMULATION_ITERATIONS; i++) {
+ for (int64_t i = 0; i < NUM_SIMULATION_ITERATIONS; i++) {
uint32_t randiter = insecure_rand();
// 19/20 txs add a new transaction
@@ -501,7 +501,7 @@
ss1 >> c1;
BOOST_CHECK_EQUAL(c1.IsCoinBase(), false);
BOOST_CHECK_EQUAL(c1.GetHeight(), 203998);
- BOOST_CHECK_EQUAL(c1.GetTxOut().nValue, 60000000000ULL);
+ BOOST_CHECK_EQUAL(c1.GetTxOut().nValue, Amount(60000000000LL));
BOOST_CHECK_EQUAL(HexStr(c1.GetTxOut().scriptPubKey),
HexStr(GetScriptForDestination(CKeyID(uint160(ParseHex(
"816115944e077fe7c803cfa57f29b36bf87c1d35"))))));
@@ -514,7 +514,7 @@
ss2 >> c2;
BOOST_CHECK_EQUAL(c2.IsCoinBase(), true);
BOOST_CHECK_EQUAL(c2.GetHeight(), 120891);
- BOOST_CHECK_EQUAL(c2.GetTxOut().nValue, 110397ULL);
+ BOOST_CHECK_EQUAL(c2.GetTxOut().nValue, Amount(110397LL));
BOOST_CHECK_EQUAL(HexStr(c2.GetTxOut().scriptPubKey),
HexStr(GetScriptForDestination(CKeyID(uint160(ParseHex(
"8c988f1a4a4de2161e0f50aac7f17e7f9555caa4"))))));
@@ -525,7 +525,7 @@
ss3 >> c3;
BOOST_CHECK_EQUAL(c3.IsCoinBase(), false);
BOOST_CHECK_EQUAL(c3.GetHeight(), 0);
- BOOST_CHECK_EQUAL(c3.GetTxOut().nValue, 0);
+ BOOST_CHECK_EQUAL(c3.GetTxOut().nValue, Amount(0));
BOOST_CHECK_EQUAL(c3.GetTxOut().scriptPubKey.size(), 0);
// scriptPubKey that ends beyond the end of the stream
@@ -601,7 +601,7 @@
if (it->second.coin.IsSpent()) {
value = PRUNED;
} else {
- value = it->second.coin.GetTxOut().nValue;
+ value = it->second.coin.GetTxOut().nValue.GetSatoshis();
}
flags = it->second.flags;
assert(flags != NO_ENTRY);
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
@@ -24,7 +24,7 @@
BOOST_FIXTURE_TEST_SUITE(compress_tests, BasicTestingSetup)
-static bool TestEncode(uint64_t in) {
+static bool TestEncode(Amount in) {
return in == CTxOutCompressor::DecompressAmount(
CTxOutCompressor::CompressAmount(in));
}
@@ -34,7 +34,7 @@
CTxOutCompressor::DecompressAmount(in));
}
-static bool TestPair(uint64_t dec, uint64_t enc) {
+static bool TestPair(Amount dec, uint64_t enc) {
return CTxOutCompressor::CompressAmount(dec) == enc &&
CTxOutCompressor::DecompressAmount(enc) == dec;
}
@@ -42,28 +42,28 @@
BOOST_AUTO_TEST_CASE(compress_amounts) {
BOOST_CHECK(TestPair(0, 0x0));
BOOST_CHECK(TestPair(1, 0x1));
- BOOST_CHECK(TestPair(CENT.GetSatoshis(), 0x7));
- BOOST_CHECK(TestPair(COIN.GetSatoshis(), 0x9));
- BOOST_CHECK(TestPair(50 * COIN.GetSatoshis(), 0x32));
- BOOST_CHECK(TestPair(21000000 * COIN.GetSatoshis(), 0x1406f40));
+ BOOST_CHECK(TestPair(CENT, 0x7));
+ BOOST_CHECK(TestPair(COIN, 0x9));
+ BOOST_CHECK(TestPair(50 * COIN, 0x32));
+ BOOST_CHECK(TestPair(21000000 * COIN, 0x1406f40));
- for (uint64_t i = 1; i <= NUM_MULTIPLES_UNIT; i++) {
+ for (int64_t i = 1; i <= NUM_MULTIPLES_UNIT; i++) {
BOOST_CHECK(TestEncode(i));
}
- for (uint64_t i = 1; i <= NUM_MULTIPLES_CENT; i++) {
- BOOST_CHECK(TestEncode(i * CENT.GetSatoshis()));
+ for (int64_t i = 1; i <= NUM_MULTIPLES_CENT; i++) {
+ BOOST_CHECK(TestEncode(i * CENT));
}
- for (uint64_t i = 1; i <= NUM_MULTIPLES_1BCC; i++) {
- BOOST_CHECK(TestEncode(i * COIN.GetSatoshis()));
+ for (int64_t i = 1; i <= NUM_MULTIPLES_1BCC; i++) {
+ BOOST_CHECK(TestEncode(i * COIN));
}
- for (uint64_t i = 1; i <= NUM_MULTIPLES_50BCC; i++) {
- BOOST_CHECK(TestEncode(i * 50 * COIN.GetSatoshis()));
+ for (int64_t i = 1; i <= NUM_MULTIPLES_50BCC; i++) {
+ BOOST_CHECK(TestEncode(i * 50 * COIN));
}
- for (uint64_t i = 0; i < 100000; i++) {
+ for (int64_t i = 0; i < 100000; i++) {
BOOST_CHECK(TestDecode(i));
}
}
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
@@ -27,7 +27,8 @@
BOOST_FIXTURE_TEST_SUITE(miner_tests, TestingSetup)
-static CFeeRate blockMinFeeRate = CFeeRate(DEFAULT_BLOCK_MIN_TX_FEE);
+static CFeeRate blockMinFeeRate =
+ CFeeRate(Amount(int64_t(DEFAULT_BLOCK_MIN_TX_FEE)));
static struct {
uint8_t extranonce;
@@ -138,7 +139,7 @@
// Calculate a fee on child transaction that will put the package just
// below the block min tx fee (assuming 1 child tx of the same size).
- CAmount feeToUse = blockMinFeeRate.GetFee(2 * freeTxSize) - 1;
+ CAmount feeToUse = blockMinFeeRate.GetFee(2 * freeTxSize).GetSatoshis() - 1;
tx.vin[0].prevout.hash = hashFreeTx;
tx.vout[0].nValue = 5000000000LL - 1000 - 50000 - feeToUse;
@@ -180,7 +181,7 @@
// This tx can't be mined by itself.
tx.vin[0].prevout.hash = hashFreeTx2;
tx.vout.resize(1);
- feeToUse = blockMinFeeRate.GetFee(freeTxSize);
+ feeToUse = blockMinFeeRate.GetFee(freeTxSize).GetSatoshis();
tx.vout[0].nValue = 5000000000LL - 100000000 - feeToUse;
uint256 hashLowFeeTx2 = tx.GetId();
mempool.addUnchecked(hashLowFeeTx2,
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
@@ -106,7 +106,7 @@
}
}
- std::vector<CAmount> origFeeEst;
+ std::vector<Amount> origFeeEst;
// Highest feerate is 10*baseRate and gets in all blocks, second highest
// feerate is 9*baseRate and gets in 9/10 blocks = 90%, third highest
// feerate is 8*base rate, and gets in 8/10 blocks = 80%, so estimateFee(1)
diff --git a/src/test/script_P2SH_tests.cpp b/src/test/script_P2SH_tests.cpp
--- a/src/test/script_P2SH_tests.cpp
+++ b/src/test/script_P2SH_tests.cpp
@@ -2,12 +2,12 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+#include "script/script.h"
#include "core_io.h"
#include "key.h"
#include "keystore.h"
#include "policy/policy.h"
#include "script/ismine.h"
-#include "script/script.h"
#include "script/script_error.h"
#include "script/sign.h"
#include "test/test_bitcoin.h"
@@ -38,12 +38,12 @@
txTo.vin[0].scriptSig = scriptSig;
txTo.vout[0].nValue = 1;
- return VerifyScript(
- scriptSig, scriptPubKey,
- (fStrict ? SCRIPT_VERIFY_P2SH : SCRIPT_VERIFY_NONE) |
- SCRIPT_ENABLE_SIGHASH_FORKID,
- MutableTransactionSignatureChecker(&txTo, 0, txFrom.vout[0].nValue),
- &err);
+ return VerifyScript(scriptSig, scriptPubKey,
+ (fStrict ? SCRIPT_VERIFY_P2SH : SCRIPT_VERIFY_NONE) |
+ SCRIPT_ENABLE_SIGHASH_FORKID,
+ MutableTransactionSignatureChecker(
+ &txTo, 0, txFrom.vout[0].nValue.GetSatoshis()),
+ &err);
}
BOOST_FIXTURE_TEST_SUITE(script_P2SH_tests, BasicTestingSetup)
@@ -111,11 +111,11 @@
CScript sigSave = txTo[i].vin[0].scriptSig;
txTo[i].vin[0].scriptSig = txTo[j].vin[0].scriptSig;
const CTxOut &output = txFrom.vout[txTo[i].vin[0].prevout.n];
- bool sigOK =
- CScriptCheck(output.scriptPubKey, output.nValue, txTo[i], 0,
- SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_STRICTENC |
- SCRIPT_ENABLE_SIGHASH_FORKID,
- false, txdata)();
+ bool sigOK = CScriptCheck(
+ output.scriptPubKey, output.nValue.GetSatoshis(), txTo[i], 0,
+ SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_STRICTENC |
+ SCRIPT_ENABLE_SIGHASH_FORKID,
+ false, txdata)();
if (i == j) {
BOOST_CHECK_MESSAGE(sigOK,
strprintf("VerifySignature %d %d", i, j));
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
@@ -152,7 +152,7 @@
static void DoTest(const CScript &scriptPubKey, const CScript &scriptSig,
int flags, const std::string &message, int scriptError,
- CAmount nValue) {
+ Amount nValue) {
bool expect = (scriptError == SCRIPT_ERR_OK);
if (flags & SCRIPT_VERIFY_CLEANSTACK) {
flags |= SCRIPT_VERIFY_P2SH;
@@ -160,14 +160,15 @@
ScriptError err;
CMutableTransaction txCredit =
- BuildCreditingTransaction(scriptPubKey, nValue);
+ BuildCreditingTransaction(scriptPubKey, nValue.GetSatoshis());
CMutableTransaction tx = BuildSpendingTransaction(scriptSig, txCredit);
CMutableTransaction tx2 = tx;
- BOOST_CHECK_MESSAGE(VerifyScript(scriptSig, scriptPubKey, flags,
- MutableTransactionSignatureChecker(
- &tx, 0, txCredit.vout[0].nValue),
- &err) == expect,
- message);
+ BOOST_CHECK_MESSAGE(
+ VerifyScript(scriptSig, scriptPubKey, flags,
+ MutableTransactionSignatureChecker(
+ &tx, 0, txCredit.vout[0].nValue.GetSatoshis()),
+ &err) == expect,
+ message);
BOOST_CHECK_MESSAGE(
err == scriptError,
std::string(FormatScriptError(err)) + " where " +
@@ -181,7 +182,7 @@
if (flags & bitcoinconsensus_SCRIPT_ENABLE_SIGHASH_FORKID) {
BOOST_CHECK_MESSAGE(bitcoinconsensus_verify_script_with_amount(
scriptPubKey.data(), scriptPubKey.size(),
- txCredit.vout[0].nValue,
+ txCredit.vout[0].nValue.GetSatoshis(),
(const uint8_t *)&stream[0], stream.size(),
0, libconsensus_flags, nullptr) == expect,
message);
@@ -408,7 +409,7 @@
return ret;
}
-}
+} // namespace
BOOST_AUTO_TEST_CASE(script_build) {
const KeyData keys;
@@ -1084,7 +1085,7 @@
for (unsigned int idx = 0; idx < tests.size(); idx++) {
UniValue test = tests[idx];
std::string strTest = test.write();
- CAmount nValue = 0;
+ Amount nValue = 0;
unsigned int pos = 0;
if (test.size() > 0 && test[pos].isArray()) {
nValue = AmountFromValue(test[pos][0]);
@@ -1107,7 +1108,7 @@
int scriptError = ParseScriptError(test[pos++].get_str());
DoTest(scriptPubKey, scriptSig, scriptflags, strTest, scriptError,
- nValue);
+ nValue.GetSatoshis());
}
}
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
@@ -111,7 +111,7 @@
for (int out = 0; out < outs; out++) {
tx.vout.push_back(CTxOut());
CTxOut &txout = tx.vout.back();
- txout.nValue = insecure_rand() % 100000000;
+ txout.nValue = Amount(int64_t(insecure_rand()) % 100000000);
RandomScript(txout.scriptPubKey);
}
}
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
@@ -174,12 +174,12 @@
CTxMemPool *pool) {
// Hack to assume either it's completely dependent on other mempool txs or
// not at all.
- CAmount inChainValue =
- pool && pool->HasNoInputsOf(txn) ? txn.GetValueOut() : 0;
+ Amount inChainValue =
+ pool && pool->HasNoInputsOf(txn) ? txn.GetValueOut() : Amount(0);
return CTxMemPoolEntry(MakeTransactionRef(txn), nFee, nTime, dPriority,
- nHeight, inChainValue, spendsCoinbase, sigOpCost,
- lp);
+ nHeight, inChainValue.GetSatoshis(), spendsCoinbase,
+ sigOpCost, lp);
}
void Shutdown(void *parg) {
diff --git a/src/test/transaction_tests.cpp b/src/test/transaction_tests.cpp
--- a/src/test/transaction_tests.cpp
+++ b/src/test/transaction_tests.cpp
@@ -113,12 +113,11 @@
uint32_t verify_flags = ParseScriptFlags(test[2].get_str());
BOOST_CHECK_MESSAGE(
- VerifyScript(
- tx.vin[i].scriptSig,
- mapprevOutScriptPubKeys[tx.vin[i].prevout],
- verify_flags,
- TransactionSignatureChecker(&tx, i, amount, txdata),
- &err),
+ VerifyScript(tx.vin[i].scriptSig,
+ mapprevOutScriptPubKeys[tx.vin[i].prevout],
+ verify_flags, TransactionSignatureChecker(
+ &tx, i, amount, txdata),
+ &err),
strTest);
BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_OK,
ScriptErrorString(err));
@@ -491,12 +490,11 @@
CheckWithFlag(output2, input2, 0, false);
BOOST_CHECK(*output1 == *output2);
UpdateTransaction(
- input1, 0,
- CombineSignatures(output1->vout[0].scriptPubKey,
- MutableTransactionSignatureChecker(
- &input1, 0, output1->vout[0].nValue),
- DataFromTransaction(input1, 0),
- DataFromTransaction(input2, 0)));
+ input1, 0, CombineSignatures(output1->vout[0].scriptPubKey,
+ MutableTransactionSignatureChecker(
+ &input1, 0, output1->vout[0].nValue),
+ DataFromTransaction(input1, 0),
+ DataFromTransaction(input2, 0)));
CheckWithFlag(output1, input1, STANDARD_SCRIPT_VERIFY_FLAGS, true);
// P2SH 2-of-2 multisig
@@ -512,12 +510,11 @@
CheckWithFlag(output2, input2, SCRIPT_VERIFY_P2SH, false);
BOOST_CHECK(*output1 == *output2);
UpdateTransaction(
- input1, 0,
- CombineSignatures(output1->vout[0].scriptPubKey,
- MutableTransactionSignatureChecker(
- &input1, 0, output1->vout[0].nValue),
- DataFromTransaction(input1, 0),
- DataFromTransaction(input2, 0)));
+ input1, 0, CombineSignatures(output1->vout[0].scriptPubKey,
+ MutableTransactionSignatureChecker(
+ &input1, 0, output1->vout[0].nValue),
+ DataFromTransaction(input1, 0),
+ DataFromTransaction(input2, 0)));
CheckWithFlag(output1, input1, SCRIPT_VERIFY_P2SH, true);
CheckWithFlag(output1, input1, STANDARD_SCRIPT_VERIFY_FLAGS, true);
}
@@ -545,8 +542,8 @@
BOOST_CHECK(IsStandardTx(t, reason));
// Check dust with default relay fee:
- CAmount nDustThreshold = 182 * dustRelayFee.GetFeePerK() / 1000 * 3;
- BOOST_CHECK_EQUAL(nDustThreshold, 546);
+ Amount nDustThreshold = 3 * 182 * dustRelayFee.GetFeePerK() / 1000;
+ BOOST_CHECK_EQUAL(nDustThreshold, Amount(546));
// dust:
t.vout[0].nValue = nDustThreshold - 1;
BOOST_CHECK(!IsStandardTx(t, reason));
@@ -563,7 +560,7 @@
// not dust:
t.vout[0].nValue = 672;
BOOST_CHECK(IsStandardTx(t, reason));
- dustRelayFee = CFeeRate(DUST_RELAY_TX_FEE);
+ dustRelayFee = CFeeRate(Amount(int64_t(DUST_RELAY_TX_FEE)));
t.vout[0].scriptPubKey = CScript() << OP_1;
BOOST_CHECK(!IsStandardTx(t, reason));
@@ -591,8 +588,8 @@
// Data payload can be encoded in any way...
t.vout[0].scriptPubKey = CScript() << OP_RETURN << ParseHex("");
BOOST_CHECK(IsStandardTx(t, reason));
- t.vout[0].scriptPubKey = CScript()
- << OP_RETURN << ParseHex("00") << ParseHex("01");
+ t.vout[0].scriptPubKey = CScript() << OP_RETURN << ParseHex("00")
+ << ParseHex("01");
BOOST_CHECK(IsStandardTx(t, reason));
// OP_RESERVED *is* considered to be a PUSHDATA type opcode by IsPushOnly()!
t.vout[0].scriptPubKey = CScript() << OP_RETURN << OP_RESERVED << -1 << 0
diff --git a/src/txmempool.cpp b/src/txmempool.cpp
--- a/src/txmempool.cpp
+++ b/src/txmempool.cpp
@@ -40,7 +40,7 @@
nCountWithDescendants = 1;
nSizeWithDescendants = GetTxSize();
nModFeesWithDescendants = nFee;
- CAmount nValueIn = tx->GetValueOut() + nFee;
+ Amount nValueIn = tx->GetValueOut() + nFee;
assert(inChainInputValue <= nValueIn);
feeDelta = 0;
@@ -837,7 +837,7 @@
return counta < countb;
}
};
-}
+} // namespace
std::vector<CTxMemPool::indexed_transaction_set::const_iterator>
CTxMemPool::GetSortedDepthAndScore() const {
@@ -1125,7 +1125,7 @@
CFeeRate CTxMemPool::GetMinFee(size_t sizelimit) const {
LOCK(cs);
if (!blockSinceLastRollingFeeBump || rollingMinimumFeeRate == 0)
- return CFeeRate(rollingMinimumFeeRate);
+ return CFeeRate(Amount(int64_t(rollingMinimumFeeRate)));
int64_t time = GetTime();
if (time > lastRollingFeeUpdate + 10) {
@@ -1141,18 +1141,19 @@
lastRollingFeeUpdate = time;
if (rollingMinimumFeeRate <
- (double)incrementalRelayFee.GetFeePerK() / 2) {
+ (double)incrementalRelayFee.GetFeePerK().GetSatoshis() / 2) {
rollingMinimumFeeRate = 0;
return CFeeRate(0);
}
}
- return std::max(CFeeRate(rollingMinimumFeeRate), incrementalRelayFee);
+ return std::max(CFeeRate(Amount(int64_t(rollingMinimumFeeRate))),
+ incrementalRelayFee);
}
void CTxMemPool::trackPackageRemoved(const CFeeRate &rate) {
AssertLockHeld(cs);
- if (rate.GetFeePerK() > rollingMinimumFeeRate) {
- rollingMinimumFeeRate = rate.GetFeePerK();
+ if (rate.GetFeePerK().GetSatoshis() > rollingMinimumFeeRate) {
+ rollingMinimumFeeRate = rate.GetFeePerK().GetSatoshis();
blockSinceLastRollingFeeBump = false;
}
}
diff --git a/src/validation.cpp b/src/validation.cpp
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -81,7 +81,7 @@
uint256 hashAssumeValid;
-CFeeRate minRelayTxFee = CFeeRate(DEFAULT_MIN_RELAY_TX_FEE);
+CFeeRate minRelayTxFee = CFeeRate(Amount(int64_t(DEFAULT_MIN_RELAY_TX_FEE)));
CAmount maxTxFee = DEFAULT_TRANSACTION_MAXFEE;
CTxMemPool mempool(::minRelayTxFee);
@@ -490,7 +490,7 @@
}
// Check for negative or overflow output values
- CAmount nValueOut = 0;
+ Amount nValueOut = 0;
for (const auto &txout : tx.vout) {
if (txout.nValue < 0) {
return state.DoS(100, false, REJECT_INVALID,
@@ -802,7 +802,7 @@
int64_t nSigOpsCount =
GetTransactionSigOpCount(tx, view, STANDARD_SCRIPT_VERIFY_FLAGS);
- CAmount nValueOut = tx.GetValueOut();
+ CAmount nValueOut = tx.GetValueOut().GetSatoshis();
CAmount nFees = nValueIn - nValueOut;
// nModifiedFees includes any fee deltas from PrioritiseTransaction
CAmount nModifiedFees = nFees;
@@ -843,7 +843,8 @@
CAmount mempoolRejectFee =
pool.GetMinFee(GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) *
1000000)
- .GetFee(nSize);
+ .GetFee(nSize)
+ .GetSatoshis();
if (mempoolRejectFee > 0 && nModifiedFees < mempoolRejectFee) {
return state.DoS(0, false, REJECT_INSUFFICIENTFEE,
"mempool min fee not met", false,
@@ -1382,7 +1383,7 @@
}
// Check for negative or overflow input values
- nValueIn += coin.GetTxOut().nValue;
+ nValueIn += coin.GetTxOut().nValue.GetSatoshis();
if (!MoneyRange(coin.GetTxOut().nValue) || !MoneyRange(nValueIn)) {
return state.DoS(100, false, REJECT_INVALID,
"bad-txns-inputvalues-outofrange");
@@ -1390,14 +1391,14 @@
}
if (nValueIn < tx.GetValueOut()) {
- return state.DoS(100, false, REJECT_INVALID, "bad-txns-in-belowout",
- false, strprintf("value in (%s) < value out (%s)",
- FormatMoney(nValueIn),
- FormatMoney(tx.GetValueOut())));
+ return state.DoS(
+ 100, false, REJECT_INVALID, "bad-txns-in-belowout", false,
+ strprintf("value in (%s) < value out (%s)", FormatMoney(nValueIn),
+ FormatMoney(tx.GetValueOut().GetSatoshis())));
}
// Tally transaction fees
- CAmount nTxFee = nValueIn - tx.GetValueOut();
+ CAmount nTxFee = nValueIn - tx.GetValueOut().GetSatoshis();
if (nTxFee < 0) {
return state.DoS(100, false, REJECT_INVALID, "bad-txns-fee-negative");
}
@@ -1458,7 +1459,7 @@
// additional data in, eg, the coins being spent being checked as a part
// of CScriptCheck.
const CScript &scriptPubKey = coin.GetTxOut().scriptPubKey;
- const CAmount amount = coin.GetTxOut().nValue;
+ const CAmount amount = coin.GetTxOut().nValue.GetSatoshis();
// Verify signature
CScriptCheck check(scriptPubKey, amount, tx, i, flags, sigCacheStore,
@@ -2047,7 +2048,8 @@
}
if (!tx.IsCoinBase()) {
- nFees += view.GetValueIn(tx) - tx.GetValueOut();
+ Amount fee = view.GetValueIn(tx) - tx.GetValueOut();
+ nFees += fee.GetSatoshis();
// Don't cache results if we're actually connecting blocks (still
// consult the cache, though).
diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp
--- a/src/wallet/rpcwallet.cpp
+++ b/src/wallet/rpcwallet.cpp
@@ -483,7 +483,7 @@
}
// Amount
- CAmount nAmount = AmountFromValue(request.params[1]);
+ CAmount nAmount = AmountFromValue(request.params[1]).GetSatoshis();
if (nAmount <= 0) {
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for send");
}
@@ -714,7 +714,7 @@
for (const CTxOut &txout : wtx.tx->vout) {
if (txout.scriptPubKey == scriptPubKey) {
if (wtx.GetDepthInMainChain() >= nMinDepth) {
- nAmount += txout.nValue;
+ nAmount += txout.nValue.GetSatoshis();
}
}
}
@@ -788,7 +788,7 @@
if (ExtractDestination(txout.scriptPubKey, address) &&
IsMine(*pwalletMain, address) && setAddress.count(address)) {
if (wtx.GetDepthInMainChain() >= nMinDepth) {
- nAmount += txout.nValue;
+ nAmount += txout.nValue.GetSatoshis();
}
}
}
@@ -978,7 +978,7 @@
std::string strFrom = AccountFromValue(request.params[0]);
std::string strTo = AccountFromValue(request.params[1]);
- CAmount nAmount = AmountFromValue(request.params[2]);
+ CAmount nAmount = AmountFromValue(request.params[2]).GetSatoshis();
if (nAmount <= 0) {
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for send");
}
@@ -1067,7 +1067,7 @@
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY,
"Invalid Bitcoin address");
}
- CAmount nAmount = AmountFromValue(request.params[2]);
+ CAmount nAmount = AmountFromValue(request.params[2]).GetSatoshis();
if (nAmount <= 0) {
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for send");
}
@@ -1230,7 +1230,7 @@
destinations.insert(dest);
CScript scriptPubKey = GetScriptForDestination(dest);
- CAmount nAmount = AmountFromValue(sendTo[name_]);
+ CAmount nAmount = AmountFromValue(sendTo[name_]).GetSatoshis();
if (nAmount <= 0) {
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for send");
}
@@ -1403,7 +1403,7 @@
}
tallyitem &item = mapTally[address];
- item.nAmount += txout.nValue;
+ item.nAmount += txout.nValue.GetSatoshis();
item.nConf = std::min(item.nConf, nDepth);
item.txids.push_back(wtx.GetId());
if (mine & ISMINE_WATCH_ONLY) {
@@ -2236,7 +2236,9 @@
CAmount nCredit = wtx.GetCredit(filter);
CAmount nDebit = wtx.GetDebit(filter);
CAmount nNet = nCredit - nDebit;
- CAmount nFee = (wtx.IsFromMe(filter) ? wtx.tx->GetValueOut() - nDebit : 0);
+ CAmount nFee =
+ (wtx.IsFromMe(filter) ? wtx.tx->GetValueOut() - nDebit : Amount(0))
+ .GetSatoshis();
entry.push_back(Pair("amount", ValueFromAmount(nNet - nFee)));
if (wtx.IsFromMe(filter)) {
@@ -2846,7 +2848,7 @@
LOCK2(cs_main, pwalletMain->cs_wallet);
// Amount
- CAmount nAmount = AmountFromValue(request.params[0]);
+ CAmount nAmount = AmountFromValue(request.params[0]).GetSatoshis();
payTxFee = CFeeRate(nAmount, 1000);
return true;
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -79,7 +79,7 @@
std::string COutput::ToString() const {
return strprintf("COutput(%s, %d, %d) [%s]", tx->GetId().ToString(), i,
- nDepth, FormatMoney(tx->tx->vout[i].nValue));
+ nDepth, FormatMoney(tx->tx->vout[i].nValue.GetSatoshis()));
}
const CWalletTx *CWallet::GetWalletTx(const uint256 &hash) const {
@@ -1369,7 +1369,7 @@
const CWalletTx &prev = (*mi).second;
if (txin.prevout.n < prev.tx->vout.size()) {
if (IsMine(prev.tx->vout[txin.prevout.n]) & filter) {
- return prev.tx->vout[txin.prevout.n].nValue;
+ return prev.tx->vout[txin.prevout.n].nValue.GetSatoshis();
}
}
}
@@ -1388,7 +1388,7 @@
": value out of range");
}
- return (IsMine(txout) & filter) ? txout.nValue : 0;
+ return (IsMine(txout) & filter) ? txout.nValue.GetSatoshis() : 0;
}
bool CWallet::IsChange(const CTxOut &txout) const {
@@ -1421,7 +1421,7 @@
": value out of range");
}
- return (IsChange(txout) ? txout.nValue : 0);
+ return (IsChange(txout) ? txout.nValue.GetSatoshis() : 0);
}
bool CWallet::IsMine(const CTransaction &tx) const {
@@ -1621,7 +1621,7 @@
CAmount nDebit = GetDebit(filter);
// debit>0 means we signed/sent this transaction.
if (nDebit > 0) {
- CAmount nValueOut = tx->GetValueOut();
+ CAmount nValueOut = tx->GetValueOut().GetSatoshis();
nFee = nDebit - nValueOut;
}
@@ -1652,7 +1652,7 @@
address = CNoDestination();
}
- COutputEntry output = {address, txout.nValue, (int)i};
+ COutputEntry output = {address, txout.nValue.GetSatoshis(), (int)i};
// If we are debited by the transaction, add the output as a "sent"
// entry.
@@ -2375,7 +2375,7 @@
}
int i = output.i;
- CAmount n = pcoin->tx->vout[i].nValue;
+ CAmount n = pcoin->tx->vout[i].nValue.GetSatoshis();
std::pair<CAmount, std::pair<const CWalletTx *, unsigned int>> coin =
std::make_pair(n, std::make_pair(pcoin, i));
@@ -2467,7 +2467,7 @@
continue;
}
- nValueRet += out.tx->tx->vout[out.i].nValue;
+ nValueRet += out.tx->tx->vout[out.i].nValue.GetSatoshis();
setCoinsRet.insert(std::make_pair(out.tx, out.i));
}
@@ -2497,7 +2497,8 @@
return false;
}
- nValueFromPresetInputs += pcoin->tx->vout[outpoint.n].nValue;
+ nValueFromPresetInputs +=
+ pcoin->tx->vout[outpoint.n].nValue.GetSatoshis();
setPresetCoins.insert(std::make_pair(pcoin, outpoint.n));
}
@@ -2565,7 +2566,7 @@
// Turn the txout set into a CRecipient vector.
for (size_t idx = 0; idx < tx.vout.size(); idx++) {
const CTxOut &txOut = tx.vout[idx];
- CRecipient recipient = {txOut.scriptPubKey, txOut.nValue,
+ CRecipient recipient = {txOut.scriptPubKey, txOut.nValue.GetSatoshis(),
setSubtractFeeFromOutputs.count(idx) == 1};
vecSend.push_back(recipient);
}
@@ -2750,7 +2751,8 @@
}
for (const auto &pcoin : setCoins) {
- CAmount nCredit = pcoin.first->tx->vout[pcoin.second].nValue;
+ CAmount nCredit =
+ pcoin.first->tx->vout[pcoin.second].nValue.GetSatoshis();
// The coin age after the next block (depth+1) is used instead
// of the current, reflecting an assumption the user would
// accept a bit more delay for a chance at a free transaction.
@@ -2807,8 +2809,8 @@
// change and deduct from the recipient.
if (nSubtractFeeFromAmount > 0 &&
newTxOut.IsDust(dustRelayFee)) {
- CAmount nDust = newTxOut.GetDustThreshold(dustRelayFee) -
- newTxOut.nValue;
+ Amount nDust = newTxOut.GetDustThreshold(dustRelayFee) -
+ newTxOut.nValue;
// Raise change until no more dust.
newTxOut.nValue += nDust;
// Subtract from first recipient.
@@ -2906,7 +2908,7 @@
}
if (coinControl && coinControl->fOverrideFeeRate) {
- nFeeNeeded = coinControl->nFeeRate.GetFee(nBytes);
+ nFeeNeeded = coinControl->nFeeRate.GetFee(nBytes).GetSatoshis();
}
// If we made it here and we aren't even able to meet the relay fee
@@ -2971,12 +2973,12 @@
coin.first->tx->vout[coin.second].scriptPubKey;
SignatureData sigdata;
- if (!ProduceSignature(
- TransactionSignatureCreator(
- this, &txNewConst, nIn,
- coin.first->tx->vout[coin.second].nValue,
- nHashType),
- scriptPubKey, sigdata)) {
+ if (!ProduceSignature(TransactionSignatureCreator(
+ this, &txNewConst, nIn,
+ coin.first->tx->vout[coin.second]
+ .nValue.GetSatoshis(),
+ nHashType),
+ scriptPubKey, sigdata)) {
strFailReason = _("Signing transaction failed");
return false;
} else {
@@ -3091,8 +3093,8 @@
}
CAmount CWallet::GetRequiredFee(unsigned int nTxBytes) {
- return std::max(minTxFee.GetFee(nTxBytes),
- ::minRelayTxFee.GetFee(nTxBytes));
+ return std::max(minTxFee.GetFee(nTxBytes), ::minRelayTxFee.GetFee(nTxBytes))
+ .GetSatoshis();
}
CAmount CWallet::GetMinimumFee(unsigned int nTxBytes,
@@ -3100,7 +3102,7 @@
const CTxMemPool &pool) {
// payTxFee is the user-set global for desired feerate.
return GetMinimumFee(nTxBytes, nConfirmTarget, pool,
- payTxFee.GetFee(nTxBytes));
+ payTxFee.GetFee(nTxBytes).GetSatoshis());
}
CAmount CWallet::GetMinimumFee(unsigned int nTxBytes,
@@ -3111,11 +3113,12 @@
if (nFeeNeeded == 0) {
int estimateFoundTarget = nConfirmTarget;
nFeeNeeded = pool.estimateSmartFee(nConfirmTarget, &estimateFoundTarget)
- .GetFee(nTxBytes);
+ .GetFee(nTxBytes)
+ .GetSatoshis();
// ... unless we don't have enough mempool data for estimatefee, then
// use fallbackFee.
if (nFeeNeeded == 0) {
- nFeeNeeded = fallbackFee.GetFee(nTxBytes);
+ nFeeNeeded = fallbackFee.GetFee(nTxBytes).GetSatoshis();
}
}
@@ -3468,11 +3471,11 @@
continue;
}
- CAmount n =
+ Amount n =
IsSpent(walletEntry.first, i) ? 0 : pcoin->tx->vout[i].nValue;
if (!balances.count(addr)) balances[addr] = 0;
- balances[addr] += n;
+ balances[addr] += n.GetSatoshis();
}
}
@@ -3931,7 +3934,7 @@
"-paytxfee=<amt>",
strprintf(
_("Fee (in %s/kB) to add to transactions you send (default: %s)"),
- CURRENCY_UNIT, FormatMoney(payTxFee.GetFeePerK())));
+ CURRENCY_UNIT, FormatMoney(payTxFee.GetFeePerK().GetSatoshis())));
strUsage += HelpMessageOpt(
"-rescan",
_("Rescan the block chain for missing wallet transactions on startup"));
@@ -4401,7 +4404,6 @@
LogPrintf("cannot backup to wallet source file %s\n",
pathDest.string());
return false;
-
}
#if BOOST_VERSION >= 104000

File Metadata

Mime Type
text/plain
Expires
Sat, Apr 26, 10:35 (3 h, 18 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5573288
Default Alt Text
D577.id1514.diff (70 KB)

Event Timeline