diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -881,7 +881,7 @@ ss << *(const CScriptBase *)(&output.second.GetTxOut().scriptPubKey); ss << VARINT(output.second.GetTxOut().nValue.GetSatoshis()); stats.nTransactionOutputs++; - stats.nTotalAmount += output.second.GetTxOut().nValue.GetSatoshis(); + stats.nTotalAmount += output.second.GetTxOut().nValue; 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 @@ -331,7 +331,7 @@ LOCK(cs_main); uint256 hash = ParseHashStr(request.params[0].get_str(), "txid"); - Amount nAmount = request.params[2].get_int64(); + Amount nAmount(request.params[2].get_int64()); mempool.PrioritiseTransaction(hash, request.params[0].get_str(), request.params[1].get_real(), nAmount); @@ -948,7 +948,7 @@ } CFeeRate feeRate = mempool.estimateFee(nBlocks); - if (feeRate == CFeeRate(0)) { + if (feeRate == CFeeRate(Amount(0))) { return -1.0; } @@ -1022,9 +1022,10 @@ UniValue result(UniValue::VOBJ); int answerFound; CFeeRate feeRate = mempool.estimateSmartFee(nBlocks, &answerFound); - result.push_back(Pair( - "feerate", - feeRate == CFeeRate(0) ? -1.0 : ValueFromAmount(feeRate.GetFeePerK()))); + result.push_back( + Pair("feerate", feeRate == CFeeRate(Amount(0)) + ? -1.0 + : ValueFromAmount(feeRate.GetFeePerK()))); result.push_back(Pair("blocks", answerFound)); return result; } diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -538,7 +538,7 @@ std::vector data = ParseHexV(sendTo[name_].getValStr(), "Data"); - CTxOut out(0, CScript() << OP_RETURN << data); + CTxOut out(Amount(0), CScript() << OP_RETURN << data); rawTx.vout.push_back(out); } else { CTxDestination destination = DecodeDestination(name_); @@ -929,7 +929,7 @@ CTxOut txout; txout.scriptPubKey = scriptPubKey; - txout.nValue = 0; + txout.nValue = Amount(0); if (prevOut.exists("amount")) { txout.nValue = AmountFromValue(find_value(prevOut, "amount")); @@ -1115,7 +1115,7 @@ bool fLimitFree = false; Amount nMaxRawTxFee = maxTxFee; if (request.params.size() > 1 && request.params[1].get_bool()) { - nMaxRawTxFee = 0; + nMaxRawTxFee = Amount(0); } 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 @@ -114,12 +114,15 @@ Amount AmountFromValue(const UniValue &value) { if (!value.isNum() && !value.isStr()) throw JSONRPCError(RPC_TYPE_ERROR, "Amount is not a number or string"); - CAmount amount; - if (!ParseFixedPoint(value.getValStr(), 8, &amount)) + + int64_t n; + if (!ParseFixedPoint(value.getValStr(), 8, &n)) throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount"); - if (!MoneyRange(amount)) + + Amount amt(n); + if (!MoneyRange(amt)) throw JSONRPCError(RPC_TYPE_ERROR, "Amount out of range"); - return Amount(amount); + return amt; } UniValue ValueFromAmount(const Amount &amount) {