@@ -97,7 +97,7 @@ WalletTxOut MakeWalletTxOut(CWallet& wallet,
9797class WalletImpl : public Wallet
9898{
9999public:
100- explicit WalletImpl (const std::shared_ptr<CWallet>& wallet) : m_wallet(wallet) {}
100+ explicit WalletImpl (WalletContext& context, const std::shared_ptr<CWallet>& wallet) : m_context(context), m_wallet(wallet) {}
101101
102102 bool encryptWallet (const SecureString& wallet_passphrase) override
103103 {
@@ -446,7 +446,7 @@ class WalletImpl : public Wallet
446446 CAmount getDefaultMaxTxFee () override { return m_wallet->m_default_max_tx_fee ; }
447447 void remove () override
448448 {
449- RemoveWallet (m_wallet, false /* load_on_start */ );
449+ RemoveWallet (m_context, m_wallet, false /* load_on_start */ );
450450 }
451451 bool isLegacy () override { return m_wallet->IsLegacy (); }
452452 std::unique_ptr<Handler> handleUnload (UnloadFn fn) override
@@ -482,6 +482,7 @@ class WalletImpl : public Wallet
482482 }
483483 CWallet* wallet () override { return m_wallet.get (); }
484484
485+ WalletContext& m_context;
485486 std::shared_ptr<CWallet> m_wallet;
486487};
487488
@@ -494,7 +495,7 @@ class WalletClientImpl : public WalletClient
494495 m_context.chain = &chain;
495496 m_context.args = &args;
496497 }
497- ~WalletClientImpl () override { UnloadWallets (); }
498+ ~WalletClientImpl () override { UnloadWallets (m_context ); }
498499
499500 // ! ChainClient methods
500501 void registerRpcs () override
@@ -506,23 +507,23 @@ class WalletClientImpl : public WalletClient
506507 m_rpc_handlers.emplace_back (m_context.chain ->handleRpc (m_rpc_commands.back ()));
507508 }
508509 }
509- bool verify () override { return VerifyWallets (* m_context. chain , m_wallet_filenames); }
510- bool load () override { return LoadWallets (* m_context. chain , m_wallet_filenames); }
511- void start (CScheduler& scheduler) override { return StartWallets (scheduler, * Assert (m_context. args ) ); }
512- void flush () override { return FlushWallets (); }
513- void stop () override { return StopWallets (); }
510+ bool verify () override { return VerifyWallets (m_context, m_wallet_filenames); }
511+ bool load () override { return LoadWallets (m_context, m_wallet_filenames); }
512+ void start (CScheduler& scheduler) override { return StartWallets (m_context, scheduler ); }
513+ void flush () override { return FlushWallets (m_context ); }
514+ void stop () override { return StopWallets (m_context ); }
514515 void setMockTime (int64_t time) override { return SetMockTime (time); }
515516
516517 // ! WalletClient methods
517518 std::unique_ptr<Wallet> createWallet (const std::string& name, const SecureString& passphrase, uint64_t wallet_creation_flags, WalletCreationStatus& status, bilingual_str& error, std::vector<bilingual_str>& warnings) override
518519 {
519520 std::shared_ptr<CWallet> wallet;
520- status = CreateWallet (* m_context. chain , passphrase, wallet_creation_flags, name, true /* load_on_start */ , error, warnings, wallet);
521- return MakeWallet (std::move (wallet));
521+ status = CreateWallet (m_context, passphrase, wallet_creation_flags, name, true /* load_on_start */ , error, warnings, wallet);
522+ return MakeWallet (m_context, std::move (wallet));
522523 }
523524 std::unique_ptr<Wallet> loadWallet (const std::string& name, bilingual_str& error, std::vector<bilingual_str>& warnings) override
524525 {
525- return MakeWallet (LoadWallet (* m_context. chain , WalletLocation (name), true /* load_on_start */ , error, warnings));
526+ return MakeWallet (m_context, LoadWallet (m_context, WalletLocation (name), true /* load_on_start */ , error, warnings));
526527 }
527528 std::string getWalletDir () override
528529 {
@@ -539,15 +540,16 @@ class WalletClientImpl : public WalletClient
539540 std::vector<std::unique_ptr<Wallet>> getWallets () override
540541 {
541542 std::vector<std::unique_ptr<Wallet>> wallets;
542- for (const auto & wallet : GetWallets ()) {
543- wallets.emplace_back (MakeWallet (wallet));
543+ for (const auto & wallet : GetWallets (m_context )) {
544+ wallets.emplace_back (MakeWallet (m_context, wallet));
544545 }
545546 return wallets;
546547 }
547548 std::unique_ptr<Handler> handleLoadWallet (LoadWalletFn fn) override
548549 {
549- return HandleLoadWallet (std::move (fn));
550+ return HandleLoadWallet (m_context, std::move (fn));
550551 }
552+ WalletContext* context () override { return &m_context; }
551553
552554 WalletContext m_context;
553555 const std::vector<std::string> m_wallet_filenames;
@@ -557,7 +559,7 @@ class WalletClientImpl : public WalletClient
557559
558560} // namespace
559561
560- std::unique_ptr<Wallet> MakeWallet (const std::shared_ptr<CWallet>& wallet) { return wallet ? MakeUnique<WalletImpl>(wallet) : nullptr ; }
562+ std::unique_ptr<Wallet> MakeWallet (WalletContext& context, const std::shared_ptr<CWallet>& wallet) { return wallet ? MakeUnique<WalletImpl>(context, wallet) : nullptr ; }
561563
562564std::unique_ptr<WalletClient> MakeWalletClient (Chain& chain, ArgsManager& args, std::vector<std::string> wallet_filenames)
563565{
0 commit comments