@@ -127,7 +127,7 @@ WalletTxOut MakeWalletTxOut(const CWallet& wallet,
127
127
class WalletImpl : public Wallet
128
128
{
129
129
public:
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) {}
131
131
132
132
void markDirty () override
133
133
{
@@ -501,7 +501,7 @@ class WalletImpl : public Wallet
501
501
CAmount getDefaultMaxTxFee () override { return m_wallet->m_default_max_tx_fee ; }
502
502
void remove () override
503
503
{
504
- RemoveWallet (m_wallet, false /* load_on_start */ );
504
+ RemoveWallet (m_context, m_wallet, false /* load_on_start */ );
505
505
}
506
506
bool isLegacy () override { return m_wallet->IsLegacy (); }
507
507
std::unique_ptr<Handler> handleUnload (UnloadFn fn) override
@@ -547,6 +547,7 @@ class WalletImpl : public Wallet
547
547
}
548
548
CWallet* wallet () override { return m_wallet.get (); }
549
549
550
+ WalletContext& m_context;
550
551
std::shared_ptr<CWallet> m_wallet;
551
552
std::unique_ptr<interfaces::CoinJoin::Client> m_coinjoin_client;
552
553
};
@@ -575,7 +576,7 @@ class WalletLoaderImpl : public WalletLoader
575
576
m_context.node_context = &node_context;
576
577
m_context.coinjoin_loader = &coinjoin_loader;
577
578
}
578
- ~WalletLoaderImpl () override { UnloadWallets (); }
579
+ ~WalletLoaderImpl () override { UnloadWallets (m_context ); }
579
580
580
581
// ! ChainClient methods
581
582
void registerRpcs () override
@@ -585,8 +586,8 @@ class WalletLoaderImpl : public WalletLoader
585
586
bool verify () override { return VerifyWallets (m_context); }
586
587
bool load () override { return LoadWallets (m_context); }
587
588
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 ); }
590
591
void setMockTime (int64_t time) override { return SetMockTime (time ); }
591
592
592
593
// ! WalletLoader methods
@@ -602,19 +603,19 @@ class WalletLoaderImpl : public WalletLoader
602
603
options.require_create = true ;
603
604
options.create_flags = wallet_creation_flags;
604
605
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));
606
607
}
607
608
std::unique_ptr<Wallet> loadWallet (const std::string& name, bilingual_str& error, std::vector<bilingual_str>& warnings) override
608
609
{
609
610
DatabaseOptions options;
610
611
DatabaseStatus status;
611
612
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));
613
614
}
614
615
std::unique_ptr<Wallet> restoreWallet (const fs::path& backup_file, const std::string& wallet_name, bilingual_str& error, std::vector<bilingual_str>& warnings) override
615
616
{
616
617
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));
618
619
}
619
620
std::string getWalletDir () override
620
621
{
@@ -631,14 +632,14 @@ class WalletLoaderImpl : public WalletLoader
631
632
std::vector<std::unique_ptr<Wallet>> getWallets () override
632
633
{
633
634
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));
636
637
}
637
638
return wallets;
638
639
}
639
640
std::unique_ptr<Handler> handleLoadWallet (LoadWalletFn fn) override
640
641
{
641
- return HandleLoadWallet (std::move (fn));
642
+ return HandleLoadWallet (m_context, std::move (fn));
642
643
}
643
644
WalletContext* context () override { return &m_context; }
644
645
@@ -651,7 +652,7 @@ class WalletLoaderImpl : public WalletLoader
651
652
} // namespace wallet
652
653
653
654
namespace 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 ; }
655
656
std::unique_ptr<WalletLoader> MakeWalletLoader (Chain& chain, ArgsManager& args, NodeContext& node_context,
656
657
interfaces::CoinJoin::Loader& coinjoin_loader)
657
658
{
0 commit comments