diff --git a/src/interfaces/node.h b/src/interfaces/node.h index f6eb8d6fb8..cd50480b07 100644 --- a/src/interfaces/node.h +++ b/src/interfaces/node.h @@ -37,7 +37,7 @@ struct NodeContext; namespace interfaces { class Handler; -class WalletClient; +class WalletLoader; struct BlockTip; //! Interface for the src/evo part of a dash node (dashd process). @@ -284,8 +284,8 @@ public: //! Get unspent outputs associated with a transaction. virtual bool getUnspentOutput(const COutPoint& output, Coin& coin) = 0; - //! Get wallet client. - virtual WalletClient& walletClient() = 0; + //! Get wallet loader. + virtual WalletLoader& walletLoader() = 0; //! Return interface for accessing evo related handler. virtual EVO& evo() = 0; diff --git a/src/interfaces/wallet.h b/src/interfaces/wallet.h index 049b177690..7232bc79f6 100644 --- a/src/interfaces/wallet.h +++ b/src/interfaces/wallet.h @@ -349,7 +349,7 @@ public: //! Wallet chain client that in addition to having chain client methods for //! starting up, shutting down, and registering RPCs, also has additional //! methods (called by the GUI) to load and create wallets. -class WalletClient : public ChainClient +class WalletLoader : public ChainClient { public: //! Create new wallet. @@ -456,9 +456,9 @@ struct WalletTxOut //! dummywallet.cpp and throws if the wallet component is not compiled. std::unique_ptr MakeWallet(const std::shared_ptr& wallet); -//! Return implementation of ChainClient interface for a wallet client. This +//! Return implementation of ChainClient interface for a wallet loader. This //! function will be undefined in builds where ENABLE_WALLET is false. -std::unique_ptr MakeWalletClient(Chain& chain, ArgsManager& args); +std::unique_ptr MakeWalletLoader(Chain& chain, ArgsManager& args); } // namespace interfaces diff --git a/src/node/context.h b/src/node/context.h index 32f2b511bb..f44cc8d51b 100644 --- a/src/node/context.h +++ b/src/node/context.h @@ -25,7 +25,7 @@ class CEvoDB; namespace interfaces { class Chain; class ChainClient; -class WalletClient; +class WalletLoader; } // namespace interfaces //! NodeContext struct containing references to chain state and connection @@ -52,7 +52,7 @@ struct NodeContext { std::vector> chain_clients; //! Reference to chain client that should used to load or create wallets //! opened by the gui. - interfaces::WalletClient* wallet_client{nullptr}; + interfaces::WalletLoader* wallet_loader{nullptr}; std::unique_ptr scheduler; std::function rpc_interruption_point = [] {}; //! Dash diff --git a/src/node/interfaces.cpp b/src/node/interfaces.cpp index c74e20d016..036187e538 100644 --- a/src/node/interfaces.cpp +++ b/src/node/interfaces.cpp @@ -71,7 +71,7 @@ using interfaces::Handler; using interfaces::LLMQ; using interfaces::MakeHandler; using interfaces::Node; -using interfaces::WalletClient; +using interfaces::WalletLoader; namespace node { namespace { @@ -431,9 +431,9 @@ public: assert(std::addressof(::ChainstateActive()) == std::addressof(chainman().ActiveChainstate())); return chainman().ActiveChainstate().CoinsTip().GetCoin(output, coin); } - WalletClient& walletClient() override + WalletLoader& walletLoader() override { - return *Assert(m_context->wallet_client); + return *Assert(m_context->wallet_loader); } EVO& evo() override { return m_evo; } diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 00bab9460a..03ef6acbc0 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -1357,7 +1357,7 @@ void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, const QStri bool disableAppNap = !m_node.masternodeSync().isSynced(); #ifdef ENABLE_WALLET if (enableWallet) { - for (const auto& wallet : m_node.walletClient().getWallets()) { + for (const auto& wallet : m_node.walletLoader().getWallets()) { disableAppNap |= wallet->coinJoin().isMixing(); } } @@ -1725,7 +1725,7 @@ void BitcoinGUI::showIncomingTransactions() // On new transaction, make an info balloon QString msg = tr("Date: %1\n").arg(itx.date) + tr("Amount: %1\n").arg(BitcoinUnits::formatWithUnit(itx.unit, itx.amount, true)); - if (m_node.walletClient().getWallets().size() > 1 && !itx.walletName.isEmpty()) { + if (m_node.walletLoader().getWallets().size() > 1 && !itx.walletName.isEmpty()) { msg += tr("Wallet: %1\n").arg(itx.walletName); } msg += tr("Type: %1\n").arg(itx.type); diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp index 0af071c11c..b74646a95e 100644 --- a/src/qt/optionsdialog.cpp +++ b/src/qt/optionsdialog.cpp @@ -404,7 +404,7 @@ void OptionsDialog::on_okButton_clicked() appearance->accept(); #ifdef ENABLE_WALLET if (m_enable_wallet) { - for (auto& wallet : model->node().walletClient().getWallets()) { + for (auto& wallet : model->node().walletLoader().getWallets()) { wallet->coinJoin().resetCachedBlocks(); wallet->markDirty(); } diff --git a/src/qt/splashscreen.cpp b/src/qt/splashscreen.cpp index 01c8df2ddb..1e56981a08 100644 --- a/src/qt/splashscreen.cpp +++ b/src/qt/splashscreen.cpp @@ -189,7 +189,7 @@ void SplashScreen::handleLoadWallet() { #ifdef ENABLE_WALLET if (!WalletModel::isWalletEnabled()) return; - m_handler_load_wallet = m_node.walletClient().handleLoadWallet([this](std::unique_ptr wallet) { + m_handler_load_wallet = m_node.walletLoader().handleLoadWallet([this](std::unique_ptr wallet) { m_connected_wallet_handlers.emplace_back(wallet->handleShowProgress(std::bind(ShowProgress, this, std::placeholders::_1, std::placeholders::_2, false))); m_connected_wallets.emplace_back(std::move(wallet)); }); diff --git a/src/qt/walletcontroller.cpp b/src/qt/walletcontroller.cpp index 51eab2d652..ddd2fd346a 100644 --- a/src/qt/walletcontroller.cpp +++ b/src/qt/walletcontroller.cpp @@ -34,11 +34,11 @@ WalletController::WalletController(ClientModel& client_model, QObject* parent) , m_node(client_model.node()) , m_options_model(client_model.getOptionsModel()) { - m_handler_load_wallet = m_node.walletClient().handleLoadWallet([this](std::unique_ptr wallet) { + m_handler_load_wallet = m_node.walletLoader().handleLoadWallet([this](std::unique_ptr wallet) { getOrCreateWallet(std::move(wallet)); }); - for (std::unique_ptr& wallet : m_node.walletClient().getWallets()) { + for (std::unique_ptr& wallet : m_node.walletLoader().getWallets()) { getOrCreateWallet(std::move(wallet)); } @@ -65,7 +65,7 @@ std::map WalletController::listWalletDir() const { QMutexLocker locker(&m_mutex); std::map wallets; - for (const std::string& name : m_node.walletClient().listWalletDir()) { + for (const std::string& name : m_node.walletLoader().listWalletDir()) { wallets[name] = false; } for (WalletModel* wallet_model : m_wallets) { @@ -228,7 +228,7 @@ void CreateWalletActivity::createWallet() } QTimer::singleShot(500, worker(), [this, name, flags] { - std::unique_ptr wallet = node().walletClient().createWallet(name, m_passphrase, flags, m_error_message, m_warning_message); + std::unique_ptr wallet = node().walletLoader().createWallet(name, m_passphrase, flags, m_error_message, m_warning_message); if (wallet) m_wallet_model = m_wallet_controller->getOrCreateWallet(std::move(wallet)); @@ -299,7 +299,7 @@ void OpenWalletActivity::open(const std::string& path) showProgressDialog(tr("Opening Wallet %1...").arg(name.toHtmlEscaped())); QTimer::singleShot(0, worker(), [this, path] { - std::unique_ptr wallet = node().walletClient().loadWallet(path, m_error_message, m_warning_message); + std::unique_ptr wallet = node().walletLoader().loadWallet(path, m_error_message, m_warning_message); if (wallet) m_wallet_model = m_wallet_controller->getOrCreateWallet(std::move(wallet)); diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp index 53900aa06e..8a27a6719d 100644 --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -606,7 +606,7 @@ QString WalletModel::getDisplayName() const bool WalletModel::isMultiwallet() { - return m_node.walletClient().getWallets().size() > 1; + return m_node.walletLoader().getWallets().size() > 1; } uint256 WalletModel::getLastBlockProcessed() const diff --git a/src/wallet/init.cpp b/src/wallet/init.cpp index f6c9a51328..4956d92c8a 100644 --- a/src/wallet/init.cpp +++ b/src/wallet/init.cpp @@ -185,9 +185,9 @@ void WalletInit::Construct(NodeContext& node) const LogPrintf("Wallet disabled!\n"); return; } - auto wallet_client = interfaces::MakeWalletClient(*node.chain, args); - node.wallet_client = wallet_client.get(); - node.chain_clients.emplace_back(std::move(wallet_client)); + auto wallet_loader = interfaces::MakeWalletLoader(*node.chain, args); + node.wallet_loader = wallet_loader.get(); + node.chain_clients.emplace_back(std::move(wallet_loader)); } diff --git a/src/wallet/interfaces.cpp b/src/wallet/interfaces.cpp index 2ddaccd7cb..69be72a8ab 100644 --- a/src/wallet/interfaces.cpp +++ b/src/wallet/interfaces.cpp @@ -38,7 +38,7 @@ using interfaces::MakeHandler; using interfaces::Wallet; using interfaces::WalletAddress; using interfaces::WalletBalances; -using interfaces::WalletClient; +using interfaces::WalletLoader; using interfaces::WalletOrderForm; using interfaces::WalletTx; using interfaces::WalletTxOut; @@ -601,15 +601,15 @@ public: CoinJoinImpl m_coinjoin; }; -class WalletClientImpl : public WalletClient +class WalletLoaderImpl : public WalletLoader { public: - WalletClientImpl(Chain& chain, ArgsManager& args) + WalletLoaderImpl(Chain& chain, ArgsManager& args) { m_context.chain = &chain; m_context.args = &args; } - ~WalletClientImpl() override { UnloadWallets(); } + ~WalletLoaderImpl() override { UnloadWallets(); } //! ChainClient methods void registerRpcs() override @@ -628,7 +628,7 @@ public: void stop() override { return StopWallets(); } void setMockTime(int64_t time) override { return SetMockTime(time); } - //! WalletClient methods + //! WalletLoader methods std::unique_ptr createWallet(const std::string& name, const SecureString& passphrase, uint64_t wallet_creation_flags, bilingual_str& error, std::vector& warnings) override { std::shared_ptr wallet; @@ -681,7 +681,7 @@ public: namespace interfaces { std::unique_ptr MakeWallet(const std::shared_ptr& wallet) { return wallet ? std::make_unique(wallet) : nullptr; } -std::unique_ptr MakeWalletClient(Chain& chain, ArgsManager& args) { - return std::make_unique(chain, args); +std::unique_ptr MakeWalletLoader(Chain& chain, ArgsManager& args) { + return std::make_unique(chain, args); } } // namespace interfaces diff --git a/src/wallet/test/init_test_fixture.cpp b/src/wallet/test/init_test_fixture.cpp index 59fc162ee7..6242af1f32 100644 --- a/src/wallet/test/init_test_fixture.cpp +++ b/src/wallet/test/init_test_fixture.cpp @@ -10,7 +10,7 @@ InitWalletDirTestingSetup::InitWalletDirTestingSetup(const std::string& chainName) : BasicTestingSetup(chainName) { - m_wallet_client = MakeWalletClient(*m_node.chain, *Assert(m_node.args)); + m_wallet_loader = MakeWalletLoader(*m_node.chain, *Assert(m_node.args)); std::string sep; sep += fs::path::preferred_separator; diff --git a/src/wallet/test/init_test_fixture.h b/src/wallet/test/init_test_fixture.h index acf8789fe8..0dfc5767b4 100644 --- a/src/wallet/test/init_test_fixture.h +++ b/src/wallet/test/init_test_fixture.h @@ -19,7 +19,7 @@ struct InitWalletDirTestingSetup: public BasicTestingSetup { fs::path m_datadir; fs::path m_cwd; std::map m_walletdir_path_cases; - std::unique_ptr m_wallet_client; + std::unique_ptr m_wallet_loader; }; #endif // BITCOIN_WALLET_TEST_INIT_TEST_FIXTURE_H diff --git a/src/wallet/test/init_tests.cpp b/src/wallet/test/init_tests.cpp index 811708e06a..0fba357252 100644 --- a/src/wallet/test/init_tests.cpp +++ b/src/wallet/test/init_tests.cpp @@ -16,7 +16,7 @@ BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_default) SetWalletDir(m_walletdir_path_cases["default"]); { ASSERT_DEBUG_LOG(""); - bool result = m_wallet_client->verify(); + bool result = m_wallet_loader->verify(); BOOST_CHECK(result == true); } fs::path walletdir = gArgs.GetArg("-walletdir", ""); @@ -29,7 +29,7 @@ BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_custom) SetWalletDir(m_walletdir_path_cases["custom"]); { ASSERT_DEBUG_LOG(""); - bool result = m_wallet_client->verify(); + bool result = m_wallet_loader->verify(); BOOST_CHECK(result == true); } fs::path walletdir = gArgs.GetArg("-walletdir", ""); @@ -42,7 +42,7 @@ BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_does_not_exist) SetWalletDir(m_walletdir_path_cases["nonexistent"]); { ASSERT_DEBUG_LOG("does not exist"); - bool result = m_wallet_client->verify(); + bool result = m_wallet_loader->verify(); BOOST_CHECK(result == false); } } @@ -52,7 +52,7 @@ BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_is_not_directory) SetWalletDir(m_walletdir_path_cases["file"]); { ASSERT_DEBUG_LOG("is not a directory"); - bool result = m_wallet_client->verify(); + bool result = m_wallet_loader->verify(); BOOST_CHECK(result == false); } } @@ -62,7 +62,7 @@ BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_is_not_relative) SetWalletDir(m_walletdir_path_cases["relative"]); { ASSERT_DEBUG_LOG("is a relative path"); - bool result = m_wallet_client->verify(); + bool result = m_wallet_loader->verify(); BOOST_CHECK(result == false); } } @@ -72,7 +72,7 @@ BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_no_trailing) SetWalletDir(m_walletdir_path_cases["trailing"]); { ASSERT_DEBUG_LOG(""); - bool result = m_wallet_client->verify(); + bool result = m_wallet_loader->verify(); BOOST_CHECK(result == true); } fs::path walletdir = gArgs.GetArg("-walletdir", ""); @@ -85,7 +85,7 @@ BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_no_trailing2) SetWalletDir(m_walletdir_path_cases["trailing2"]); { ASSERT_DEBUG_LOG(""); - bool result = m_wallet_client->verify(); + bool result = m_wallet_loader->verify(); BOOST_CHECK(result == true); } fs::path walletdir = gArgs.GetArg("-walletdir", ""); diff --git a/src/wallet/test/wallet_test_fixture.cpp b/src/wallet/test/wallet_test_fixture.cpp index 27c01c47f4..fc6100557d 100644 --- a/src/wallet/test/wallet_test_fixture.cpp +++ b/src/wallet/test/wallet_test_fixture.cpp @@ -12,5 +12,5 @@ WalletTestingSetup::WalletTestingSetup(const std::string& chainName) bool fFirstRun; m_wallet.LoadWallet(fFirstRun); m_chain_notifications_handler = m_node.chain->handleNotifications({ &m_wallet, [](CWallet*) {} }); - m_wallet_client->registerRpcs(); + m_wallet_loader->registerRpcs(); } diff --git a/src/wallet/test/wallet_test_fixture.h b/src/wallet/test/wallet_test_fixture.h index ab7fb8c42b..4f034489f1 100644 --- a/src/wallet/test/wallet_test_fixture.h +++ b/src/wallet/test/wallet_test_fixture.h @@ -20,7 +20,7 @@ struct WalletTestingSetup : public TestingSetup { explicit WalletTestingSetup(const std::string& chainName = CBaseChainParams::MAIN); - std::unique_ptr m_wallet_client = interfaces::MakeWalletClient(*m_node.chain, *Assert(m_node.args)); + std::unique_ptr m_wallet_loader = interfaces::MakeWalletLoader(*m_node.chain, *Assert(m_node.args)); CWallet m_wallet; std::unique_ptr m_chain_notifications_handler; }; diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index b6f796db29..83eaff9fbb 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -49,7 +49,7 @@ using LoadWalletFn = std::function wall //! Explicitly unload and delete the wallet. // Blocks the current thread after signaling the unload intent so that all -// wallet clients release the wallet. +// wallet pointer owners release the wallet. // Note that, when blocking is not required, the wallet is implicitly unloaded // by the shared pointer deleter. void UnloadWallet(std::shared_ptr&& wallet);