From 0fff89439918b25c18936239c809a1e3a75c7e68 Mon Sep 17 00:00:00 2001 From: practicalswift Date: Tue, 6 Jun 2017 21:15:28 +0200 Subject: [PATCH] Use list initialization (C++11) for maps/vectors instead of boost::assign::map_list_of/list_of Back-ported from: 3fb81a8480582d96e8c87ef1b963a11c55064d57 --- src/bitcoin-tx.cpp | 7 ++++-- src/chainparams.cpp | 14 +++++------- src/core_read.cpp | 1 - src/core_write.cpp | 18 +++++++-------- src/qt/coincontroldialog.cpp | 2 -- src/rpc/mining.cpp | 12 +++++----- src/rpc/misc.cpp | 4 +--- src/rpc/rawtransaction.cpp | 41 ++++++++++++++++------------------ src/test/DoS_tests.cpp | 1 - src/test/crypto_tests.cpp | 1 - src/test/netbase_tests.cpp | 25 ++++++++++----------- src/test/pmt_tests.cpp | 18 +++++++-------- src/test/rpc_tests.cpp | 11 +++++---- src/test/transaction_tests.cpp | 39 ++++++++++++++++---------------- src/wallet/rpcdump.cpp | 3 +-- src/wallet/rpcwallet.cpp | 12 +++++----- 16 files changed, 95 insertions(+), 114 deletions(-) diff --git a/src/bitcoin-tx.cpp b/src/bitcoin-tx.cpp index bceaf579525..b0890569bb4 100644 --- a/src/bitcoin-tx.cpp +++ b/src/bitcoin-tx.cpp @@ -27,7 +27,6 @@ #include #include -#include static bool fCreateBlank; static std::map registers; @@ -566,7 +565,11 @@ static void MutateTxSign(CMutableTransaction& tx, const std::string& flagStr) if (!prevOut.isObject()) throw std::runtime_error("expected prevtxs internal object"); - std::map types = boost::assign::map_list_of("txid", UniValue::VSTR)("vout",UniValue::VNUM)("scriptPubKey",UniValue::VSTR); + std::map types = { + {"txid", UniValue::VSTR}, + {"vout", UniValue::VNUM}, + {"scriptPubKey", UniValue::VSTR}, + }; if (!prevOut.checkObject(types)) throw std::runtime_error("prevtxs internal object typecheck fail"); diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 9e83ec62bd3..dab77c7bd12 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -13,8 +13,6 @@ #include -#include - #include "chainparamsseeds.h" static CBlock CreateGenesisBlock(const char* pszTimestamp, const CScript& genesisOutputScript, uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward) @@ -167,8 +165,8 @@ class CMainParams : public CChainParams { base58Prefixes[PUBKEY_ADDRESS] = std::vector(1,30); base58Prefixes[SCRIPT_ADDRESS] = std::vector(1,22); base58Prefixes[SECRET_KEY] = std::vector(1,158); - base58Prefixes[EXT_PUBLIC_KEY] = boost::assign::list_of(0x02)(0xfa)(0xca)(0xfd).convert_to_container >(); - base58Prefixes[EXT_SECRET_KEY] = boost::assign::list_of(0x02)(0xfa)(0xc3)(0x98).convert_to_container >(); + base58Prefixes[EXT_PUBLIC_KEY] = {0x02, 0xfa, 0xca, 0xfd}; + base58Prefixes[EXT_SECRET_KEY] = {0x02, 0xfa, 0xc3, 0x98}; vFixedSeeds = std::vector(pnSeed6_main, pnSeed6_main + ARRAYLEN(pnSeed6_main)); @@ -328,8 +326,8 @@ class CTestNetParams : public CChainParams { base58Prefixes[PUBKEY_ADDRESS] = std::vector(1,113); // 0x71 base58Prefixes[SCRIPT_ADDRESS] = std::vector(1,196); // 0xc4 base58Prefixes[SECRET_KEY] = std::vector(1,241); // 0xf1 - base58Prefixes[EXT_PUBLIC_KEY] = boost::assign::list_of(0x04)(0x35)(0x87)(0xcf).convert_to_container >(); - base58Prefixes[EXT_SECRET_KEY] = boost::assign::list_of(0x04)(0x35)(0x83)(0x94).convert_to_container >(); + base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x35, 0x87, 0xcf}; + base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x35, 0x83, 0x94}; vFixedSeeds = std::vector(pnSeed6_test, pnSeed6_test + ARRAYLEN(pnSeed6_test)); @@ -475,8 +473,8 @@ class CRegTestParams : public CChainParams { base58Prefixes[PUBKEY_ADDRESS] = std::vector(1,111); // 0x6f base58Prefixes[SCRIPT_ADDRESS] = std::vector(1,196); // 0xc4 base58Prefixes[SECRET_KEY] = std::vector(1,239); // 0xef - base58Prefixes[EXT_PUBLIC_KEY] = boost::assign::list_of(0x04)(0x35)(0x87)(0xCF).convert_to_container >(); - base58Prefixes[EXT_SECRET_KEY] = boost::assign::list_of(0x04)(0x35)(0x83)(0x94).convert_to_container >(); + base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x35, 0x87, 0xCF}; + base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x35, 0x83, 0x94}; } void UpdateBIP9Parameters(Consensus::DeploymentPos d, int64_t nStartTime, int64_t nTimeout) diff --git a/src/core_read.cpp b/src/core_read.cpp index a8d667e3bc7..bb716aa26bd 100644 --- a/src/core_read.cpp +++ b/src/core_read.cpp @@ -18,7 +18,6 @@ #include #include #include -#include CScript ParseScript(const std::string& s) { diff --git a/src/core_write.cpp b/src/core_write.cpp index b0993a131f0..f0d31a079dd 100644 --- a/src/core_write.cpp +++ b/src/core_write.cpp @@ -15,7 +15,6 @@ #include "utilmoneystr.h" #include "utilstrencodings.h" -#include #include std::string FormatScript(const CScript& script) @@ -53,15 +52,14 @@ std::string FormatScript(const CScript& script) return ret.substr(0, ret.size() - 1); } -const std::map mapSigHashTypes = - boost::assign::map_list_of - (static_cast(SIGHASH_ALL), std::string("ALL")) - (static_cast(SIGHASH_ALL|SIGHASH_ANYONECANPAY), std::string("ALL|ANYONECANPAY")) - (static_cast(SIGHASH_NONE), std::string("NONE")) - (static_cast(SIGHASH_NONE|SIGHASH_ANYONECANPAY), std::string("NONE|ANYONECANPAY")) - (static_cast(SIGHASH_SINGLE), std::string("SINGLE")) - (static_cast(SIGHASH_SINGLE|SIGHASH_ANYONECANPAY), std::string("SINGLE|ANYONECANPAY")) - ; +const std::map mapSigHashTypes = { + {static_cast(SIGHASH_ALL), std::string("ALL")}, + {static_cast(SIGHASH_ALL|SIGHASH_ANYONECANPAY), std::string("ALL|ANYONECANPAY")}, + {static_cast(SIGHASH_NONE), std::string("NONE")}, + {static_cast(SIGHASH_NONE|SIGHASH_ANYONECANPAY), std::string("NONE|ANYONECANPAY")}, + {static_cast(SIGHASH_SINGLE), std::string("SINGLE")}, + {static_cast(SIGHASH_SINGLE|SIGHASH_ANYONECANPAY), std::string("SINGLE|ANYONECANPAY")}, +}; /** * Create the assembly string representation of a CScript object. diff --git a/src/qt/coincontroldialog.cpp b/src/qt/coincontroldialog.cpp index d6c3dc6c01f..9925a6db4fc 100644 --- a/src/qt/coincontroldialog.cpp +++ b/src/qt/coincontroldialog.cpp @@ -20,8 +20,6 @@ #include "validation.h" // For mempool #include "wallet/wallet.h" -#include // for 'map_list_of()' - #include #include #include diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index f98ae514b16..23d764b3703 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -26,8 +26,6 @@ #include #include -#include - #include using namespace std; @@ -621,7 +619,7 @@ UniValue getblocktemplate(const JSONRPCRequest& request) entry.pushKV("hash", tx.GetWitnessHash().GetHex()); UniValue deps(UniValue::VARR); - BOOST_FOREACH (const CTxIn &in, tx.vin) + for (const CTxIn &in : tx.vin) { if (setTxIndex.count(in.prevout.hash)) deps.push_back(setTxIndex[in.prevout.hash]); @@ -858,7 +856,7 @@ UniValue estimatefee(const JSONRPCRequest& request) + HelpExampleCli("estimatefee", "6") ); - RPCTypeCheck(request.params, boost::assign::list_of(UniValue::VNUM)); + RPCTypeCheck(request.params, {UniValue::VNUM}); int nBlocks = request.params[0].get_int(); if (nBlocks < 1) @@ -889,7 +887,7 @@ UniValue estimatepriority(const JSONRPCRequest& request) + HelpExampleCli("estimatepriority", "6") ); - RPCTypeCheck(request.params, boost::assign::list_of(UniValue::VNUM)); + RPCTypeCheck(request.params, {UniValue::VNUM}); int nBlocks = request.params[0].get_int(); if (nBlocks < 1) @@ -923,7 +921,7 @@ UniValue estimatesmartfee(const JSONRPCRequest& request) + HelpExampleCli("estimatesmartfee", "6") ); - RPCTypeCheck(request.params, boost::assign::list_of(UniValue::VNUM)); + RPCTypeCheck(request.params, {UniValue::VNUM}); int nBlocks = request.params[0].get_int(); @@ -959,7 +957,7 @@ UniValue estimatesmartpriority(const JSONRPCRequest& request) + HelpExampleCli("estimatesmartpriority", "6") ); - RPCTypeCheck(request.params, boost::assign::list_of(UniValue::VNUM)); + RPCTypeCheck(request.params, {UniValue::VNUM}); int nBlocks = request.params[0].get_int(); diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 9693568069b..554a25531d0 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -21,8 +21,6 @@ #include -#include - #include using namespace std; @@ -449,7 +447,7 @@ UniValue setmocktime(const JSONRPCRequest& request) // ensure all callsites of GetTime() are accessing this safely. LOCK(cs_main); - RPCTypeCheck(request.params, boost::assign::list_of(UniValue::VNUM)); + RPCTypeCheck(request.params, {UniValue::VNUM}); SetMockTime(request.params[0].get_int64()); return NullUniValue; diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index 5155e0780e9..7100276aae2 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -30,8 +30,6 @@ #include -#include - #include using namespace std; @@ -55,7 +53,7 @@ void ScriptPubKeyToJSON(const CScript& scriptPubKey, UniValue& out, bool fInclud out.pushKV("type", GetTxnOutputType(type)); UniValue a(UniValue::VARR); - BOOST_FOREACH(const CTxDestination& addr, addresses) + for (const CTxDestination& addr : addresses) a.push_back(CBitcoinAddress(addr).ToString()); out.pushKV("addresses", a); } @@ -346,7 +344,7 @@ UniValue verifytxoutproof(const JSONRPCRequest& request) if (!mapBlockIndex.count(merkleBlock.header.GetHash()) || !chainActive.Contains(mapBlockIndex[merkleBlock.header.GetHash()])) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found in chain"); - BOOST_FOREACH(const uint256& hash, vMatch) + for (const uint256& hash : vMatch) res.push_back(hash.GetHex()); return res; } @@ -389,7 +387,7 @@ UniValue createrawtransaction(const JSONRPCRequest& request) + HelpExampleRpc("createrawtransaction", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\", \"{\\\"data\\\":\\\"00010203\\\"}\"") ); - RPCTypeCheck(request.params, boost::assign::list_of(UniValue::VARR)(UniValue::VOBJ)(UniValue::VNUM), true); + RPCTypeCheck(request.params, {UniValue::VARR, UniValue::VOBJ, UniValue::VNUM}, true); if (request.params[0].isNull() || request.params[1].isNull()) throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, arguments 1 and 2 must be non-null"); @@ -437,7 +435,7 @@ UniValue createrawtransaction(const JSONRPCRequest& request) set setAddress; vector addrList = sendTo.getKeys(); - BOOST_FOREACH(const string& name_, addrList) { + for (const string& name_ : addrList) { if (name_ == "data") { std::vector data = ParseHexV(sendTo[name_].getValStr(),"Data"); @@ -520,7 +518,7 @@ UniValue decoderawtransaction(const JSONRPCRequest& request) ); LOCK(cs_main); - RPCTypeCheck(request.params, boost::assign::list_of(UniValue::VSTR)); + RPCTypeCheck(request.params, {UniValue::VSTR}); CMutableTransaction mtx; @@ -558,7 +556,7 @@ UniValue decodescript(const JSONRPCRequest& request) + HelpExampleRpc("decodescript", "\"hexstring\"") ); - RPCTypeCheck(request.params, boost::assign::list_of(UniValue::VSTR)); + RPCTypeCheck(request.params, {UniValue::VSTR}); UniValue r(UniValue::VOBJ); CScript script; @@ -660,7 +658,7 @@ UniValue signrawtransaction(const JSONRPCRequest& request) #else LOCK(cs_main); #endif - RPCTypeCheck(request.params, boost::assign::list_of(UniValue::VSTR)(UniValue::VARR)(UniValue::VARR)(UniValue::VSTR), true); + RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VARR, UniValue::VARR, UniValue::VSTR}, true); vector txData(ParseHexV(request.params[0], "argument 1")); CDataStream ssData(txData, SER_NETWORK, PROTOCOL_VERSION); @@ -692,7 +690,7 @@ UniValue signrawtransaction(const JSONRPCRequest& request) CCoinsViewMemPool viewMempool(&viewChain, mempool); view.SetBackend(viewMempool); // temporarily switch cache backend to db+mempool view - BOOST_FOREACH(const CTxIn& txin, mergedTx.vin) { + for (const CTxIn& txin : mergedTx.vin) { const uint256& prevHash = txin.prevout.hash; CCoins coins; view.AccessCoins(prevHash); // this is certainly allowed to fail @@ -794,16 +792,15 @@ UniValue signrawtransaction(const JSONRPCRequest& request) int nHashType = SIGHASH_ALL; if (request.params.size() > 3 && !request.params[3].isNull()) { - static map mapSigHashValues = - boost::assign::map_list_of - (string("ALL"), int(SIGHASH_ALL)) - (string("ALL|ANYONECANPAY"), int(SIGHASH_ALL|SIGHASH_ANYONECANPAY)) - (string("NONE"), int(SIGHASH_NONE)) - (string("NONE|ANYONECANPAY"), int(SIGHASH_NONE|SIGHASH_ANYONECANPAY)) - (string("SINGLE"), int(SIGHASH_SINGLE)) - (string("SINGLE|ANYONECANPAY"), int(SIGHASH_SINGLE|SIGHASH_ANYONECANPAY)) - ; - string strHashType = request.params[3].get_str(); + static std::map mapSigHashValues = { + {std::string("ALL"), int(SIGHASH_ALL)}, + {std::string("ALL|ANYONECANPAY"), int(SIGHASH_ALL|SIGHASH_ANYONECANPAY)}, + {std::string("NONE"), int(SIGHASH_NONE)}, + {std::string("NONE|ANYONECANPAY"), int(SIGHASH_NONE|SIGHASH_ANYONECANPAY)}, + {std::string("SINGLE"), int(SIGHASH_SINGLE)}, + {std::string("SINGLE|ANYONECANPAY"), int(SIGHASH_SINGLE|SIGHASH_ANYONECANPAY)}, + }; + std::string strHashType = request.params[3].get_str(); if (mapSigHashValues.count(strHashType)) nHashType = mapSigHashValues[strHashType]; else @@ -835,7 +832,7 @@ UniValue signrawtransaction(const JSONRPCRequest& request) ProduceSignature(MutableTransactionSignatureCreator(&keystore, &mergedTx, i, amount, nHashType), prevPubKey, sigdata); // ... and merge in other signatures: - BOOST_FOREACH(const CMutableTransaction& txv, txVariants) { + for (const CMutableTransaction& txv : txVariants) { if (txv.vin.size() > i) { sigdata = CombineSignatures(prevPubKey, TransactionSignatureChecker(&txConst, i, amount), sigdata, DataFromTransaction(txv, i)); } @@ -884,7 +881,7 @@ UniValue sendrawtransaction(const JSONRPCRequest& request) ); LOCK(cs_main); - RPCTypeCheck(request.params, boost::assign::list_of(UniValue::VSTR)(UniValue::VBOOL)); + RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VBOOL}); // parse hex string from parameter CMutableTransaction mtx; diff --git a/src/test/DoS_tests.cpp b/src/test/DoS_tests.cpp index 0c71152dcdf..4628f39b893 100644 --- a/src/test/DoS_tests.cpp +++ b/src/test/DoS_tests.cpp @@ -18,7 +18,6 @@ #include -#include // for 'map_list_of()' #include #include #include diff --git a/src/test/crypto_tests.cpp b/src/test/crypto_tests.cpp index a4f0e17c997..391ad14ffa1 100644 --- a/src/test/crypto_tests.cpp +++ b/src/test/crypto_tests.cpp @@ -16,7 +16,6 @@ #include -#include #include #include #include diff --git a/src/test/netbase_tests.cpp b/src/test/netbase_tests.cpp index 2cc51f8e3e3..a5b21395236 100644 --- a/src/test/netbase_tests.cpp +++ b/src/test/netbase_tests.cpp @@ -8,7 +8,6 @@ #include -#include #include BOOST_FIXTURE_TEST_SUITE(netbase_tests, BasicTestingSetup) @@ -269,18 +268,18 @@ BOOST_AUTO_TEST_CASE(subnet_test) BOOST_AUTO_TEST_CASE(netbase_getgroup) { - BOOST_CHECK(ResolveIP("127.0.0.1").GetGroup() == boost::assign::list_of(0)); // Local -> !Routable() - BOOST_CHECK(ResolveIP("257.0.0.1").GetGroup() == boost::assign::list_of(0)); // !Valid -> !Routable() - BOOST_CHECK(ResolveIP("10.0.0.1").GetGroup() == boost::assign::list_of(0)); // RFC1918 -> !Routable() - BOOST_CHECK(ResolveIP("169.254.1.1").GetGroup() == boost::assign::list_of(0)); // RFC3927 -> !Routable() - BOOST_CHECK(ResolveIP("1.2.3.4").GetGroup() == boost::assign::list_of((unsigned char)NET_IPV4)(1)(2)); // IPv4 - BOOST_CHECK(ResolveIP("::FFFF:0:102:304").GetGroup() == boost::assign::list_of((unsigned char)NET_IPV4)(1)(2)); // RFC6145 - BOOST_CHECK(ResolveIP("64:FF9B::102:304").GetGroup() == boost::assign::list_of((unsigned char)NET_IPV4)(1)(2)); // RFC6052 - BOOST_CHECK(ResolveIP("2002:102:304:9999:9999:9999:9999:9999").GetGroup() == boost::assign::list_of((unsigned char)NET_IPV4)(1)(2)); // RFC3964 - BOOST_CHECK(ResolveIP("2001:0:9999:9999:9999:9999:FEFD:FCFB").GetGroup() == boost::assign::list_of((unsigned char)NET_IPV4)(1)(2)); // RFC4380 - BOOST_CHECK(ResolveIP("FD87:D87E:EB43:edb1:8e4:3588:e546:35ca").GetGroup() == boost::assign::list_of((unsigned char)NET_TOR)(239)); // Tor - BOOST_CHECK(ResolveIP("2001:470:abcd:9999:9999:9999:9999:9999").GetGroup() == boost::assign::list_of((unsigned char)NET_IPV6)(32)(1)(4)(112)(175)); //he.net - BOOST_CHECK(ResolveIP("2001:2001:9999:9999:9999:9999:9999:9999").GetGroup() == boost::assign::list_of((unsigned char)NET_IPV6)(32)(1)(32)(1)); //IPv6 + BOOST_CHECK(ResolveIP("127.0.0.1").GetGroup() == std::vector({0})); // Local -> !Routable() + BOOST_CHECK(ResolveIP("257.0.0.1").GetGroup() == std::vector({0})); // !Valid -> !Routable() + BOOST_CHECK(ResolveIP("10.0.0.1").GetGroup() == std::vector({0})); // RFC1918 -> !Routable() + BOOST_CHECK(ResolveIP("169.254.1.1").GetGroup() == std::vector({0})); // RFC3927 -> !Routable() + BOOST_CHECK(ResolveIP("1.2.3.4").GetGroup() == std::vector({(unsigned char)NET_IPV4, 1, 2})); // IPv4 + BOOST_CHECK(ResolveIP("::FFFF:0:102:304").GetGroup() == std::vector({(unsigned char)NET_IPV4, 1, 2})); // RFC6145 + BOOST_CHECK(ResolveIP("64:FF9B::102:304").GetGroup() == std::vector({(unsigned char)NET_IPV4, 1, 2})); // RFC6052 + BOOST_CHECK(ResolveIP("2002:102:304:9999:9999:9999:9999:9999").GetGroup() == std::vector({(unsigned char)NET_IPV4, 1, 2})); // RFC3964 + BOOST_CHECK(ResolveIP("2001:0:9999:9999:9999:9999:FEFD:FCFB").GetGroup() == std::vector({(unsigned char)NET_IPV4, 1, 2})); // RFC4380 + BOOST_CHECK(ResolveIP("FD87:D87E:EB43:edb1:8e4:3588:e546:35ca").GetGroup() == std::vector({(unsigned char)NET_TOR, 239})); // Tor + BOOST_CHECK(ResolveIP("2001:470:abcd:9999:9999:9999:9999:9999").GetGroup() == std::vector({(unsigned char)NET_IPV6, 32, 1, 4, 112, 175})); //he.net + BOOST_CHECK(ResolveIP("2001:2001:9999:9999:9999:9999:9999:9999").GetGroup() == std::vector({(unsigned char)NET_IPV6, 32, 1, 32, 1})); //IPv6 } diff --git a/src/test/pmt_tests.cpp b/src/test/pmt_tests.cpp index 708a9ca508a..c1d216d0944 100644 --- a/src/test/pmt_tests.cpp +++ b/src/test/pmt_tests.cpp @@ -13,7 +13,6 @@ #include -#include #include class CPartialMerkleTreeTester : public CPartialMerkleTree @@ -109,14 +108,15 @@ BOOST_AUTO_TEST_CASE(pmt_test1) BOOST_AUTO_TEST_CASE(pmt_malleability) { - std::vector vTxid = boost::assign::list_of - (ArithToUint256(1))(ArithToUint256(2)) - (ArithToUint256(3))(ArithToUint256(4)) - (ArithToUint256(5))(ArithToUint256(6)) - (ArithToUint256(7))(ArithToUint256(8)) - (ArithToUint256(9))(ArithToUint256(10)) - (ArithToUint256(9))(ArithToUint256(10)); - std::vector vMatch = boost::assign::list_of(false)(false)(false)(false)(false)(false)(false)(false)(false)(true)(true)(false); + std::vector vTxid = { + ArithToUint256(1), ArithToUint256(2), + ArithToUint256(3), ArithToUint256(4), + ArithToUint256(5), ArithToUint256(6), + ArithToUint256(7), ArithToUint256(8), + ArithToUint256(9), ArithToUint256(10), + ArithToUint256(9), ArithToUint256(10), + }; + std::vector vMatch = {false, false, false, false, false, false, false, false, false, true, true, false}; CPartialMerkleTree tree(vTxid, vMatch); std::vector vIndex; diff --git a/src/test/rpc_tests.cpp b/src/test/rpc_tests.cpp index c0ce918adc4..fddbaea8863 100644 --- a/src/test/rpc_tests.cpp +++ b/src/test/rpc_tests.cpp @@ -12,7 +12,6 @@ #include "test/test_bitcoin.h" #include -#include #include #include @@ -327,25 +326,25 @@ BOOST_AUTO_TEST_CASE(rpc_convert_values_generatetoaddress) { UniValue result; - BOOST_CHECK_NO_THROW(result = RPCConvertValues("generatetoaddress", boost::assign::list_of("101")("mkESjLZW66TmHhiFX8MCaBjrhZ543PPh9a"))); + BOOST_CHECK_NO_THROW(result = RPCConvertValues("generatetoaddress", {"101", "mkESjLZW66TmHhiFX8MCaBjrhZ543PPh9a"})); BOOST_CHECK_EQUAL(result[0].get_int(), 101); BOOST_CHECK_EQUAL(result[1].get_str(), "mkESjLZW66TmHhiFX8MCaBjrhZ543PPh9a"); - BOOST_CHECK_NO_THROW(result = RPCConvertValues("generatetoaddress", boost::assign::list_of("101")("mhMbmE2tE9xzJYCV9aNC8jKWN31vtGrguU"))); + BOOST_CHECK_NO_THROW(result = RPCConvertValues("generatetoaddress", {"101", "mhMbmE2tE9xzJYCV9aNC8jKWN31vtGrguU"})); BOOST_CHECK_EQUAL(result[0].get_int(), 101); BOOST_CHECK_EQUAL(result[1].get_str(), "mhMbmE2tE9xzJYCV9aNC8jKWN31vtGrguU"); - BOOST_CHECK_NO_THROW(result = RPCConvertValues("generatetoaddress", boost::assign::list_of("1")("mkESjLZW66TmHhiFX8MCaBjrhZ543PPh9a")("9"))); + BOOST_CHECK_NO_THROW(result = RPCConvertValues("generatetoaddress", {"1", "mkESjLZW66TmHhiFX8MCaBjrhZ543PPh9a", "9"})); BOOST_CHECK_EQUAL(result[0].get_int(), 1); BOOST_CHECK_EQUAL(result[1].get_str(), "mkESjLZW66TmHhiFX8MCaBjrhZ543PPh9a"); BOOST_CHECK_EQUAL(result[2].get_int(), 9); - BOOST_CHECK_NO_THROW(result = RPCConvertValues("generatetoaddress", boost::assign::list_of("1")("mhMbmE2tE9xzJYCV9aNC8jKWN31vtGrguU")("9"))); + BOOST_CHECK_NO_THROW(result = RPCConvertValues("generatetoaddress", {"1", "mhMbmE2tE9xzJYCV9aNC8jKWN31vtGrguU", "9"})); BOOST_CHECK_EQUAL(result[0].get_int(), 1); BOOST_CHECK_EQUAL(result[1].get_str(), "mhMbmE2tE9xzJYCV9aNC8jKWN31vtGrguU"); BOOST_CHECK_EQUAL(result[2].get_int(), 9); - BOOST_CHECK_NO_THROW(result = RPCConvertValues("generatetoaddress", boost::assign::list_of("1")("mhMbmE2tE9xzJYCV9aNC8jKWN31vtGrguU")("9")("1"))); + BOOST_CHECK_NO_THROW(result = RPCConvertValues("generatetoaddress", {"1", "mhMbmE2tE9xzJYCV9aNC8jKWN31vtGrguU", "9", "1"})); BOOST_CHECK_EQUAL(result[0].get_int(), 1); BOOST_CHECK_EQUAL(result[1].get_str(), "mhMbmE2tE9xzJYCV9aNC8jKWN31vtGrguU"); BOOST_CHECK_EQUAL(result[2].get_int(), 9); diff --git a/src/test/transaction_tests.cpp b/src/test/transaction_tests.cpp index fc6d4f0a951..3417b4462eb 100644 --- a/src/test/transaction_tests.cpp +++ b/src/test/transaction_tests.cpp @@ -26,9 +26,7 @@ #include #include -#include #include -#include #include #include @@ -38,24 +36,25 @@ typedef std::vector valtype; // In script_tests.cpp extern UniValue read_json(const std::string& jsondata); -static std::map mapFlagNames = boost::assign::map_list_of - (std::string("NONE"), (unsigned int)SCRIPT_VERIFY_NONE) - (std::string("P2SH"), (unsigned int)SCRIPT_VERIFY_P2SH) - (std::string("STRICTENC"), (unsigned int)SCRIPT_VERIFY_STRICTENC) - (std::string("DERSIG"), (unsigned int)SCRIPT_VERIFY_DERSIG) - (std::string("LOW_S"), (unsigned int)SCRIPT_VERIFY_LOW_S) - (std::string("SIGPUSHONLY"), (unsigned int)SCRIPT_VERIFY_SIGPUSHONLY) - (std::string("MINIMALDATA"), (unsigned int)SCRIPT_VERIFY_MINIMALDATA) - (std::string("NULLDUMMY"), (unsigned int)SCRIPT_VERIFY_NULLDUMMY) - (std::string("DISCOURAGE_UPGRADABLE_NOPS"), (unsigned int)SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS) - (std::string("CLEANSTACK"), (unsigned int)SCRIPT_VERIFY_CLEANSTACK) - (std::string("MINIMALIF"), (unsigned int)SCRIPT_VERIFY_MINIMALIF) - (std::string("NULLFAIL"), (unsigned int)SCRIPT_VERIFY_NULLFAIL) - (std::string("CHECKLOCKTIMEVERIFY"), (unsigned int)SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY) - (std::string("CHECKSEQUENCEVERIFY"), (unsigned int)SCRIPT_VERIFY_CHECKSEQUENCEVERIFY) - (std::string("WITNESS"), (unsigned int)SCRIPT_VERIFY_WITNESS) - (std::string("DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM"), (unsigned int)SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM) - (std::string("WITNESS_PUBKEYTYPE"), (unsigned int)SCRIPT_VERIFY_WITNESS_PUBKEYTYPE); +static std::map mapFlagNames = { + {std::string("NONE"), (unsigned int)SCRIPT_VERIFY_NONE}, + {std::string("P2SH"), (unsigned int)SCRIPT_VERIFY_P2SH}, + {std::string("STRICTENC"), (unsigned int)SCRIPT_VERIFY_STRICTENC}, + {std::string("DERSIG"), (unsigned int)SCRIPT_VERIFY_DERSIG}, + {std::string("LOW_S"), (unsigned int)SCRIPT_VERIFY_LOW_S}, + {std::string("SIGPUSHONLY"), (unsigned int)SCRIPT_VERIFY_SIGPUSHONLY}, + {std::string("MINIMALDATA"), (unsigned int)SCRIPT_VERIFY_MINIMALDATA}, + {std::string("NULLDUMMY"), (unsigned int)SCRIPT_VERIFY_NULLDUMMY}, + {std::string("DISCOURAGE_UPGRADABLE_NOPS"), (unsigned int)SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS}, + {std::string("CLEANSTACK"), (unsigned int)SCRIPT_VERIFY_CLEANSTACK}, + {std::string("MINIMALIF"), (unsigned int)SCRIPT_VERIFY_MINIMALIF}, + {std::string("NULLFAIL"), (unsigned int)SCRIPT_VERIFY_NULLFAIL}, + {std::string("CHECKLOCKTIMEVERIFY"), (unsigned int)SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY}, + {std::string("CHECKSEQUENCEVERIFY"), (unsigned int)SCRIPT_VERIFY_CHECKSEQUENCEVERIFY}, + {std::string("WITNESS"), (unsigned int)SCRIPT_VERIFY_WITNESS}, + {std::string("DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM"), (unsigned int)SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM}, + {std::string("WITNESS_PUBKEYTYPE"), (unsigned int)SCRIPT_VERIFY_WITNESS_PUBKEYTYPE}, +}; unsigned int ParseScriptFlags(std::string strFlags) { diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp index f51665c7dd1..16deb211a60 100644 --- a/src/wallet/rpcdump.cpp +++ b/src/wallet/rpcdump.cpp @@ -27,7 +27,6 @@ #include -#include #include using namespace std; @@ -1061,7 +1060,7 @@ UniValue importmulti(const JSONRPCRequest& mainRequest) return NullUniValue; } - RPCTypeCheck(mainRequest.params, boost::assign::list_of(UniValue::VARR)(UniValue::VOBJ)); + RPCTypeCheck(mainRequest.params, {UniValue::VARR, UniValue::VOBJ}); const UniValue& requests = mainRequest.params[0]; diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 28d6df016be..f63d575cd9a 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -25,8 +25,6 @@ #include -#include - #include using namespace std; @@ -2387,9 +2385,9 @@ UniValue lockunspent(const JSONRPCRequest& request) LOCK2(cs_main, pwalletMain->cs_wallet); if (request.params.size() == 1) - RPCTypeCheck(request.params, boost::assign::list_of(UniValue::VBOOL)); + RPCTypeCheck(request.params, {UniValue::VBOOL}); else - RPCTypeCheck(request.params, boost::assign::list_of(UniValue::VBOOL)(UniValue::VARR)); + RPCTypeCheck(request.params, {UniValue::VBOOL, UniValue::VARR}); bool fUnlock = request.params[0].get_bool(); @@ -2786,7 +2784,7 @@ UniValue fundrawtransaction(const JSONRPCRequest& request) + HelpExampleCli("sendrawtransaction", "\"signedtransactionhex\"") ); - RPCTypeCheck(request.params, boost::assign::list_of(UniValue::VSTR)); + RPCTypeCheck(request.params, {UniValue::VSTR}); CTxDestination changeAddress = CNoDestination(); int changePosition = -1; @@ -2804,7 +2802,7 @@ UniValue fundrawtransaction(const JSONRPCRequest& request) includeWatching = request.params[1].get_bool(); } else { - RPCTypeCheck(request.params, boost::assign::list_of(UniValue::VSTR)(UniValue::VOBJ)); + RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VOBJ}); UniValue options = request.params[1]; @@ -2964,7 +2962,7 @@ UniValue bumpfee(const JSONRPCRequest& request) HelpExampleCli("bumpfee", "")); } - RPCTypeCheck(request.params, boost::assign::list_of(UniValue::VSTR)(UniValue::VOBJ)); + RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VOBJ}); uint256 hash; hash.SetHex(request.params[0].get_str());