Skip to content

Commit a43be66

Browse files
committed
follow-up on SingleConfig
1 parent 1a08063 commit a43be66

2 files changed

Lines changed: 9 additions & 11 deletions

File tree

electrum/daemon.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,11 +363,10 @@ async def ping(self):
363363
return True
364364

365365
async def gui(self, config_options):
366-
config = SimpleConfig(config_options)
367366
if self.gui_object:
368367
if hasattr(self.gui_object, 'new_window'):
369-
path = config.get_wallet_path(use_gui_last_wallet=True)
370-
self.gui_object.new_window(path, config.get('url'))
368+
path = self.config.get_wallet_path(use_gui_last_wallet=True)
369+
self.gui_object.new_window(path, config_options.get('url'))
371370
response = "ok"
372371
else:
373372
response = "error: current GUI does not support multiple windows"

run_electrum

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,7 @@ def prompt_password(prompt, confirm=True):
106106
return password
107107

108108

109-
def init_cmdline(config_options, server):
110-
config = SimpleConfig(config_options)
109+
def init_cmdline(config_options, wallet_path, server):
111110
cmdname = config.get('cmd')
112111
cmd = known_commands[cmdname]
113112

@@ -122,7 +121,7 @@ def init_cmdline(config_options, server):
122121
cmd.requires_network = True
123122

124123
# instantiate wallet for command-line
125-
storage = WalletStorage(config.get_wallet_path())
124+
storage = WalletStorage(wallet_path)
126125

127126
if cmd.requires_wallet and not storage.file_exists():
128127
print_msg("Error: Wallet file not found.")
@@ -324,9 +323,8 @@ if __name__ == '__main__':
324323
if not uri.startswith('bitcoin:'):
325324
print_stderr('unknown command:', uri)
326325
sys.exit(1)
327-
config_options['url'] = uri
328326

329-
# todo: defer this to gui
327+
# singleton
330328
config = SimpleConfig(config_options)
331329

332330
if config.get('testnet'):
@@ -392,9 +390,10 @@ if __name__ == '__main__':
392390
else:
393391
# command line
394392
cmd = known_commands[cmdname]
393+
wallet_path = config.get_wallet_path()
395394
if not config.get('offline'):
396-
init_cmdline(config_options, True)
397-
timeout = config_options.get('timeout', 60)
395+
init_cmdline(config_options, wallet_path, True)
396+
timeout = config.get('timeout', 60)
398397
if timeout: timeout = int(timeout)
399398
try:
400399
result = daemon.request(config, 'run_cmdline', (config_options,), timeout)
@@ -410,7 +409,7 @@ if __name__ == '__main__':
410409
if cmd.requires_network:
411410
print_msg("This command cannot be run offline")
412411
sys_exit(1)
413-
init_cmdline(config_options, False)
412+
init_cmdline(config_options, wallet_path, False)
414413
plugins = init_plugins(config, 'cmdline')
415414
coro = run_offline_command(config, config_options, plugins)
416415
fut = asyncio.run_coroutine_threadsafe(coro, loop)

0 commit comments

Comments
 (0)