@@ -127,7 +127,7 @@ WalletTxOut MakeWalletTxOut(const CWallet& wallet,
127127class WalletImpl : public Wallet
128128{
129129public:
130- explicit WalletImpl (const std::shared_ptr<CWallet>& wallet) : m_wallet(wallet) {}
130+ explicit WalletImpl (WalletContext& context, const std::shared_ptr<CWallet>& wallet) : m_context(context), m_wallet(wallet) {}
131131
132132 void markDirty () override
133133 {
@@ -501,7 +501,7 @@ class WalletImpl : public Wallet
501501 CAmount getDefaultMaxTxFee () override { return m_wallet->m_default_max_tx_fee ; }
502502 void remove () override
503503 {
504- RemoveWallet (m_wallet, false /* load_on_start */ );
504+ RemoveWallet (m_context, m_wallet, false /* load_on_start */ );
505505 }
506506 bool isLegacy () override { return m_wallet->IsLegacy (); }
507507 std::unique_ptr<Handler> handleUnload (UnloadFn fn) override
@@ -547,6 +547,7 @@ class WalletImpl : public Wallet
547547 }
548548 CWallet* wallet () override { return m_wallet.get (); }
549549
550+ WalletContext& m_context;
550551 std::shared_ptr<CWallet> m_wallet;
551552 std::unique_ptr<interfaces::CoinJoin::Client> m_coinjoin_client;
552553};
@@ -575,7 +576,7 @@ class WalletLoaderImpl : public WalletLoader
575576 m_context.node_context = &node_context;
576577 m_context.coinjoin_loader = &coinjoin_loader;
577578 }
578- ~WalletLoaderImpl () override { UnloadWallets (); }
579+ ~WalletLoaderImpl () override { UnloadWallets (m_context ); }
579580
580581 // ! ChainClient methods
581582 void registerRpcs () override
@@ -585,8 +586,8 @@ class WalletLoaderImpl : public WalletLoader
585586 bool verify () override { return VerifyWallets (m_context); }
586587 bool load () override { return LoadWallets (m_context); }
587588 void start (CScheduler& scheduler) override { return StartWallets (m_context, scheduler); }
588- void flush () override { return FlushWallets (); }
589- void stop () override { return StopWallets (); }
589+ void flush () override { return FlushWallets (m_context ); }
590+ void stop () override { return StopWallets (m_context ); }
590591 void setMockTime (int64_t time) override { return SetMockTime (time); }
591592
592593 // ! WalletLoader methods
@@ -602,19 +603,19 @@ class WalletLoaderImpl : public WalletLoader
602603 options.require_create = true ;
603604 options.create_flags = wallet_creation_flags;
604605 options.create_passphrase = passphrase;
605- return MakeWallet (CreateWallet (m_context, name, true /* load_on_start */ , options, status, error, warnings));
606+ return MakeWallet (m_context, CreateWallet (m_context, name, true /* load_on_start */ , options, status, error, warnings));
606607 }
607608 std::unique_ptr<Wallet> loadWallet (const std::string& name, bilingual_str& error, std::vector<bilingual_str>& warnings) override
608609 {
609610 DatabaseOptions options;
610611 DatabaseStatus status;
611612 options.require_existing = true ;
612- return MakeWallet (LoadWallet (m_context, name, true /* load_on_start */ , options, status, error, warnings));
613+ return MakeWallet (m_context, LoadWallet (m_context, name, true /* load_on_start */ , options, status, error, warnings));
613614 }
614615 std::unique_ptr<Wallet> restoreWallet (const fs::path& backup_file, const std::string& wallet_name, bilingual_str& error, std::vector<bilingual_str>& warnings) override
615616 {
616617 DatabaseStatus status;
617- return MakeWallet (RestoreWallet (m_context, backup_file, wallet_name, /* load_on_start=*/ true , status, error, warnings));
618+ return MakeWallet (m_context, RestoreWallet (m_context, backup_file, wallet_name, /* load_on_start=*/ true , status, error, warnings));
618619 }
619620 std::string getWalletDir () override
620621 {
@@ -631,14 +632,14 @@ class WalletLoaderImpl : public WalletLoader
631632 std::vector<std::unique_ptr<Wallet>> getWallets () override
632633 {
633634 std::vector<std::unique_ptr<Wallet>> wallets;
634- for (const auto & wallet : GetWallets ()) {
635- wallets.emplace_back (MakeWallet (wallet));
635+ for (const auto & wallet : GetWallets (m_context )) {
636+ wallets.emplace_back (MakeWallet (m_context, wallet));
636637 }
637638 return wallets;
638639 }
639640 std::unique_ptr<Handler> handleLoadWallet (LoadWalletFn fn) override
640641 {
641- return HandleLoadWallet (std::move (fn));
642+ return HandleLoadWallet (m_context, std::move (fn));
642643 }
643644 WalletContext* context () override { return &m_context; }
644645
@@ -651,7 +652,7 @@ class WalletLoaderImpl : public WalletLoader
651652} // namespace wallet
652653
653654namespace interfaces {
654- std::unique_ptr<Wallet> MakeWallet (const std::shared_ptr<CWallet>& wallet) { return wallet ? std::make_unique<wallet::WalletImpl>(wallet) : nullptr ; }
655+ std::unique_ptr<Wallet> MakeWallet (WalletContext& context, const std::shared_ptr<CWallet>& wallet) { return wallet ? std::make_unique<wallet::WalletImpl>(context, wallet) : nullptr ; }
655656std::unique_ptr<WalletLoader> MakeWalletLoader (Chain& chain, ArgsManager& args, NodeContext& node_context,
656657 interfaces::CoinJoin::Loader& coinjoin_loader)
657658{
0 commit comments