diff --git a/src/cryptoadvance/specter/devices/hwi/jade.py b/src/cryptoadvance/specter/devices/hwi/jade.py index 3fc5ffba4..b9404100e 100644 --- a/src/cryptoadvance/specter/devices/hwi/jade.py +++ b/src/cryptoadvance/specter/devices/hwi/jade.py @@ -141,7 +141,7 @@ def __init__( password: Optional[str] = None, expert: bool = False, chain: Chain = Chain.MAIN, - unlock: bool = True, + skip_unlocking: bool = False, timeout: Optional[int] = None, ) -> None: super(JadeClient, self).__init__(path, password, expert, chain) @@ -166,15 +166,15 @@ def __init__( ) else: if uninitialized: + if skip_unlocking: + # We don't want to prompt to unlock the device right now + return if not HAS_NETWORKING: # Wallet not initialised/unlocked nor do we have networking dependencies # User must use 'Recovery Phrase Login' or 'QR Unlock' feature to access wallet raise DeviceNotReadyError( 'Use "Recovery Phrase Login" or "QR PIN Unlock" feature on Jade hw to access wallet' ) - if not unlock: - # We don't want to prompt to unlock the device right now - return # Push some host entropy into jade self.jade.add_entropy(os.urandom(32)) @@ -717,7 +717,7 @@ def enumerate( password: Optional[str] = None, expert: bool = False, chain: Chain = Chain.MAIN, - unlock=True, + skip_unlocking=True, ) -> List[Dict[str, Any]]: results = [] @@ -731,9 +731,12 @@ def _get_device_entry(device_model: str, device_path: str) -> Dict[str, Any]: client = None with handle_errors(common_err_msgs["enumerate"], d_data): - client = JadeClient(device_path, password, expert, chain, unlock, timeout=1) - # We don't get the fingerprint from a locked Jade - if client and unlock: + client = JadeClient( + device_path, password, expert, chain, skip_unlocking, timeout=1 + ) + # The Jade could already be unlocked upon startup (this is the only instance where unlock_required is False right now). + # But, we don't need the fingerpint then. + if client and not skip_unlocking: d_data["fingerprint"] = client.get_master_fingerprint().hex() if client: client.close() diff --git a/src/cryptoadvance/specter/hwi_rpc.py b/src/cryptoadvance/specter/hwi_rpc.py index 7c038e6f7..0a68bb492 100644 --- a/src/cryptoadvance/specter/hwi_rpc.py +++ b/src/cryptoadvance/specter/hwi_rpc.py @@ -106,9 +106,11 @@ def enumerate(self, passphrase="", chain=""): try: # Special handling of the Jade to unsure it is not prompting to unlock the device on startup if devcls.__name__ == "Jade": - unlock = not self.is_startup + skip_unlocking = self.is_startup client_chain = Chain.argparse(chain) # This returns an enum member - devs = devcls.enumerate(unlock=unlock, chain=client_chain) + devs = devcls.enumerate( + skip_unlocking=skip_unlocking, chain=client_chain + ) else: if passphrase: devs = devcls.enumerate(passphrase) @@ -449,7 +451,6 @@ def _get_client( password=passphrase, expert=False, chain=client_chain, - unlock=True, ) else: client = devcls.get_client(device["path"], passphrase)