From 18f6b889825ec15422686e61af57f2dd15c62a5b Mon Sep 17 00:00:00 2001 From: Sander van Grieken Date: Tue, 26 Aug 2025 12:02:33 +0200 Subject: [PATCH] don't sys.exit() from run_offline_command, this leads to wait on lock that never releases. --- run_electrum | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/run_electrum b/run_electrum index 8e525ab06..08038ce7d 100755 --- a/run_electrum +++ b/run_electrum @@ -211,8 +211,7 @@ def get_connected_hw_devices(plugins: 'Plugins'): def get_password_for_hw_device_encrypted_storage(plugins: 'Plugins') -> str: devices = get_connected_hw_devices(plugins) if len(devices) == 0: - print_msg("Error: No connected hw device found. Cannot decrypt this wallet.") - sys.exit(1) + raise UserFacingException("Error: No connected hw device found. Cannot decrypt this wallet.") elif len(devices) > 1: print_msg("Warning: multiple hardware devices detected. " "The first one will be used to decrypt the wallet.") @@ -224,7 +223,7 @@ def get_password_for_hw_device_encrypted_storage(plugins: 'Plugins') -> str: client.handler = client.plugin.create_handler(None) return client.get_password_for_storage_encryption() except UserCancelled: - sys.exit(0) + raise async def run_offline_command(config: 'SimpleConfig', config_options: dict, wallet_path: str, plugins: 'Plugins'): @@ -251,7 +250,7 @@ async def run_offline_command(config: 'SimpleConfig', config_options: dict, wall wallet.check_password(password) except InvalidPassword: print_msg("Error: This password does not decode this wallet.") - sys.exit(1) + raise if cmd.requires_network: print_msg("Warning: running command offline") # arguments passed to function @@ -592,6 +591,12 @@ def handle_cmd(*, cmdname: str, config: 'SimpleConfig', config_options: dict): except UserFacingException as e: print_stderr(str(e)) sys_exit(1) + except InvalidPassword: + print_stderr("Invalid password") + sys_exit(1) + except UserCancelled: + print_stderr("Aborted by user") + sys_exit(1) except Exception as e: _logger.exception("error running command (without daemon)") sys_exit(1)