Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Jade signing issues with Swan Vault #2421

29 changes: 19 additions & 10 deletions src/cryptoadvance/specter/devices/hwi/jade.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ def __init__(
password: Optional[str] = None,
expert: bool = False,
chain: Chain = Chain.MAIN,
unlock: bool = True,
timeout: Optional[int] = None,
) -> None:
super(JadeClient, self).__init__(path, password, expert, chain)
Expand All @@ -163,12 +164,16 @@ def __init__(
"Use JadeAPI.set_[seed|mnemonic] to set simulator wallet"
)
else:
if uninitialized and 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 uninitialized:
moneymanolis marked this conversation as resolved.
Show resolved Hide resolved
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))
Expand Down Expand Up @@ -657,7 +662,10 @@ def can_sign_taproot(self) -> bool:


def enumerate(
password: Optional[str] = None, expert: bool = False, chain: Chain = Chain.MAIN
password: Optional[str] = None,
expert: bool = False,
chain: Chain = Chain.MAIN,
unlock=True,
moneymanolis marked this conversation as resolved.
Show resolved Hide resolved
) -> List[Dict[str, Any]]:
results = []

Expand All @@ -671,9 +679,10 @@ 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, timeout=1)
d_data["fingerprint"] = client.get_master_fingerprint().hex()

client = JadeClient(device_path, password, expert, chain, unlock, timeout=1)
# We don't get the fingerprint from a locked Jade
if client and unlock:
moneymanolis marked this conversation as resolved.
Show resolved Hide resolved
d_data["fingerprint"] = client.get_master_fingerprint().hex()
if client:
client.close()

moneymanolis marked this conversation as resolved.
Show resolved Hide resolved
Expand Down