From 214e04d4bb9b00de97aacfa28a31af3c43429068 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Thu, 10 Oct 2024 21:25:34 +0000 Subject: [PATCH] hw plugins: cmdline: fix offline commands for encrypted hw wallets ``` $ ./run_electrum --testnet signmessage -w /home/user/.electrum/testnet/wallets/test_trezor_white_bip84 tb1q5pguna9y2g9y2gsu8r8gmxeye2cefvyly8dg02 heyheyhey -o 0.84 | W | plugins.jade.jadepy.jade | No module named 'electrum.plugins.jade.jadepy.jade_ble' 0.84 | W | plugins.jade.jadepy.jade | BLE scanning/connectivity will not be available 3.73 | E | __main__ | error running command (without daemon) Traceback (most recent call last): File "/home/user/wspace/electrum/electrum/plugins/trezor/clientbase.py", line 151, in get_xpub node = trezorlib.btc.get_public_node(self.client, address_n).node File "/home/user/.local/lib/python3.10/site-packages/trezorlib/tools.py", line 274, in wrapped_f ret = f(*args, **kwargs) File "/home/user/.local/lib/python3.10/site-packages/trezorlib/btc.py", line 125, in get_public_node return client.call( File "/home/user/.local/lib/python3.10/site-packages/trezorlib/tools.py", line 297, in wrapped_f return f(client, *args, **kwargs) File "/home/user/.local/lib/python3.10/site-packages/trezorlib/client.py", line 260, in call resp = self._callback_pin(resp) File "/home/user/.local/lib/python3.10/site-packages/trezorlib/client.py", line 186, in _callback_pin pin = self.ui.get_pin(msg.type) File "/home/user/wspace/electrum/electrum/plugins/trezor/clientbase.py", line 308, in get_pin pin = self.handler.get_pin(msg.format(self.device), show_strength=show_strength) AttributeError: 'NoneType' object has no attribute 'get_pin' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/user/wspace/electrum/./run_electrum", line 540, in handle_cmd result = fut.result() File "/usr/lib/python3.10/concurrent/futures/_base.py", line 458, in result return self.__get_result() File "/usr/lib/python3.10/concurrent/futures/_base.py", line 403, in __get_result raise self._exception File "/home/user/wspace/electrum/./run_electrum", line 227, in run_offline_command password = get_password_for_hw_device_encrypted_storage(plugins) File "/home/user/wspace/electrum/./run_electrum", line 212, in get_password_for_hw_device_encrypted_storage return client.get_password_for_storage_encryption() File "/home/user/wspace/electrum/electrum/plugin.py", line 523, in wrapper return run_in_hwd_thread(partial(func, *args, **kwargs)) File "/home/user/wspace/electrum/electrum/plugin.py", line 516, in run_in_hwd_thread return fut.result() File "/usr/lib/python3.10/concurrent/futures/_base.py", line 458, in result return self.__get_result() File "/usr/lib/python3.10/concurrent/futures/_base.py", line 403, in __get_result raise self._exception File "/usr/lib/python3.10/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) File "/home/user/wspace/electrum/electrum/plugins/hw_wallet/plugin.py", line 260, in get_password_for_storage_encryption xpub = self.get_xpub(derivation, "standard") File "/home/user/wspace/electrum/electrum/plugin.py", line 523, in wrapper return run_in_hwd_thread(partial(func, *args, **kwargs)) File "/home/user/wspace/electrum/electrum/plugin.py", line 513, in run_in_hwd_thread return func() File "/home/user/wspace/electrum/electrum/plugins/trezor/clientbase.py", line 150, in get_xpub with self.run_flow(creating_wallet=creating): File "/home/user/wspace/electrum/electrum/plugins/trezor/clientbase.py", line 89, in __exit__ self.end_flow() File "/home/user/wspace/electrum/electrum/plugins/trezor/clientbase.py", line 82, in end_flow self.handler.finished() AttributeError: 'NoneType' object has no attribute 'finished' ``` --- run_electrum | 1 + 1 file changed, 1 insertion(+) diff --git a/run_electrum b/run_electrum index 78d2a6187..179148b85 100755 --- a/run_electrum +++ b/run_electrum @@ -209,6 +209,7 @@ def get_password_for_hw_device_encrypted_storage(plugins: 'Plugins') -> str: devmgr = plugins.device_manager try: client = devmgr.client_by_id(device_info.device.id_) + client.handler = client.plugin.create_handler(None) return client.get_password_for_storage_encryption() except UserCancelled: sys.exit(0)