diff --git a/src/amount.cpp b/src/amount.cpp --- a/src/amount.cpp +++ b/src/amount.cpp @@ -10,8 +10,7 @@ const std::string CURRENCY_UNIT = "BCH"; std::string Amount::ToString() const { - return strprintf("%d.%08d %s", amount / COIN.GetSatoshis(), - amount % COIN.GetSatoshis(), CURRENCY_UNIT); + return strprintf("%d.%08d %s", *this / COIN, *this % COIN, CURRENCY_UNIT); } CFeeRate::CFeeRate(const Amount nFeePaid, size_t nBytes_) { @@ -44,7 +43,6 @@ } std::string CFeeRate::ToString() const { - return strprintf( - "%d.%08d %s/kB", nSatoshisPerK.GetSatoshis() / COIN.GetSatoshis(), - nSatoshisPerK.GetSatoshis() % COIN.GetSatoshis(), CURRENCY_UNIT); + return strprintf("%d.%08d %s/kB", nSatoshisPerK / COIN, + nSatoshisPerK % COIN, CURRENCY_UNIT); } diff --git a/src/primitives/transaction.cpp b/src/primitives/transaction.cpp --- a/src/primitives/transaction.cpp +++ b/src/primitives/transaction.cpp @@ -30,10 +30,8 @@ } std::string CTxOut::ToString() const { - return strprintf("CTxOut(nValue=%d.%08d, scriptPubKey=%s)", - nValue.GetSatoshis() / COIN.GetSatoshis(), - nValue.GetSatoshis() % COIN.GetSatoshis(), - HexStr(scriptPubKey).substr(0, 30)); + return strprintf("CTxOut(nValue=%d.%08d, scriptPubKey=%s)", nValue / COIN, + nValue % COIN, HexStr(scriptPubKey).substr(0, 30)); } CMutableTransaction::CMutableTransaction() @@ -124,4 +122,4 @@ for (unsigned int i = 0; i < vout.size(); i++) str += " " + vout[i].ToString() + "\n"; return str; -} \ No newline at end of file +} diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -131,11 +131,10 @@ } 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(); + bool sign = amount < Amount(0); + Amount n_abs(sign ? -amount : amount); + int64_t quotient = n_abs / COIN; + int64_t remainder = n_abs % COIN; return UniValue(UniValue::VNUM, strprintf("%s%d.%08d", sign ? "-" : "", quotient, remainder)); } diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp --- a/src/script/interpreter.cpp +++ b/src/script/interpreter.cpp @@ -1571,7 +1571,7 @@ // nSequence may already be contain in hashSequence. ss << txTo.vin[nIn].prevout; ss << scriptCode; - ss << amount.GetSatoshis(); + ss << amount; ss << txTo.vin[nIn].nSequence; // Outputs (none/one/all, depending on flags) ss << hashOutputs; 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 @@ -92,8 +92,8 @@ } } - BOOST_CHECK_EQUAL(COIN + COIN, Amount(2 * COIN)); - BOOST_CHECK_EQUAL(2 * COIN + COIN, Amount(3 * COIN)); + 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(COIN - COIN, Amount(0)); diff --git a/src/validation.cpp b/src/validation.cpp --- a/src/validation.cpp +++ b/src/validation.cpp @@ -5452,11 +5452,11 @@ uint64_t version = MEMPOOL_DUMP_VERSION; file << version; - file << (uint64_t)vinfo.size(); + file << uint64_t(vinfo.size()); for (const auto &i : vinfo) { file << *(i.tx); - file << (int64_t)i.nTime; - file << (int64_t)i.nFeeDelta.GetSatoshis(); + file << int64_t(i.nTime); + file << i.nFeeDelta; mapDeltas.erase(i.tx->GetId()); }