diff --git a/src/bench/coin_selection.cpp b/src/bench/coin_selection.cpp --- a/src/bench/coin_selection.cpp +++ b/src/bench/coin_selection.cpp @@ -36,7 +36,7 @@ NodeContext node; auto chain = interfaces::MakeChain(node, Params()); - CWallet wallet(Params(), chain.get(), WalletLocation(), + CWallet wallet(chain.get(), WalletLocation(), WalletDatabase::CreateDummy()); wallet.SetupLegacyScriptPubKeyMan(); std::vector> wtxs; @@ -110,7 +110,7 @@ NodeContext node; auto chain = interfaces::MakeChain(node, Params()); - CWallet wallet(Params(), chain.get(), WalletLocation(), + CWallet wallet(chain.get(), WalletLocation(), WalletDatabase::CreateDummy()); LOCK(wallet.cs_wallet); diff --git a/src/bench/wallet_balance.cpp b/src/bench/wallet_balance.cpp --- a/src/bench/wallet_balance.cpp +++ b/src/bench/wallet_balance.cpp @@ -21,8 +21,7 @@ NodeContext node; std::unique_ptr chain = interfaces::MakeChain(node, config.GetChainParams()); - CWallet wallet{config.GetChainParams(), chain.get(), WalletLocation(), - WalletDatabase::CreateMock()}; + CWallet wallet{chain.get(), WalletLocation(), WalletDatabase::CreateMock()}; { wallet.SetupLegacyScriptPubKeyMan(); bool first_run; diff --git a/src/interfaces/chain.h b/src/interfaces/chain.h --- a/src/interfaces/chain.h +++ b/src/interfaces/chain.h @@ -313,6 +313,9 @@ //! to be prepared to handle this by ignoring notifications about unknown //! removed transactions and already added new transactions. virtual void requestMempoolTransactions(Notifications ¬ifications) = 0; + + //! This Chain's parameters + virtual const CChainParams ¶ms() const = 0; }; //! Interface to let node manage chain clients (wallets, or maybe tools for diff --git a/src/interfaces/chain.cpp b/src/interfaces/chain.cpp --- a/src/interfaces/chain.cpp +++ b/src/interfaces/chain.cpp @@ -439,6 +439,7 @@ notifications.transactionAddedToMempool(entry.GetSharedTx()); } } + const CChainParams ¶ms() const override { return m_params; } NodeContext &m_node; const CChainParams &m_params; }; diff --git a/src/interfaces/wallet.cpp b/src/interfaces/wallet.cpp --- a/src/interfaces/wallet.cpp +++ b/src/interfaces/wallet.cpp @@ -128,7 +128,7 @@ return m_wallet->GetNewDestination(type, label, dest, error); } const CChainParams &getChainParams() override { - return m_wallet->chainParams; + return m_wallet->GetChainParams(); } bool getPubKey(const CScript &script, const CKeyID &address, CPubKey &pub_key) override { diff --git a/src/qt/test/addressbooktests.cpp b/src/qt/test/addressbooktests.cpp --- a/src/qt/test/addressbooktests.cpp +++ b/src/qt/test/addressbooktests.cpp @@ -59,9 +59,9 @@ TestChain100Setup test; node.setContext(&test.m_node); - std::shared_ptr wallet = std::make_shared( - Params(), node.context()->chain.get(), WalletLocation(), - WalletDatabase::CreateMock()); + std::shared_ptr wallet = + std::make_shared(node.context()->chain.get(), WalletLocation(), + WalletDatabase::CreateMock()); wallet->SetupLegacyScriptPubKeyMan(); bool firstRun; diff --git a/src/qt/test/wallettests.cpp b/src/qt/test/wallettests.cpp --- a/src/qt/test/wallettests.cpp +++ b/src/qt/test/wallettests.cpp @@ -114,9 +114,9 @@ {}, GetScriptForRawPubKey(test.coinbaseKey.GetPubKey())); } node.setContext(&test.m_node); - std::shared_ptr wallet = std::make_shared( - Params(), node.context()->chain.get(), WalletLocation(), - WalletDatabase::CreateMock()); + std::shared_ptr wallet = + std::make_shared(node.context()->chain.get(), WalletLocation(), + WalletDatabase::CreateMock()); bool firstRun; wallet->LoadWallet(firstRun); diff --git a/src/test/util/wallet.cpp b/src/test/util/wallet.cpp --- a/src/test/util/wallet.cpp +++ b/src/test/util/wallet.cpp @@ -29,7 +29,7 @@ void importaddress(CWallet &wallet, const std::string &address) { auto spk_man = wallet.GetLegacyScriptPubKeyMan(); LOCK2(wallet.cs_wallet, spk_man->cs_KeyStore); - const auto dest = DecodeDestination(address, wallet.chainParams); + const auto dest = DecodeDestination(address, wallet.GetChainParams()); assert(IsValidDestination(dest)); const auto script = GetScriptForDestination(dest); wallet.MarkDirty(); diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp --- a/src/wallet/rpcdump.cpp +++ b/src/wallet/rpcdump.cpp @@ -328,8 +328,8 @@ { LOCK(pwallet->cs_wallet); - CTxDestination dest = - DecodeDestination(request.params[0].get_str(), wallet->chainParams); + CTxDestination dest = DecodeDestination(request.params[0].get_str(), + wallet->GetChainParams()); if (IsValidDestination(dest)) { if (fP2SH) { throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, @@ -840,7 +840,8 @@ EnsureWalletIsUnlocked(pwallet); std::string strAddress = request.params[0].get_str(); - CTxDestination dest = DecodeDestination(strAddress, wallet->chainParams); + CTxDestination dest = + DecodeDestination(strAddress, wallet->GetChainParams()); if (!IsValidDestination(dest)) { throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Bitcoin address"); @@ -1138,7 +1139,8 @@ // Generate the script and destination for the scriptPubKey provided CScript script; if (!isScript) { - CTxDestination dest = DecodeDestination(output, pwallet->chainParams); + CTxDestination dest = + DecodeDestination(output, pwallet->GetChainParams()); if (!IsValidDestination(dest)) { throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address \"" + output + "\""); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -350,8 +350,8 @@ LOCK(pwallet->cs_wallet); - CTxDestination dest = - DecodeDestination(request.params[0].get_str(), wallet->chainParams); + CTxDestination dest = DecodeDestination(request.params[0].get_str(), + wallet->GetChainParams()); if (!IsValidDestination(dest)) { throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Bitcoin address"); @@ -473,8 +473,8 @@ LOCK(pwallet->cs_wallet); - CTxDestination dest = - DecodeDestination(request.params[0].get_str(), wallet->chainParams); + CTxDestination dest = DecodeDestination(request.params[0].get_str(), + wallet->GetChainParams()); if (!IsValidDestination(dest)) { throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address"); } @@ -629,7 +629,8 @@ std::string strAddress = request.params[0].get_str(); std::string strMessage = request.params[1].get_str(); - CTxDestination dest = DecodeDestination(strAddress, wallet->chainParams); + CTxDestination dest = + DecodeDestination(strAddress, wallet->GetChainParams()); if (!IsValidDestination(dest)) { throw JSONRPCError(RPC_TYPE_ERROR, "Invalid address"); } @@ -663,7 +664,7 @@ } else { // Get the address CTxDestination dest = - DecodeDestination(params[0].get_str(), wallet.chainParams); + DecodeDestination(params[0].get_str(), wallet.GetChainParams()); if (!IsValidDestination(dest)) { throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Bitcoin address"); @@ -1020,7 +1021,8 @@ std::vector keys = sendTo.getKeys(); for (const std::string &name_ : keys) { - CTxDestination dest = DecodeDestination(name_, wallet->chainParams); + CTxDestination dest = + DecodeDestination(name_, wallet->GetChainParams()); if (!IsValidDestination(dest)) { throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, std::string("Invalid Bitcoin address: ") + @@ -1152,7 +1154,7 @@ keys_or_addrs[i].get_str().length() == 130)) { pubkeys.push_back(HexToPubKey(keys_or_addrs[i].get_str())); } else { - pubkeys.push_back(AddrToPubKey(wallet->chainParams, spk_man, + pubkeys.push_back(AddrToPubKey(wallet->GetChainParams(), spk_man, keys_or_addrs[i].get_str())); } } @@ -1208,12 +1210,12 @@ CTxDestination filtered_address = CNoDestination(); if (!by_label && params.size() > 3) { if (!IsValidDestinationString(params[3].get_str(), - pwallet->chainParams)) { + pwallet->GetChainParams())) { throw JSONRPCError(RPC_WALLET_ERROR, "address_filter parameter was invalid"); } filtered_address = - DecodeDestination(params[3].get_str(), pwallet->chainParams); + DecodeDestination(params[3].get_str(), pwallet->GetChainParams()); has_filtered_address = true; } @@ -3565,7 +3567,7 @@ for (size_t idx = 0; idx < inputs.size(); idx++) { const UniValue &input = inputs[idx]; CTxDestination dest = - DecodeDestination(input.get_str(), wallet->chainParams); + DecodeDestination(input.get_str(), wallet->GetChainParams()); if (!IsValidDestination(dest)) { throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, std::string("Invalid Bitcoin address: ") + @@ -3729,8 +3731,9 @@ true, true); if (options.exists("changeAddress")) { - CTxDestination dest = DecodeDestination( - options["changeAddress"].get_str(), pwallet->chainParams); + CTxDestination dest = + DecodeDestination(options["changeAddress"].get_str(), + pwallet->GetChainParams()); if (!IsValidDestination(dest)) { throw JSONRPCError( @@ -4390,8 +4393,8 @@ LOCK(pwallet->cs_wallet); UniValue ret(UniValue::VOBJ); - CTxDestination dest = - DecodeDestination(request.params[0].get_str(), wallet->chainParams); + CTxDestination dest = DecodeDestination(request.params[0].get_str(), + wallet->GetChainParams()); // Make sure the destination is valid if (!IsValidDestination(dest)) { throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address"); @@ -4937,7 +4940,7 @@ Amount fee; int change_position; CMutableTransaction rawTx = - ConstructTransaction(wallet->chainParams, request.params[0], + ConstructTransaction(wallet->GetChainParams(), request.params[0], request.params[1], request.params[2]); FundTransaction(pwallet, rawTx, fee, change_position, request.params[3]); diff --git a/src/wallet/salvage.cpp b/src/wallet/salvage.cpp --- a/src/wallet/salvage.cpp +++ b/src/wallet/salvage.cpp @@ -130,7 +130,7 @@ } DbTxn *ptxn = env->TxnBegin(); - CWallet dummyWallet(GetConfig().GetChainParams(), nullptr, WalletLocation(), + CWallet dummyWallet(nullptr, WalletLocation(), WalletDatabase::CreateDummy()); for (KeyValPair &row : salvagedData) { /* Filter for only private key type KV pairs to be added to the salvaged diff --git a/src/wallet/test/coinselector_tests.cpp b/src/wallet/test/coinselector_tests.cpp --- a/src/wallet/test/coinselector_tests.cpp +++ b/src/wallet/test/coinselector_tests.cpp @@ -330,9 +330,8 @@ // Make sure that can use BnB when there are preset inputs empty_wallet(); { - auto wallet = - std::make_unique(Params(), m_chain.get(), WalletLocation(), - WalletDatabase::CreateMock()); + auto wallet = std::make_unique(m_chain.get(), WalletLocation(), + WalletDatabase::CreateMock()); bool firstRun; wallet->LoadWallet(firstRun); LOCK(wallet->cs_wallet); @@ -355,7 +354,7 @@ BOOST_AUTO_TEST_CASE(knapsack_solver_test) { auto testChain = interfaces::MakeChain(testNode, Params()); - CWallet testWallet(Params(), testChain.get(), WalletLocation(), + CWallet testWallet(testChain.get(), WalletLocation(), WalletDatabase::CreateDummy()); CoinSet setCoinsRet, setCoinsRet2; @@ -786,7 +785,7 @@ // to find a solution that can pay the target value BOOST_AUTO_TEST_CASE(SelectCoins_test) { auto testChain = interfaces::MakeChain(testNode, Params()); - CWallet testWallet(Params(), testChain.get(), WalletLocation(), + CWallet testWallet(testChain.get(), WalletLocation(), WalletDatabase::CreateDummy()); testWallet.SetupLegacyScriptPubKeyMan(); diff --git a/src/wallet/test/ismine_tests.cpp b/src/wallet/test/ismine_tests.cpp --- a/src/wallet/test/ismine_tests.cpp +++ b/src/wallet/test/ismine_tests.cpp @@ -37,7 +37,7 @@ // P2PK compressed { - CWallet keystore(Params(), chain.get(), WalletLocation(), + CWallet keystore(chain.get(), WalletLocation(), WalletDatabase::CreateDummy()); keystore.SetupLegacyScriptPubKeyMan(); LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore); @@ -55,7 +55,7 @@ // P2PK uncompressed { - CWallet keystore(Params(), chain.get(), WalletLocation(), + CWallet keystore(chain.get(), WalletLocation(), WalletDatabase::CreateDummy()); keystore.SetupLegacyScriptPubKeyMan(); LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore); @@ -74,7 +74,7 @@ // P2PKH compressed { - CWallet keystore(Params(), chain.get(), WalletLocation(), + CWallet keystore(chain.get(), WalletLocation(), WalletDatabase::CreateDummy()); keystore.SetupLegacyScriptPubKeyMan(); LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore); @@ -92,7 +92,7 @@ // P2PKH uncompressed { - CWallet keystore(Params(), chain.get(), WalletLocation(), + CWallet keystore(chain.get(), WalletLocation(), WalletDatabase::CreateDummy()); keystore.SetupLegacyScriptPubKeyMan(); LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore); @@ -111,7 +111,7 @@ // P2SH { - CWallet keystore(Params(), chain.get(), WalletLocation(), + CWallet keystore(chain.get(), WalletLocation(), WalletDatabase::CreateDummy()); keystore.SetupLegacyScriptPubKeyMan(); LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore); @@ -137,7 +137,7 @@ // (P2PKH inside) P2SH inside P2SH (invalid) { - CWallet keystore(Params(), chain.get(), WalletLocation(), + CWallet keystore(chain.get(), WalletLocation(), WalletDatabase::CreateDummy()); keystore.SetupLegacyScriptPubKeyMan(); LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore); @@ -161,7 +161,7 @@ // scriptPubKey multisig { - CWallet keystore(Params(), chain.get(), WalletLocation(), + CWallet keystore(chain.get(), WalletLocation(), WalletDatabase::CreateDummy()); keystore.SetupLegacyScriptPubKeyMan(); LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore); @@ -196,7 +196,7 @@ // P2SH multisig { - CWallet keystore(Params(), chain.get(), WalletLocation(), + CWallet keystore(chain.get(), WalletLocation(), WalletDatabase::CreateDummy()); keystore.SetupLegacyScriptPubKeyMan(); LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore); @@ -221,7 +221,7 @@ // OP_RETURN { - CWallet keystore(Params(), chain.get(), WalletLocation(), + CWallet keystore(chain.get(), WalletLocation(), WalletDatabase::CreateDummy()); keystore.SetupLegacyScriptPubKeyMan(); LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore); @@ -236,7 +236,7 @@ // Nonstandard { - CWallet keystore(Params(), chain.get(), WalletLocation(), + CWallet keystore(chain.get(), WalletLocation(), WalletDatabase::CreateDummy()); keystore.SetupLegacyScriptPubKeyMan(); LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore); diff --git a/src/wallet/test/wallet_test_fixture.cpp b/src/wallet/test/wallet_test_fixture.cpp --- a/src/wallet/test/wallet_test_fixture.cpp +++ b/src/wallet/test/wallet_test_fixture.cpp @@ -10,8 +10,7 @@ WalletTestingSetup::WalletTestingSetup(const std::string &chainName) : TestingSetup(chainName), m_chain(interfaces::MakeChain(m_node, Params())), - m_wallet(Params(), m_chain.get(), WalletLocation(), - WalletDatabase::CreateMock()) { + m_wallet(m_chain.get(), WalletLocation(), WalletDatabase::CreateMock()) { bool fFirstRun; m_wallet.LoadWallet(fFirstRun); m_chain_notifications_handler = diff --git a/src/wallet/test/wallet_tests.cpp b/src/wallet/test/wallet_tests.cpp --- a/src/wallet/test/wallet_tests.cpp +++ b/src/wallet/test/wallet_tests.cpp @@ -47,7 +47,7 @@ // Verify ScanForWalletTransactions fails to read an unknown start block. { - CWallet wallet(Params(), chain.get(), WalletLocation(), + CWallet wallet(chain.get(), WalletLocation(), WalletDatabase::CreateDummy()); { LOCK(wallet.cs_wallet); @@ -70,7 +70,7 @@ // Verify ScanForWalletTransactions picks up transactions in both the old // and new block files. { - CWallet wallet(Params(), chain.get(), WalletLocation(), + CWallet wallet(chain.get(), WalletLocation(), WalletDatabase::CreateDummy()); { LOCK(wallet.cs_wallet); @@ -100,7 +100,7 @@ // Verify ScanForWalletTransactions only picks transactions in the new block // file. { - CWallet wallet(Params(), chain.get(), WalletLocation(), + CWallet wallet(chain.get(), WalletLocation(), WalletDatabase::CreateDummy()); { LOCK(wallet.cs_wallet); @@ -129,7 +129,7 @@ // Verify ScanForWalletTransactions scans no blocks. { - CWallet wallet(Params(), chain.get(), WalletLocation(), + CWallet wallet(chain.get(), WalletLocation(), WalletDatabase::CreateDummy()); { LOCK(wallet.cs_wallet); @@ -171,9 +171,8 @@ // before the missing block, and success for a key whose creation time is // after. { - std::shared_ptr wallet = - std::make_shared(Params(), chain.get(), WalletLocation(), - WalletDatabase::CreateDummy()); + std::shared_ptr wallet = std::make_shared( + chain.get(), WalletLocation(), WalletDatabase::CreateDummy()); wallet->SetupLegacyScriptPubKeyMan(); WITH_LOCK(wallet->cs_wallet, wallet->SetLastBlockProcessed(newTip->nHeight, @@ -256,9 +255,8 @@ // Import key into wallet and call dumpwallet to create backup file. { - std::shared_ptr wallet = - std::make_shared(Params(), chain.get(), WalletLocation(), - WalletDatabase::CreateDummy()); + std::shared_ptr wallet = std::make_shared( + chain.get(), WalletLocation(), WalletDatabase::CreateDummy()); { auto spk_man = wallet->GetOrCreateLegacyScriptPubKeyMan(); LOCK2(wallet->cs_wallet, spk_man->cs_KeyStore); @@ -282,9 +280,8 @@ // Call importwallet RPC and verify all blocks with timestamps >= BLOCK_TIME // were scanned, and no prior blocks were scanned. { - std::shared_ptr wallet = - std::make_shared(Params(), chain.get(), WalletLocation(), - WalletDatabase::CreateDummy()); + std::shared_ptr wallet = std::make_shared( + chain.get(), WalletLocation(), WalletDatabase::CreateDummy()); LOCK(wallet->cs_wallet); wallet->SetupLegacyScriptPubKeyMan(); @@ -317,7 +314,7 @@ BOOST_FIXTURE_TEST_CASE(coin_mark_dirty_immature_credit, TestChain100Setup) { NodeContext node; auto chain = interfaces::MakeChain(node, Params()); - CWallet wallet(Params(), chain.get(), WalletLocation(), + CWallet wallet(chain.get(), WalletLocation(), WalletDatabase::CreateDummy()); auto spk_man = wallet.GetOrCreateLegacyScriptPubKeyMan(); CWalletTx wtx(&wallet, m_coinbase_txns.back()); @@ -506,9 +503,8 @@ ListCoinsTestingSetup() { CreateAndProcessBlock({}, GetScriptForRawPubKey(coinbaseKey.GetPubKey())); - wallet = - std::make_unique(Params(), m_chain.get(), WalletLocation(), - WalletDatabase::CreateMock()); + wallet = std::make_unique(m_chain.get(), WalletLocation(), + WalletDatabase::CreateMock()); { LOCK2(wallet->cs_wallet, ::cs_main); wallet->SetLastBlockProcessed( @@ -638,7 +634,7 @@ NodeContext node; auto chain = interfaces::MakeChain(node, Params()); std::shared_ptr wallet = std::make_shared( - Params(), chain.get(), WalletLocation(), WalletDatabase::CreateDummy()); + chain.get(), WalletLocation(), WalletDatabase::CreateDummy()); wallet->SetupLegacyScriptPubKeyMan(); wallet->SetMinVersion(FEATURE_LATEST); wallet->SetWalletFlag(WALLET_FLAG_DISABLE_PRIVATE_KEYS); diff --git a/src/wallet/test/walletdb_tests.cpp b/src/wallet/test/walletdb_tests.cpp --- a/src/wallet/test/walletdb_tests.cpp +++ b/src/wallet/test/walletdb_tests.cpp @@ -21,7 +21,7 @@ NodeContext node; auto chain = interfaces::MakeChain(node, Params()); std::unique_ptr wallet = std::make_unique( - Params(), chain.get(), WalletLocation(), WalletDatabase::CreateDummy()); + chain.get(), WalletLocation(), WalletDatabase::CreateDummy()); DBErrors res = batch.LoadWallet(wallet.get()); BOOST_CHECK(res == DBErrors::LOAD_OK); return wallet; diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -815,7 +815,6 @@ std::map> m_spk_managers; public: - const CChainParams &chainParams; /* * Main wallet lock. * This lock protects all the fields added by CWallet. @@ -853,11 +852,10 @@ unsigned int nMasterKeyMaxID = 0; /** Construct wallet with specified name and database implementation. */ - CWallet(const CChainParams &chainParamsIn, interfaces::Chain *chain, - const WalletLocation &location, + CWallet(interfaces::Chain *chain, const WalletLocation &location, std::unique_ptr _database) - : m_chain(chain), m_location(location), database(std::move(_database)), - chainParams(chainParamsIn) {} + : m_chain(chain), m_location(location), database(std::move(_database)) { + } ~CWallet() { // Should not have slots connected at this point. @@ -865,7 +863,7 @@ } /* Returns the chain params used by this wallet. */ - const CChainParams &GetChainParams() const override { return chainParams; } + const CChainParams &GetChainParams() const override; bool IsCrypted() const; bool IsLocked() const override; diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -288,6 +288,12 @@ nDepth, FormatMoney(tx->tx->vout[i].nValue)); } +const CChainParams &CWallet::GetChainParams() const { + // Get CChainParams from interfaces::Chain, unless wallet doesn't have a + // chain (i.e. bitcoin-wallet), in which case return global Params() + return m_chain ? m_chain->params() : Params(); +} + const CWalletTx *CWallet::GetWalletTx(const TxId &txid) const { LOCK(cs_wallet); std::map::const_iterator it = mapWallet.find(txid); @@ -4168,8 +4174,7 @@ _("Zapping all transactions from wallet...").translated); std::unique_ptr tempWallet = std::make_unique( - chainParams, &chain, location, - WalletDatabase::Create(location.GetPath())); + &chain, location, WalletDatabase::Create(location.GetPath())); DBErrors nZapWalletRet = tempWallet->ZapWalletTx(vWtx); if (nZapWalletRet != DBErrors::LOAD_OK) { error = @@ -4185,7 +4190,7 @@ // TODO: Can't use std::make_shared because we need a custom deleter but // should be possible to use std::allocate_shared. std::shared_ptr walletInstance( - new CWallet(chainParams, &chain, location, + new CWallet(&chain, location, WalletDatabase::Create(location.GetPath())), ReleaseWallet); DBErrors nLoadWalletRet = walletInstance->LoadWallet(fFirstRun); diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -298,14 +298,14 @@ ssValue >> label; pwallet ->m_address_book[DecodeDestination(strAddress, - pwallet->chainParams)] + pwallet->GetChainParams())] .SetLabel(label); } else if (strType == DBKeys::PURPOSE) { std::string strAddress; ssKey >> strAddress; ssValue >> pwallet ->m_address_book[DecodeDestination( - strAddress, pwallet->chainParams)] + strAddress, pwallet->GetChainParams())] .purpose; } else if (strType == DBKeys::TX) { TxId txid; @@ -493,8 +493,8 @@ ssKey >> strKey; ssValue >> strValue; pwallet->LoadDestData( - DecodeDestination(strAddress, pwallet->chainParams), strKey, - strValue); + DecodeDestination(strAddress, pwallet->GetChainParams()), + strKey, strValue); } else if (strType == DBKeys::HDCHAIN) { CHDChain chain; ssValue >> chain; diff --git a/src/wallet/wallettool.cpp b/src/wallet/wallettool.cpp --- a/src/wallet/wallettool.cpp +++ b/src/wallet/wallettool.cpp @@ -31,7 +31,7 @@ } // dummy chain interface std::shared_ptr wallet_instance( - new CWallet(Params(), nullptr /* chain */, WalletLocation(name), + new CWallet(nullptr /* chain */, WalletLocation(name), WalletDatabase::Create(path)), WalletToolReleaseWallet); LOCK(wallet_instance->cs_wallet); @@ -63,7 +63,7 @@ // dummy chain interface std::shared_ptr wallet_instance( - new CWallet(Params(), nullptr /* chain */, WalletLocation(name), + new CWallet(nullptr /* chain */, WalletLocation(name), WalletDatabase::Create(path)), WalletToolReleaseWallet); DBErrors load_wallet_ret;