follow-up on SingleConfig
This commit is contained in:
@@ -363,11 +363,10 @@ class Daemon(Logger):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
async def gui(self, config_options):
|
async def gui(self, config_options):
|
||||||
config = SimpleConfig(config_options)
|
|
||||||
if self.gui_object:
|
if self.gui_object:
|
||||||
if hasattr(self.gui_object, 'new_window'):
|
if hasattr(self.gui_object, 'new_window'):
|
||||||
path = config.get_wallet_path(use_gui_last_wallet=True)
|
path = self.config.get_wallet_path(use_gui_last_wallet=True)
|
||||||
self.gui_object.new_window(path, config.get('url'))
|
self.gui_object.new_window(path, config_options.get('url'))
|
||||||
response = "ok"
|
response = "ok"
|
||||||
else:
|
else:
|
||||||
response = "error: current GUI does not support multiple windows"
|
response = "error: current GUI does not support multiple windows"
|
||||||
|
|||||||
15
run_electrum
15
run_electrum
@@ -106,8 +106,7 @@ def prompt_password(prompt, confirm=True):
|
|||||||
return password
|
return password
|
||||||
|
|
||||||
|
|
||||||
def init_cmdline(config_options, server):
|
def init_cmdline(config_options, wallet_path, server):
|
||||||
config = SimpleConfig(config_options)
|
|
||||||
cmdname = config.get('cmd')
|
cmdname = config.get('cmd')
|
||||||
cmd = known_commands[cmdname]
|
cmd = known_commands[cmdname]
|
||||||
|
|
||||||
@@ -122,7 +121,7 @@ def init_cmdline(config_options, server):
|
|||||||
cmd.requires_network = True
|
cmd.requires_network = True
|
||||||
|
|
||||||
# instantiate wallet for command-line
|
# instantiate wallet for command-line
|
||||||
storage = WalletStorage(config.get_wallet_path())
|
storage = WalletStorage(wallet_path)
|
||||||
|
|
||||||
if cmd.requires_wallet and not storage.file_exists():
|
if cmd.requires_wallet and not storage.file_exists():
|
||||||
print_msg("Error: Wallet file not found.")
|
print_msg("Error: Wallet file not found.")
|
||||||
@@ -324,9 +323,8 @@ if __name__ == '__main__':
|
|||||||
if not uri.startswith('bitcoin:'):
|
if not uri.startswith('bitcoin:'):
|
||||||
print_stderr('unknown command:', uri)
|
print_stderr('unknown command:', uri)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
config_options['url'] = uri
|
|
||||||
|
|
||||||
# todo: defer this to gui
|
# singleton
|
||||||
config = SimpleConfig(config_options)
|
config = SimpleConfig(config_options)
|
||||||
|
|
||||||
if config.get('testnet'):
|
if config.get('testnet'):
|
||||||
@@ -392,9 +390,10 @@ if __name__ == '__main__':
|
|||||||
else:
|
else:
|
||||||
# command line
|
# command line
|
||||||
cmd = known_commands[cmdname]
|
cmd = known_commands[cmdname]
|
||||||
|
wallet_path = config.get_wallet_path()
|
||||||
if not config.get('offline'):
|
if not config.get('offline'):
|
||||||
init_cmdline(config_options, True)
|
init_cmdline(config_options, wallet_path, True)
|
||||||
timeout = config_options.get('timeout', 60)
|
timeout = config.get('timeout', 60)
|
||||||
if timeout: timeout = int(timeout)
|
if timeout: timeout = int(timeout)
|
||||||
try:
|
try:
|
||||||
result = daemon.request(config, 'run_cmdline', (config_options,), timeout)
|
result = daemon.request(config, 'run_cmdline', (config_options,), timeout)
|
||||||
@@ -410,7 +409,7 @@ if __name__ == '__main__':
|
|||||||
if cmd.requires_network:
|
if cmd.requires_network:
|
||||||
print_msg("This command cannot be run offline")
|
print_msg("This command cannot be run offline")
|
||||||
sys_exit(1)
|
sys_exit(1)
|
||||||
init_cmdline(config_options, False)
|
init_cmdline(config_options, wallet_path, False)
|
||||||
plugins = init_plugins(config, 'cmdline')
|
plugins = init_plugins(config, 'cmdline')
|
||||||
coro = run_offline_command(config, config_options, plugins)
|
coro = run_offline_command(config, config_options, plugins)
|
||||||
fut = asyncio.run_coroutine_threadsafe(coro, loop)
|
fut = asyncio.run_coroutine_threadsafe(coro, loop)
|
||||||
|
|||||||
Reference in New Issue
Block a user