From f68c79554f0f1a82ea916097a554f72a7d488acc Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Wed, 21 Oct 2020 01:05:00 +0100 Subject: [PATCH 01/11] Add header to files that will need it --- src/chainparams.cpp | 1 + src/consensus/params.h | 2 ++ src/gtest/test_keys.cpp | 2 ++ src/gtest/test_miner.cpp | 2 ++ src/key_io.cpp | 1 + src/main.cpp | 1 + src/miner.h | 1 + src/primitives/transaction.h | 1 + src/proof_verifier.cpp | 2 ++ src/rpc/mining.cpp | 1 + src/rpc/misc.cpp | 1 + src/rpc/rawtransaction.cpp | 1 + src/script/standard.h | 1 + src/test/key_tests.cpp | 1 + src/test/script_standard_tests.cpp | 2 ++ src/wallet/asyncrpcoperation_mergetoaddress.cpp | 1 + src/wallet/asyncrpcoperation_saplingmigration.cpp | 2 ++ src/wallet/asyncrpcoperation_sendmany.cpp | 1 + src/wallet/asyncrpcoperation_shieldcoinbase.cpp | 1 + src/wallet/rpcdump.cpp | 1 + src/wallet/rpcwallet.cpp | 1 + src/wallet/test/rpc_wallet_tests.cpp | 1 + src/wallet/wallet.cpp | 1 + src/zcash/Address.hpp | 2 +- src/zcash/Proof.hpp | 2 +- 25 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index d8bebb862..85c38b4e6 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -13,6 +13,7 @@ #include "utilstrencodings.h" #include +#include #include diff --git a/src/consensus/params.h b/src/consensus/params.h index eb4874710..01a6edb0c 100644 --- a/src/consensus/params.h +++ b/src/consensus/params.h @@ -11,6 +11,8 @@ #include "key_constants.h" #include +#include + #include #include diff --git a/src/gtest/test_keys.cpp b/src/gtest/test_keys.cpp index eb2735a28..c61b50073 100644 --- a/src/gtest/test_keys.cpp +++ b/src/gtest/test_keys.cpp @@ -4,6 +4,8 @@ #include "utiltest.h" +#include + #include TEST(Keys, EncodeAndDecodeSapling) diff --git a/src/gtest/test_miner.cpp b/src/gtest/test_miner.cpp index c648a6750..e73f77a43 100644 --- a/src/gtest/test_miner.cpp +++ b/src/gtest/test_miner.cpp @@ -7,6 +7,8 @@ #include "miner.h" #include "util.h" +#include + TEST(Miner, GetMinerAddress) { SelectParams(CBaseChainParams::MAIN); diff --git a/src/key_io.cpp b/src/key_io.cpp index 27a1b8a2e..f739f5437 100644 --- a/src/key_io.cpp +++ b/src/key_io.cpp @@ -16,6 +16,7 @@ #include #include #include +#include namespace { diff --git a/src/main.cpp b/src/main.cpp index 1415c2da7..9a9346a16 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #include #include diff --git a/src/miner.h b/src/miner.h index 080d29195..2cee74fbc 100644 --- a/src/miner.h +++ b/src/miner.h @@ -11,6 +11,7 @@ #include #include #include +#include class CBlockIndex; class CChainParams; diff --git a/src/primitives/transaction.h b/src/primitives/transaction.h index cff19b0e3..553fa5ede 100644 --- a/src/primitives/transaction.h +++ b/src/primitives/transaction.h @@ -15,6 +15,7 @@ #include "consensus/consensus.h" #include +#include #include diff --git a/src/proof_verifier.cpp b/src/proof_verifier.cpp index a99690609..58099c0bd 100644 --- a/src/proof_verifier.cpp +++ b/src/proof_verifier.cpp @@ -6,6 +6,8 @@ #include +#include + #include #include diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index cdcaa4407..f79e98c04 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -28,6 +28,7 @@ #endif #include +#include #include #include diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 9c12d954b..89b46b68d 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -19,6 +19,7 @@ #endif #include +#include #include diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index bdffd3573..4d6580518 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -26,6 +26,7 @@ #endif #include +#include #include diff --git a/src/script/standard.h b/src/script/standard.h index 97df161f5..4a3706738 100644 --- a/src/script/standard.h +++ b/src/script/standard.h @@ -12,6 +12,7 @@ #include #include +#include static const bool DEFAULT_ACCEPT_DATACARRIER = true; diff --git a/src/test/key_tests.cpp b/src/test/key_tests.cpp index d87470b23..25b285c85 100644 --- a/src/test/key_tests.cpp +++ b/src/test/key_tests.cpp @@ -16,6 +16,7 @@ #include "zcash/Address.hpp" #include +#include #include #include diff --git a/src/test/script_standard_tests.cpp b/src/test/script_standard_tests.cpp index 90a77e366..c7948a550 100644 --- a/src/test/script_standard_tests.cpp +++ b/src/test/script_standard_tests.cpp @@ -10,6 +10,8 @@ #include "script/standard.h" #include "test/test_bitcoin.h" +#include + #include diff --git a/src/wallet/asyncrpcoperation_mergetoaddress.cpp b/src/wallet/asyncrpcoperation_mergetoaddress.cpp index 7fdeea97a..fd6b62187 100644 --- a/src/wallet/asyncrpcoperation_mergetoaddress.cpp +++ b/src/wallet/asyncrpcoperation_mergetoaddress.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include diff --git a/src/wallet/asyncrpcoperation_saplingmigration.cpp b/src/wallet/asyncrpcoperation_saplingmigration.cpp index 45845720d..8be4b6af7 100644 --- a/src/wallet/asyncrpcoperation_saplingmigration.cpp +++ b/src/wallet/asyncrpcoperation_saplingmigration.cpp @@ -12,6 +12,8 @@ #include "utilmoneystr.h" #include "wallet.h" +#include + const CAmount FEE = 10000; const int MIGRATION_EXPIRY_DELTA = 450; diff --git a/src/wallet/asyncrpcoperation_sendmany.cpp b/src/wallet/asyncrpcoperation_sendmany.cpp index bb9f4e0ff..cc6061a24 100644 --- a/src/wallet/asyncrpcoperation_sendmany.cpp +++ b/src/wallet/asyncrpcoperation_sendmany.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include diff --git a/src/wallet/asyncrpcoperation_shieldcoinbase.cpp b/src/wallet/asyncrpcoperation_shieldcoinbase.cpp index 3407466b7..495e925f4 100644 --- a/src/wallet/asyncrpcoperation_shieldcoinbase.cpp +++ b/src/wallet/asyncrpcoperation_shieldcoinbase.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp index f6aa3488e..ebf9037e5 100644 --- a/src/wallet/rpcdump.cpp +++ b/src/wallet/rpcdump.cpp @@ -16,6 +16,7 @@ #include #include +#include #include #include diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 4f051a785..06faa9bb0 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -42,6 +42,7 @@ #include #include +#include #include diff --git a/src/wallet/test/rpc_wallet_tests.cpp b/src/wallet/test/rpc_wallet_tests.cpp index 3e2989356..fb4ef3030 100644 --- a/src/wallet/test/rpc_wallet_tests.cpp +++ b/src/wallet/test/rpc_wallet_tests.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 0f5288983..e5a3228f2 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -31,6 +31,7 @@ #include #include +#include #include #include diff --git a/src/zcash/Address.hpp b/src/zcash/Address.hpp index a4700fbbc..4dc65d6fc 100644 --- a/src/zcash/Address.hpp +++ b/src/zcash/Address.hpp @@ -5,7 +5,7 @@ #include "zcash/address/sprout.hpp" #include "zcash/address/zip32.h" -#include +#include namespace libzcash { class InvalidEncoding { diff --git a/src/zcash/Proof.hpp b/src/zcash/Proof.hpp index 0b9855f63..1bb55c413 100644 --- a/src/zcash/Proof.hpp +++ b/src/zcash/Proof.hpp @@ -4,7 +4,7 @@ #include "serialize.h" #include "uint256.h" -#include +#include namespace libzcash { From b521cb89321f6ded1a5a69e8846e3a8b875accc2 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Wed, 21 Oct 2020 01:07:14 +0100 Subject: [PATCH 02/11] scripted-diff: Migrate from boost::variant to std::variant -BEGIN VERIFY SCRIPT- sed -i 's/boost::variant/std::variant/' ./src/*.h ./src/*.cpp ./src/*/*.h* ./src/*/*.cpp ; sed -i 's/boost::get<\(.*\)>(&/std::get_if<\1>(\&/' ./src/*.h ./src/*.cpp ./src/*/*.h ./src/*/*.cpp ./src/*/*/*.cpp ; sed -i 's/boost::get/class \1/' ./src/*.h ./src/*.cpp ./src/*/*.h* ./src/*/*.cpp ; sed -i ':a;N;$!ba;s/#include \n//' ./src/*.h ./src/*.cpp ./src/*/*.h ./src/*/*.cpp ; sed -i ':a;N;$!ba;s/#include "boost\/variant\/.*.hpp"\n//' ./src/*/*.cpp ; -END VERIFY SCRIPT- --- src/chainparams.cpp | 2 +- src/consensus/funding.h | 1 - src/consensus/params.cpp | 8 ++-- src/consensus/params.h | 5 +- src/gtest/test_joinsplit.cpp | 1 - src/gtest/test_keys.cpp | 12 ++--- src/gtest/test_miner.cpp | 14 +++--- src/init.cpp | 6 +-- src/key_io.cpp | 18 ++++---- src/keystore.h | 1 - src/main.cpp | 4 +- src/miner.cpp | 18 ++++---- src/miner.h | 6 +-- src/primitives/transaction.h | 5 +- src/proof_verifier.cpp | 5 +- src/rpc/mining.cpp | 14 +++--- src/rpc/misc.cpp | 16 +++---- src/rpc/rawtransaction.cpp | 2 +- src/script/standard.cpp | 4 +- src/script/standard.h | 3 +- src/test/key_tests.cpp | 16 +++---- src/test/script_standard_tests.cpp | 32 ++++++------- src/transaction_builder.cpp | 1 - .../asyncrpcoperation_mergetoaddress.cpp | 6 +-- .../asyncrpcoperation_saplingmigration.cpp | 3 +- src/wallet/asyncrpcoperation_sendmany.cpp | 22 ++++----- .../asyncrpcoperation_shieldcoinbase.cpp | 2 +- src/wallet/asyncrpcoperation_shieldcoinbase.h | 2 +- src/wallet/rpcdump.cpp | 16 +++---- src/wallet/rpcwallet.cpp | 46 +++++++++---------- src/wallet/test/rpc_wallet_tests.cpp | 6 +-- src/wallet/wallet.cpp | 12 ++--- src/wallet/wallet.h | 12 ++--- src/zcash/Address.hpp | 10 ++-- src/zcash/Proof.hpp | 2 +- 35 files changed, 161 insertions(+), 172 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 85c38b4e6..0353ae1d2 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -813,7 +813,7 @@ CScript CChainParams::GetFoundersRewardScriptAtHeight(int nHeight) const { CTxDestination address = keyIO.DecodeDestination(GetFoundersRewardAddressAtHeight(nHeight).c_str()); assert(IsValidDestination(address)); assert(IsScriptDestination(address)); - CScriptID scriptID = boost::get(address); // address is a boost variant + CScriptID scriptID = std::get(address); // address is a boost variant CScript script = CScript() << OP_HASH160 << ToByteVector(scriptID) << OP_EQUAL; return script; } diff --git a/src/consensus/funding.h b/src/consensus/funding.h index b2dc1cd6c..91230db2b 100644 --- a/src/consensus/funding.h +++ b/src/consensus/funding.h @@ -8,7 +8,6 @@ #include #include -#include namespace Consensus { diff --git a/src/consensus/params.cpp b/src/consensus/params.cpp index a6525f4b7..cc519337b 100644 --- a/src/consensus/params.cpp +++ b/src/consensus/params.cpp @@ -102,7 +102,7 @@ namespace Consensus { return (nHeight - fundingStreamStartHeight + startPeriodOffset) / nFundingPeriodLength; } - boost::variant FundingStream::ValidateFundingStream( + std::variant FundingStream::ValidateFundingStream( const Consensus::Params& params, const int startHeight, const int endHeight, @@ -123,7 +123,7 @@ namespace Consensus { return FundingStream(startHeight, endHeight, addresses); }; - class GetFundingStreamOrThrow: public boost::static_visitor { + class GetFundingStreamOrThrow { public: FundingStream operator()(const FundingStream& fs) const { return fs; @@ -163,12 +163,12 @@ namespace Consensus { // If the string is not a valid transparent or Sapling address, we will // throw here. - addresses.push_back(boost::get(zaddr)); + addresses.push_back(std::get(zaddr)); } } auto validationResult = FundingStream::ValidateFundingStream(params, startHeight, endHeight, addresses); - return boost::apply_visitor(GetFundingStreamOrThrow(), validationResult); + return std::visit(GetFundingStreamOrThrow(), validationResult); }; void Params::AddZIP207FundingStream( diff --git a/src/consensus/params.h b/src/consensus/params.h index 01a6edb0c..f5830855d 100644 --- a/src/consensus/params.h +++ b/src/consensus/params.h @@ -14,7 +14,6 @@ #include #include -#include namespace Consensus { @@ -84,7 +83,7 @@ struct NetworkUpgrade { boost::optional hashActivationBlock; }; -typedef boost::variant FundingStreamAddress; +typedef std::variant FundingStreamAddress; /** * Index into Params.vFundingStreams. @@ -118,7 +117,7 @@ public: FundingStream(const FundingStream& fs): startHeight(fs.startHeight), endHeight(fs.endHeight), addresses(fs.addresses) { } - static boost::variant ValidateFundingStream( + static std::variant ValidateFundingStream( const Consensus::Params& params, const int startHeight, const int endHeight, diff --git a/src/gtest/test_joinsplit.cpp b/src/gtest/test_joinsplit.cpp index 65c452102..b89c3d6ad 100644 --- a/src/gtest/test_joinsplit.cpp +++ b/src/gtest/test_joinsplit.cpp @@ -2,7 +2,6 @@ #include "utilstrencodings.h" -#include #include "zcash/prf.h" #include "util.h" diff --git a/src/gtest/test_keys.cpp b/src/gtest/test_keys.cpp index c61b50073..e31b6796a 100644 --- a/src/gtest/test_keys.cpp +++ b/src/gtest/test_keys.cpp @@ -26,8 +26,8 @@ TEST(Keys, EncodeAndDecodeSapling) auto spendingkey2 = keyIO.DecodeSpendingKey(sk_string); EXPECT_TRUE(IsValidSpendingKey(spendingkey2)); - ASSERT_TRUE(boost::get(&spendingkey2) != nullptr); - auto sk2 = boost::get(spendingkey2); + ASSERT_TRUE(std::get_if(&spendingkey2) != nullptr); + auto sk2 = std::get(spendingkey2); EXPECT_EQ(sk, sk2); } { @@ -40,8 +40,8 @@ TEST(Keys, EncodeAndDecodeSapling) auto viewingkey2 = keyIO.DecodeViewingKey(vk_string); EXPECT_TRUE(IsValidViewingKey(viewingkey2)); - ASSERT_TRUE(boost::get(&viewingkey2) != nullptr); - auto extfvk2 = boost::get(viewingkey2); + ASSERT_TRUE(std::get_if(&viewingkey2) != nullptr); + auto extfvk2 = std::get(viewingkey2); EXPECT_EQ(extfvk, extfvk2); } { @@ -55,8 +55,8 @@ TEST(Keys, EncodeAndDecodeSapling) auto paymentaddr2 = keyIO.DecodePaymentAddress(addr_string); EXPECT_TRUE(IsValidPaymentAddress(paymentaddr2)); - ASSERT_TRUE(boost::get(&paymentaddr2) != nullptr); - auto addr2 = boost::get(paymentaddr2); + ASSERT_TRUE(std::get_if(&paymentaddr2) != nullptr); + auto addr2 = std::get(paymentaddr2); EXPECT_EQ(addr, addr2); } } diff --git a/src/gtest/test_miner.cpp b/src/gtest/test_miner.cpp index e73f77a43..61d454407 100644 --- a/src/gtest/test_miner.cpp +++ b/src/gtest/test_miner.cpp @@ -54,8 +54,8 @@ TEST(Miner, GetMinerAddress) { MinerAddress minerAddress; GetMinerAddress(minerAddress); EXPECT_TRUE(IsValidMinerAddress(minerAddress)); - EXPECT_TRUE(boost::get>(&minerAddress) != nullptr); - auto coinbaseScript = boost::get>(minerAddress); + EXPECT_TRUE(std::get_if>(&minerAddress) != nullptr); + auto coinbaseScript = std::get>(minerAddress); EXPECT_EQ(expectedCoinbaseScript, coinbaseScript->reserveScript); } @@ -65,8 +65,8 @@ TEST(Miner, GetMinerAddress) { MinerAddress minerAddress; GetMinerAddress(minerAddress); EXPECT_TRUE(IsValidMinerAddress(minerAddress)); - EXPECT_TRUE(boost::get>(&minerAddress) != nullptr); - auto coinbaseScript = boost::get>(minerAddress); + EXPECT_TRUE(std::get_if>(&minerAddress) != nullptr); + auto coinbaseScript = std::get>(minerAddress); EXPECT_EQ(expectedCoinbaseScript, coinbaseScript->reserveScript); } @@ -76,8 +76,8 @@ TEST(Miner, GetMinerAddress) { MinerAddress minerAddress; GetMinerAddress(minerAddress); EXPECT_TRUE(IsValidMinerAddress(minerAddress)); - EXPECT_TRUE(boost::get>(&minerAddress) != nullptr); - auto coinbaseScript = boost::get>(minerAddress); + EXPECT_TRUE(std::get_if>(&minerAddress) != nullptr); + auto coinbaseScript = std::get>(minerAddress); EXPECT_EQ(expectedCoinbaseScript, coinbaseScript->reserveScript); } @@ -103,7 +103,7 @@ TEST(Miner, GetMinerAddress) { MinerAddress minerAddress; GetMinerAddress(minerAddress); EXPECT_TRUE(IsValidMinerAddress(minerAddress)); - EXPECT_TRUE(boost::get(&minerAddress) != nullptr); + EXPECT_TRUE(std::get_if(&minerAddress) != nullptr); } // Valid Sapling address with leading whitespace diff --git a/src/init.cpp b/src/init.cpp index ab46a51e7..473692646 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1054,7 +1054,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) // Try a Sapling address auto zaddr = keyIO.DecodePaymentAddress(mapArgs["-mineraddress"]); if (!IsValidPaymentAddress(zaddr) || - boost::get(&zaddr) == nullptr) + std::get_if(&zaddr) == nullptr) { return InitError(strprintf( _("Invalid address for -mineraddress=: '%s' (must be a Sapling or transparent address)"), @@ -1575,11 +1575,11 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) if (pwalletMain) { CTxDestination addr = keyIO.DecodeDestination(mapArgs["-mineraddress"]); if (IsValidDestination(addr)) { - CKeyID keyID = boost::get(addr); + CKeyID keyID = std::get(addr); minerAddressInLocalWallet = pwalletMain->HaveKey(keyID); } else { auto zaddr = keyIO.DecodePaymentAddress(mapArgs["-mineraddress"]); - minerAddressInLocalWallet = boost::apply_visitor( + minerAddressInLocalWallet = std::visit( HaveSpendingKeyForPaymentAddress(pwalletMain), zaddr); } } diff --git a/src/key_io.cpp b/src/key_io.cpp index f739f5437..8e049d874 100644 --- a/src/key_io.cpp +++ b/src/key_io.cpp @@ -10,8 +10,6 @@ #include