diff --git a/src/bench/wallet_balance.cpp b/src/bench/wallet_balance.cpp index 7fd279416..46ca12826 100644 --- a/src/bench/wallet_balance.cpp +++ b/src/bench/wallet_balance.cpp @@ -10,31 +10,16 @@ #include #include -struct WalletTestingSetup { - std::unique_ptr m_chain = interfaces::MakeChain(); - CWallet m_wallet; - - WalletTestingSetup() - : m_wallet{m_chain.get(), WalletLocation(), WalletDatabase::CreateMock()} - { - } - - void handleNotifications() - { - m_wallet.m_chain_notifications_handler = m_chain->handleNotifications(m_wallet); - } -}; - static void WalletBalance(benchmark::State& state, const bool set_dirty, const bool add_watchonly, const bool add_mine) { const auto& ADDRESS_WATCHONLY = ADDRESS_BCRT1_UNSPENDABLE; - WalletTestingSetup wallet_t{}; - auto& wallet = wallet_t.m_wallet; + std::unique_ptr chain = interfaces::MakeChain(); + CWallet wallet{chain.get(), WalletLocation(), WalletDatabase::CreateMock()}; { bool first_run; if (wallet.LoadWallet(first_run) != DBErrors::LOAD_OK) assert(false); - wallet_t.handleNotifications(); + wallet.handleNotifications(); } diff --git a/src/wallet/test/wallet_test_fixture.cpp b/src/wallet/test/wallet_test_fixture.cpp index 7b8299453..6526e69ee 100644 --- a/src/wallet/test/wallet_test_fixture.cpp +++ b/src/wallet/test/wallet_test_fixture.cpp @@ -8,12 +8,13 @@ #include #include -WalletTestingSetup::WalletTestingSetup(const std::string& chainName): - TestingSetup(chainName), m_wallet(m_chain.get(), WalletLocation(), WalletDatabase::CreateMock()) +WalletTestingSetup::WalletTestingSetup(const std::string& chainName) + : TestingSetup(chainName), + m_wallet(m_chain.get(), WalletLocation(), WalletDatabase::CreateMock()) { bool fFirstRun; m_wallet.LoadWallet(fFirstRun); - m_wallet.m_chain_notifications_handler = m_chain->handleNotifications(m_wallet); + m_wallet.handleNotifications(); m_chain_client->registerRpcs(); } diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 98ba48972..4737e2f6f 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -5,9 +5,8 @@ #include -#include #include -#include +#include #include #include #include @@ -16,7 +15,6 @@ #include #include #include -#include #include #include #include @@ -34,6 +32,8 @@ #include #include #include +#include +#include #include #include @@ -4303,7 +4303,7 @@ std::shared_ptr CWallet::CreateWalletFromFile(interfaces::Chain& chain, chain.loadWallet(interfaces::MakeWallet(walletInstance)); // Register with the validation interface. It's ok to do this after rescan since we're still holding locked_chain. - walletInstance->m_chain_notifications_handler = chain.handleNotifications(*walletInstance); + walletInstance->handleNotifications(); walletInstance->SetBroadcastTransactions(gArgs.GetBoolArg("-walletbroadcast", DEFAULT_WALLETBROADCAST)); @@ -4316,6 +4316,11 @@ std::shared_ptr CWallet::CreateWalletFromFile(interfaces::Chain& chain, return walletInstance; } +void CWallet::handleNotifications() +{ + m_chain_notifications_handler = m_chain->handleNotifications(*this); +} + void CWallet::postInitProcess() { auto locked_chain = chain().lock(); diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 53de1ea06..62ba0aa96 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -11,16 +11,16 @@ #include #include #include +#include