1
0

Replace config GUI_LAST_WALLET with CURRENT_WALLET

- CURRENT_WALLET is set when a single wallet is loaded in memory, and it
   remains set after Electrum stops running.
 - If several wallets are loaded at the same time, CURRENT_WALLET is unset,
   and RPCs must specify the wallet explicitly (using --wallet for the CLI)
 - The fallback to 'default_wallet' essentially only applies when
   creating a new wallet file
This commit is contained in:
ThomasV
2025-05-31 11:45:57 +02:00
parent 0ce89b6d54
commit 9e225d1269
9 changed files with 40 additions and 42 deletions

View File

@@ -342,7 +342,7 @@ class CommandsServer(AuthenticatedServer):
if config_options.get(SimpleConfig.NETWORK_OFFLINE.key()) and not self.config.NETWORK_OFFLINE:
raise UserFacingException(
"error: current GUI is running online, so it cannot open a new wallet offline.")
path = config_options.get('wallet_path') or self.config.get_wallet_path(use_gui_last_wallet=True)
path = config_options.get('wallet_path') or self.config.get_wallet_path()
self.daemon.gui_object.new_window(path, config_options.get('url'))
return True
else:
@@ -477,9 +477,15 @@ class Daemon(Logger):
coro = wallet.lnworker.lnwatcher.trigger_callbacks(requires_synchronizer=False)
asyncio.run_coroutine_threadsafe(coro, self.asyncio_loop)
self.add_wallet(wallet)
self.update_current_wallet()
self.update_recently_opened_wallets(path)
return wallet
def update_current_wallet(self):
if not self._wallets:
return
self.config.CURRENT_WALLET = list(self._wallets.keys())[0] if len(self._wallets) == 1 else None
@staticmethod
@profiler
def _load_wallet(
@@ -540,6 +546,7 @@ class Daemon(Logger):
wallet = self._wallets.pop(wallet_key, None)
if not wallet:
return False
self.update_current_wallet()
await wallet.stop()
return True