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()); - const CWallet wallet(Params(), chain.get(), WalletLocation(), + const CWallet wallet(chain.get(), WalletLocation(), WalletDatabase::CreateDummy()); std::vector> wtxs; LOCK(wallet.cs_wallet); @@ -109,7 +109,7 @@ NodeContext node; auto chain = interfaces::MakeChain(node, Params()); - const CWallet wallet(Params(), chain.get(), WalletLocation(), + const 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()}; { bool first_run; if (wallet.LoadWallet(first_run) != DBErrors::LOAD_OK) { diff --git a/src/interfaces/chain.h b/src/interfaces/chain.h --- a/src/interfaces/chain.h +++ b/src/interfaces/chain.h @@ -267,6 +267,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 @@ -404,6 +404,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 @@ -126,7 +126,7 @@ return m_wallet->GetNewDestination(type, label, dest, error); } const CChainParams &getChainParams() override { - return m_wallet->chainParams; + return m_wallet->chainParams(); } 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 @@ -57,9 +57,9 @@ void TestAddAddressesToSendBook(interfaces::Node &node) { TestChain100Setup test; - 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/qt/test/wallettests.cpp b/src/qt/test/wallettests.cpp --- a/src/qt/test/wallettests.cpp +++ b/src/qt/test/wallettests.cpp @@ -113,9 +113,9 @@ {}, GetScriptForRawPubKey(test.coinbaseKey.GetPubKey())); } node.context()->connman = std::move(test.m_node.connman); - 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 @@ -30,7 +30,7 @@ auto spk_man = wallet.GetLegacyScriptPubKeyMan(); LOCK(wallet.cs_wallet); AssertLockHeld(spk_man->cs_wallet); - const auto dest = DecodeDestination(address, wallet.chainParams); + const auto dest = DecodeDestination(address, wallet.chainParams()); 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 @@ -327,8 +327,8 @@ auto locked_chain = pwallet->chain().lock(); LOCK(pwallet->cs_wallet); - CTxDestination dest = - DecodeDestination(request.params[0].get_str(), wallet->chainParams); + CTxDestination dest = DecodeDestination(request.params[0].get_str(), + wallet->chainParams()); if (IsValidDestination(dest)) { if (fP2SH) { throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, @@ -846,7 +846,7 @@ EnsureWalletIsUnlocked(pwallet); std::string strAddress = request.params[0].get_str(); - CTxDestination dest = DecodeDestination(strAddress, wallet->chainParams); + CTxDestination dest = DecodeDestination(strAddress, wallet->chainParams()); if (!IsValidDestination(dest)) { throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Bitcoin address"); @@ -1141,7 +1141,7 @@ // Generate the script and destination for the scriptPubKey provided CScript script; if (!isScript) { - CTxDestination dest = DecodeDestination(output, pwallet->chainParams); + CTxDestination dest = DecodeDestination(output, pwallet->chainParams()); 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 @@ -336,7 +336,7 @@ LOCK(pwallet->cs_wallet); CTxDestination dest = - DecodeDestination(request.params[0].get_str(), wallet->chainParams); + DecodeDestination(request.params[0].get_str(), wallet->chainParams()); if (!IsValidDestination(dest)) { throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Bitcoin address"); @@ -463,7 +463,7 @@ LOCK(pwallet->cs_wallet); CTxDestination dest = - DecodeDestination(request.params[0].get_str(), wallet->chainParams); + DecodeDestination(request.params[0].get_str(), wallet->chainParams()); if (!IsValidDestination(dest)) { throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address"); } @@ -613,7 +613,7 @@ 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->chainParams()); if (!IsValidDestination(dest)) { throw JSONRPCError(RPC_TYPE_ERROR, "Invalid address"); } @@ -695,7 +695,7 @@ // Bitcoin address CTxDestination dest = - DecodeDestination(request.params[0].get_str(), wallet->chainParams); + DecodeDestination(request.params[0].get_str(), wallet->chainParams()); if (!IsValidDestination(dest)) { throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Bitcoin address"); @@ -719,7 +719,7 @@ TxValidationState state; if (wtx.IsCoinBase() || !locked_chain->contextualCheckTransactionForCurrentBlock( - wallet->chainParams.GetConsensus(), *wtx.tx, state)) { + wallet->chainParams().GetConsensus(), *wtx.tx, state)) { continue; } @@ -793,7 +793,7 @@ TxValidationState state; if (wtx.IsCoinBase() || !locked_chain->contextualCheckTransactionForCurrentBlock( - wallet->chainParams.GetConsensus(), *wtx.tx, state)) { + wallet->chainParams().GetConsensus(), *wtx.tx, state)) { continue; } @@ -1025,7 +1025,7 @@ std::vector keys = sendTo.getKeys(); for (const std::string &name_ : keys) { - CTxDestination dest = DecodeDestination(name_, wallet->chainParams); + CTxDestination dest = DecodeDestination(name_, wallet->chainParams()); if (!IsValidDestination(dest)) { throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, std::string("Invalid Bitcoin address: ") + @@ -1151,7 +1151,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->chainParams(), spk_man, keys_or_addrs[i].get_str())); } } @@ -1203,12 +1203,12 @@ CTxDestination filtered_address = CNoDestination(); if (!by_label && params.size() > 3) { if (!IsValidDestinationString(params[3].get_str(), - pwallet->chainParams)) { + pwallet->chainParams())) { 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->chainParams()); has_filtered_address = true; } @@ -1220,7 +1220,7 @@ TxValidationState state; if (wtx.IsCoinBase() || !locked_chain.contextualCheckTransactionForCurrentBlock( - pwallet->chainParams.GetConsensus(), *wtx.tx, state)) { + pwallet->chainParams().GetConsensus(), *wtx.tx, state)) { continue; } @@ -3442,7 +3442,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->chainParams()); if (!IsValidDestination(dest)) { throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, std::string("Invalid Bitcoin address: ") + @@ -3607,7 +3607,7 @@ if (options.exists("changeAddress")) { CTxDestination dest = DecodeDestination( - options["changeAddress"].get_str(), pwallet->chainParams); + options["changeAddress"].get_str(), pwallet->chainParams()); if (!IsValidDestination(dest)) { throw JSONRPCError( @@ -4255,7 +4255,7 @@ UniValue ret(UniValue::VOBJ); CTxDestination dest = - DecodeDestination(request.params[0].get_str(), wallet->chainParams); + DecodeDestination(request.params[0].get_str(), wallet->chainParams()); // Make sure the destination is valid if (!IsValidDestination(dest)) { throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address"); @@ -4780,7 +4780,7 @@ Amount fee; int change_position; CMutableTransaction rawTx = - ConstructTransaction(wallet->chainParams, request.params[0], + ConstructTransaction(wallet->chainParams(), request.params[0], request.params[1], request.params[2]); FundTransaction(pwallet, rawTx, fee, change_position, request.params[3]); 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 @@ -304,7 +304,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; @@ -733,7 +733,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()); // Random generator stuff 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()); LOCK(keystore.cs_wallet); scriptPubKey = GetScriptForRawPubKey(pubkeys[0]); @@ -54,7 +54,7 @@ // P2PK uncompressed { - CWallet keystore(Params(), chain.get(), WalletLocation(), + CWallet keystore(chain.get(), WalletLocation(), WalletDatabase::CreateDummy()); LOCK(keystore.cs_wallet); scriptPubKey = GetScriptForRawPubKey(uncompressedPubkey); @@ -72,7 +72,7 @@ // P2PKH compressed { - CWallet keystore(Params(), chain.get(), WalletLocation(), + CWallet keystore(chain.get(), WalletLocation(), WalletDatabase::CreateDummy()); LOCK(keystore.cs_wallet); scriptPubKey = GetScriptForDestination(PKHash(pubkeys[0])); @@ -89,7 +89,7 @@ // P2PKH uncompressed { - CWallet keystore(Params(), chain.get(), WalletLocation(), + CWallet keystore(chain.get(), WalletLocation(), WalletDatabase::CreateDummy()); LOCK(keystore.cs_wallet); scriptPubKey = GetScriptForDestination(PKHash(uncompressedPubkey)); @@ -107,7 +107,7 @@ // P2SH { - CWallet keystore(Params(), chain.get(), WalletLocation(), + CWallet keystore(chain.get(), WalletLocation(), WalletDatabase::CreateDummy()); LOCK(keystore.cs_wallet); @@ -132,7 +132,7 @@ // (P2PKH inside) P2SH inside P2SH (invalid) { - CWallet keystore(Params(), chain.get(), WalletLocation(), + CWallet keystore(chain.get(), WalletLocation(), WalletDatabase::CreateDummy()); LOCK(keystore.cs_wallet); @@ -155,7 +155,7 @@ // scriptPubKey multisig { - CWallet keystore(Params(), chain.get(), WalletLocation(), + CWallet keystore(chain.get(), WalletLocation(), WalletDatabase::CreateDummy()); LOCK(keystore.cs_wallet); @@ -189,7 +189,7 @@ // P2SH multisig { - CWallet keystore(Params(), chain.get(), WalletLocation(), + CWallet keystore(chain.get(), WalletLocation(), WalletDatabase::CreateDummy()); LOCK(keystore.cs_wallet); BOOST_CHECK( @@ -213,7 +213,7 @@ // OP_RETURN { - CWallet keystore(Params(), chain.get(), WalletLocation(), + CWallet keystore(chain.get(), WalletLocation(), WalletDatabase::CreateDummy()); LOCK(keystore.cs_wallet); BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[0])); @@ -227,7 +227,7 @@ // Nonstandard { - CWallet keystore(Params(), chain.get(), WalletLocation(), + CWallet keystore(chain.get(), WalletLocation(), WalletDatabase::CreateDummy()); LOCK(keystore.cs_wallet); BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[0])); 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 @@ -49,7 +49,7 @@ // Verify ScanForWalletTransactions accommodates a null start block. { - CWallet wallet(Params(), chain.get(), WalletLocation(), + CWallet wallet(chain.get(), WalletLocation(), WalletDatabase::CreateDummy()); { LOCK(wallet.cs_wallet); @@ -71,7 +71,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); @@ -97,7 +97,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); @@ -122,7 +122,7 @@ // Verify ScanForWalletTransactions scans no blocks. { - CWallet wallet(Params(), chain.get(), WalletLocation(), + CWallet wallet(chain.get(), WalletLocation(), WalletDatabase::CreateDummy()); { LOCK(wallet.cs_wallet); @@ -162,9 +162,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()); AddWallet(wallet); UniValue keys; keys.setArray(); @@ -244,9 +243,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->GetLegacyScriptPubKeyMan(); LOCK(wallet->cs_wallet); AssertLockHeld(spk_man->cs_wallet); @@ -265,9 +263,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()); JSONRPCRequest request; request.params.setArray(); @@ -296,7 +293,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.GetLegacyScriptPubKeyMan(); CWalletTx wtx(&wallet, m_coinbase_txns.back()); @@ -491,9 +488,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()); { LOCK(wallet->cs_wallet); wallet->SetLastBlockProcessed( @@ -630,7 +626,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->SetMinVersion(FEATURE_LATEST); wallet->SetWalletFlag(WALLET_FLAG_DISABLE_PRIVATE_KEYS); BOOST_CHECK(!wallet->TopUpKeyPool(1000)); 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 @@ -763,7 +763,6 @@ int m_last_block_processed_height GUARDED_BY(cs_wallet) = -1; public: - const CChainParams &chainParams; /* * Main wallet lock. * This lock protects all the fields added by CWallet. @@ -801,11 +800,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. @@ -843,6 +841,8 @@ return *m_chain; } + const CChainParams &chainParams() const; + const CWalletTx *GetWalletTx(const TxId &txid) const; //! check whether we are allowed to upgrade (or already support) to the diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -283,6 +283,12 @@ nDepth, FormatMoney(tx->tx->vout[i].nValue)); } +const CChainParams &CWallet::chainParams() 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); @@ -2082,7 +2088,7 @@ // Quick answer in most cases TxValidationState state; if (!locked_chain.contextualCheckTransactionForCurrentBlock( - this->pwallet->chainParams.GetConsensus(), *tx, state)) { + this->pwallet->chainParams().GetConsensus(), *tx, state)) { return false; } @@ -2290,7 +2296,7 @@ const int max_depth = {coinControl ? coinControl->m_max_depth : DEFAULT_MAX_DEPTH}; - const Consensus::Params params = this->chainParams.GetConsensus(); + const Consensus::Params params = this->chainParams().GetConsensus(); std::set trusted_parents; for (const auto &entry : mapWallet) { @@ -3962,7 +3968,7 @@ if (salvage_wallet) { // Recover readable keypairs: - CWallet dummyWallet(chainParams, &chain, WalletLocation(), + CWallet dummyWallet(&chain, WalletLocation(), WalletDatabase::CreateDummy()); std::string backup_filename; // Even if we don't use this lock in this function, we want to preserve @@ -3995,8 +4001,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 = @@ -4012,7 +4017,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 @@ -221,14 +221,14 @@ ssKey >> strAddress; ssValue >> pwallet ->mapAddressBook[DecodeDestination( - strAddress, pwallet->chainParams)] + strAddress, pwallet->chainParams())] .name; } else if (strType == DBKeys::PURPOSE) { std::string strAddress; ssKey >> strAddress; ssValue >> pwallet ->mapAddressBook[DecodeDestination( - strAddress, pwallet->chainParams)] + strAddress, pwallet->chainParams())] .purpose; } else if (strType == DBKeys::TX) { TxId txid; @@ -412,7 +412,7 @@ ssKey >> strKey; ssValue >> strValue; pwallet->LoadDestData( - DecodeDestination(strAddress, pwallet->chainParams), strKey, + DecodeDestination(strAddress, pwallet->chainParams()), strKey, strValue); } else if (strType == DBKeys::HDCHAIN) { CHDChain chain; diff --git a/src/wallet/wallettool.cpp b/src/wallet/wallettool.cpp --- a/src/wallet/wallettool.cpp +++ b/src/wallet/wallettool.cpp @@ -30,7 +30,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); bool first_run = true; @@ -61,7 +61,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;