@@ -188,7 +188,16 @@ void WalletInit::Construct(InitInterfaces& interfaces) const
188188 if (default_wallet.Exists ()) {
189189 gArgs .SoftSetArg (" -wallet" , " " );
190190 }
191- interfaces.chain_clients .emplace_back (interfaces::MakeWalletClient (*interfaces.chain , gArgs .GetArgs (" -wallet" )));
191+ std::vector<std::string> wallets = gArgs .GetArgs (" -wallet" );
192+ std::stringstream ss (gArgs .GetArg (" -loadedwallet" , " " ));
193+ std::string loaded_wallet;
194+ while (std::getline (ss, loaded_wallet, ' ,' )) {
195+ if (std::find (wallets.begin (), wallets.end (), loaded_wallet) == wallets.end ()) {
196+ wallets.push_back (loaded_wallet);
197+ }
198+ }
199+
200+ interfaces.chain_clients .emplace_back (interfaces::MakeWalletClient (*interfaces.chain , wallets));
192201}
193202
194203bool LoadWallets (interfaces::Chain& chain, const std::vector<std::string>& wallet_files)
@@ -231,10 +240,19 @@ void StopWallets()
231240void UnloadWallets ()
232241{
233242 auto wallets = GetWallets ();
243+ std::string loaded_wallets = " " ;
234244 while (!wallets.empty ()) {
235245 auto wallet = wallets.back ();
246+
247+ // Write the wallet name to rw conf
248+ if (!loaded_wallets.empty ()) {
249+ loaded_wallets += " ," ;
250+ }
251+ loaded_wallets += wallet->GetName ();
252+
236253 wallets.pop_back ();
237254 RemoveWallet (wallet);
238255 UnloadWallet (std::move (wallet));
239256 }
257+ gArgs .ModifyRWConfigFile (" loadedwallet" , loaded_wallets);
240258}
0 commit comments