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 @@ -9,7 +9,7 @@ #include #include -static void AddTx(const CTransaction &tx, const CAmount &nFee, +static void AddTx(const CTransaction &tx, const Amount &nFee, CTxMemPool &pool) { int64_t nTime = 0; double dPriority = 10.0; 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 @@ -9,7 +9,7 @@ BOOST_FIXTURE_TEST_SUITE(amount_tests, BasicTestingSetup) -BOOST_AUTO_TEST_CASE(CAmountTests) { +BOOST_AUTO_TEST_CASE(AmountTests) { BOOST_CHECK(Amount(2) <= Amount(2)); BOOST_CHECK(Amount(2) <= Amount(3)); 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 @@ -552,12 +552,12 @@ } static const COutPoint OUTPOINT; -static const CAmount PRUNED = -1; -static const CAmount ABSENT = -2; -static const CAmount FAIL = -3; -static const CAmount VALUE1 = 100; -static const CAmount VALUE2 = 200; -static const CAmount VALUE3 = 300; +static const Amount PRUNED = -1; +static const Amount ABSENT = -2; +static const Amount FAIL = -3; +static const Amount VALUE1 = 100; +static const Amount VALUE2 = 200; +static const Amount VALUE3 = 300; static const char DIRTY = CCoinsCacheEntry::DIRTY; static const char FRESH = CCoinsCacheEntry::FRESH; static const char NO_ENTRY = -1; @@ -566,7 +566,7 @@ static const auto CLEAN_FLAGS = {char(0), FRESH}; static const auto ABSENT_FLAGS = {NO_ENTRY}; -static void SetCoinValue(CAmount value, Coin &coin) { +static void SetCoinValue(const Amount value, Coin &coin) { assert(value != ABSENT); coin.Clear(); assert(coin.IsSpent()); @@ -578,7 +578,7 @@ } } -size_t InsertCoinMapEntry(CCoinsMap &map, CAmount value, char flags) { +size_t InsertCoinMapEntry(CCoinsMap &map, const Amount value, char flags) { if (value == ABSENT) { assert(flags == NO_ENTRY); return 0; @@ -592,7 +592,7 @@ return inserted.first->second.coin.DynamicMemoryUsage(); } -void GetCoinMapEntry(const CCoinsMap &map, CAmount &value, char &flags) { +void GetCoinMapEntry(const CCoinsMap &map, Amount &value, char &flags) { auto it = map.find(OUTPOINT); if (it == map.end()) { value = ABSENT; @@ -608,7 +608,7 @@ } } -void WriteCoinViewEntry(CCoinsView &view, CAmount value, char flags) { +void WriteCoinViewEntry(CCoinsView &view, const Amount value, char flags) { CCoinsMap map; InsertCoinMapEntry(map, value, flags); view.BatchWrite(map, {}); @@ -616,7 +616,7 @@ class SingleEntryCacheTest { public: - SingleEntryCacheTest(CAmount base_value, CAmount cache_value, + SingleEntryCacheTest(const Amount base_value, const Amount cache_value, char cache_flags) { WriteCoinViewEntry(base, base_value, base_value == ABSENT ? NO_ENTRY : DIRTY); @@ -629,14 +629,14 @@ CCoinsViewCacheTest cache{&base}; }; -void CheckAccessCoin(CAmount base_value, CAmount cache_value, - CAmount expected_value, char cache_flags, +void CheckAccessCoin(const Amount base_value, const Amount cache_value, + const Amount expected_value, char cache_flags, char expected_flags) { SingleEntryCacheTest test(base_value, cache_value, cache_flags); test.cache.AccessCoin(OUTPOINT); test.cache.SelfTest(); - CAmount result_value; + Amount result_value; char result_flags; GetCoinMapEntry(test.cache.map(), result_value, result_flags); BOOST_CHECK_EQUAL(result_value, expected_value); @@ -680,14 +680,14 @@ CheckAccessCoin(VALUE1, VALUE2, VALUE2, DIRTY | FRESH, DIRTY | FRESH); } -void CheckSpendCoin(CAmount base_value, CAmount cache_value, - CAmount expected_value, char cache_flags, +void CheckSpendCoin(Amount base_value, Amount cache_value, + Amount expected_value, char cache_flags, char expected_flags) { SingleEntryCacheTest test(base_value, cache_value, cache_flags); test.cache.SpendCoin(OUTPOINT); test.cache.SelfTest(); - CAmount result_value; + Amount result_value; char result_flags; GetCoinMapEntry(test.cache.map(), result_value, result_flags); BOOST_CHECK_EQUAL(result_value, expected_value); @@ -732,12 +732,12 @@ CheckSpendCoin(VALUE1, VALUE2, ABSENT, DIRTY | FRESH, NO_ENTRY); } -void CheckAddCoinBase(CAmount base_value, CAmount cache_value, - CAmount modify_value, CAmount expected_value, +void CheckAddCoinBase(Amount base_value, Amount cache_value, + Amount modify_value, Amount expected_value, char cache_flags, char expected_flags, bool coinbase) { SingleEntryCacheTest test(base_value, cache_value, cache_flags); - CAmount result_value; + Amount result_value; char result_flags; try { CTxOut output; @@ -761,7 +761,7 @@ // while still verifying that the CoinsViewCache::AddCoin implementation ignores // base values. template void CheckAddCoin(Args &&... args) { - for (CAmount base_value : {ABSENT, PRUNED, VALUE1}) { + for (Amount base_value : {ABSENT, PRUNED, VALUE1}) { CheckAddCoinBase(base_value, std::forward(args)...); } } @@ -796,12 +796,12 @@ CheckAddCoin(VALUE2, VALUE3, VALUE3, DIRTY | FRESH, DIRTY | FRESH, true); } -void CheckWriteCoin(CAmount parent_value, CAmount child_value, - CAmount expected_value, char parent_flags, char child_flags, +void CheckWriteCoin(Amount parent_value, Amount child_value, + Amount expected_value, char parent_flags, char child_flags, char expected_flags) { SingleEntryCacheTest test(ABSENT, parent_value, parent_flags); - CAmount result_value; + Amount result_value; char result_flags; try { WriteCoinViewEntry(test.cache, child_value, child_flags); @@ -881,8 +881,8 @@ // they would be too repetitive (the parent cache is never updated in these // cases). The loop below covers these cases and makes sure the parent cache // is always left unchanged. - for (CAmount parent_value : {ABSENT, PRUNED, VALUE1}) { - for (CAmount child_value : {ABSENT, PRUNED, VALUE2}) { + for (Amount parent_value : {ABSENT, PRUNED, VALUE1}) { + for (Amount child_value : {ABSENT, PRUNED, VALUE2}) { for (char parent_flags : parent_value == ABSENT ? ABSENT_FLAGS : FLAGS) { for (char child_flags : diff --git a/src/test/mempool_tests.cpp b/src/test/mempool_tests.cpp --- a/src/test/mempool_tests.cpp +++ b/src/test/mempool_tests.cpp @@ -454,7 +454,7 @@ uint64_t tx7Size = GetTransactionSize(tx7); /* set the fee to just below tx2's feerate when including ancestor */ - CAmount fee = (20000 / tx2Size) * (tx7Size + tx6Size) - 1; + Amount fee((20000 / tx2Size) * (tx7Size + tx6Size) - 1); // CTxMemPoolEntry entry7(tx7, fee, 2, 10.0, 1, true); pool.addUnchecked(tx7.GetId(), entry.Fee(fee).FromTx(tx7)); 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 @@ -138,7 +138,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).GetSatoshis() - 1; + Amount feeToUse = blockMinFeeRate.GetFee(2 * freeTxSize) - Amount(1); tx.vin[0].prevout.hash = hashFreeTx; tx.vout[0].nValue = 5000000000LL - 1000 - 50000 - feeToUse; @@ -180,7 +180,7 @@ // This tx can't be mined by itself. tx.vin[0].prevout.hash = hashFreeTx2; tx.vout.resize(1); - feeToUse = blockMinFeeRate.GetFee(freeTxSize).GetSatoshis(); + feeToUse = blockMinFeeRate.GetFee(freeTxSize); tx.vout[0].nValue = 5000000000LL - 100000000 - feeToUse; uint256 hashLowFeeTx2 = tx.GetId(); mempool.addUnchecked(hashLowFeeTx2, @@ -303,10 +303,10 @@ pblocktemplate = BlockAssembler(config, chainparams).CreateNewBlock(scriptPubKey)); - const CAmount BLOCKSUBSIDY = 50 * COIN.GetSatoshis(); - const CAmount LOWFEE = CENT.GetSatoshis(); - const CAmount HIGHFEE = COIN.GetSatoshis(); - const CAmount HIGHERFEE = 4 * COIN.GetSatoshis(); + const Amount BLOCKSUBSIDY = 50 * COIN; + const Amount LOWFEE = CENT; + const Amount HIGHFEE = COIN; + const Amount HIGHERFEE = 4 * COIN; // block sigops > limit: 1000 CHECKMULTISIG + 1 tx.vin.resize(1); 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 @@ -41,7 +41,7 @@ ScriptError err; CKey key[4]; - CAmount amount = 0; + Amount amount(0); for (int i = 0; i < 4; i++) key[i].MakeNewKey(true); 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 @@ -117,7 +117,7 @@ BOOST_FIXTURE_TEST_SUITE(script_tests, BasicTestingSetup) static CMutableTransaction -BuildCreditingTransaction(const CScript &scriptPubKey, CAmount nValue) { +BuildCreditingTransaction(const CScript &scriptPubKey, const Amount nValue) { CMutableTransaction txCredit; txCredit.nVersion = 1; txCredit.nLockTime = 0; @@ -152,7 +152,7 @@ static void DoTest(const CScript &scriptPubKey, const CScript &scriptSig, int flags, const std::string &message, int scriptError, - Amount nValue) { + const Amount nValue) { bool expect = (scriptError == SCRIPT_ERR_OK); if (flags & SCRIPT_VERIFY_CLEANSTACK) { flags |= SCRIPT_VERIFY_P2SH; @@ -160,15 +160,14 @@ ScriptError err; CMutableTransaction txCredit = - BuildCreditingTransaction(scriptPubKey, nValue.GetSatoshis()); + BuildCreditingTransaction(scriptPubKey, nValue); CMutableTransaction tx = BuildSpendingTransaction(scriptSig, txCredit); CMutableTransaction tx2 = tx; - BOOST_CHECK_MESSAGE( - VerifyScript(scriptSig, scriptPubKey, flags, - MutableTransactionSignatureChecker( - &tx, 0, txCredit.vout[0].nValue.GetSatoshis()), - &err) == expect, - message); + BOOST_CHECK_MESSAGE(VerifyScript(scriptSig, scriptPubKey, flags, + MutableTransactionSignatureChecker( + &tx, 0, txCredit.vout[0].nValue), + &err) == expect, + message); BOOST_CHECK_MESSAGE( err == scriptError, std::string(FormatScriptError(err)) + " where " + @@ -250,7 +249,7 @@ std::string comment; int flags; int scriptError; - CAmount nValue; + Amount nValue; void DoPush() { if (havePush) { @@ -267,7 +266,7 @@ public: TestBuilder(const CScript &script_, const std::string &comment_, int flags_, - bool P2SH = false, CAmount nValue_ = 0) + bool P2SH = false, Amount nValue_ = Amount(0)) : script(script_), havePush(false), comment(comment_), flags(flags_), scriptError(SCRIPT_ERR_OK), nValue(nValue_) { CScript scriptPubKey = script; @@ -311,7 +310,7 @@ TestBuilder &PushSig(const CKey &key, int nHashType = SIGHASH_ALL, unsigned int lenR = 32, unsigned int lenS = 32, - CAmount amount = 0) { + Amount amount = 0) { uint256 hash = SignatureHash(script, spendTx, 0, nHashType, amount); std::vector vchSig, r, s; uint32_t iter = 0; @@ -1014,7 +1013,7 @@ .PushSig(keys.key0) .PushRedeem()); - static const CAmount TEST_AMOUNT = 12345000000000; + static const Amount TEST_AMOUNT(12345000000000); tests.push_back( TestBuilder(CScript() << ToByteVector(keys.pubkey0) << OP_CHECKSIG, "P2PK FORKID", SCRIPT_ENABLE_SIGHASH_FORKID, false, @@ -1108,7 +1107,7 @@ int scriptError = ParseScriptError(test[pos++].get_str()); DoTest(scriptPubKey, scriptSig, scriptflags, strTest, scriptError, - nValue.GetSatoshis()); + nValue); } } @@ -1330,7 +1329,7 @@ BOOST_AUTO_TEST_CASE(script_combineSigs) { // Test the CombineSignatures function - CAmount amount = 0; + Amount amount = 0; CBasicKeyStore keystore; std::vector keys; std::vector pubkeys; 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 @@ -106,7 +106,7 @@ break; } - CAmount amount = 0; + Amount amount(0); if (mapprevOutValues.count(tx.vin[i].prevout)) { amount = mapprevOutValues[tx.vin[i].prevout]; } @@ -193,7 +193,7 @@ break; } - CAmount amount = 0; + Amount amount(0); if (mapprevOutValues.count(tx.vin[i].prevout)) { amount = mapprevOutValues[tx.vin[i].prevout]; } 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 @@ -14,7 +14,7 @@ BOOST_FIXTURE_TEST_SUITE(accounting_tests, WalletTestingSetup) -static void GetResults(std::map &results) { +static void GetResults(std::map &results) { std::list aes; results.clear(); @@ -29,7 +29,7 @@ std::vector vpwtx; CWalletTx wtx; CAccountingEntry ae; - std::map results; + std::map results; LOCK(pwalletMain->cs_wallet);