Add needs_passphrase_sent to enumerate output
This commit is contained in:
parent
a4a3aff89b
commit
d2696cfadf
@ -225,6 +225,7 @@ def enumerate(password=''):
|
|||||||
path = d['path'].decode()
|
path = d['path'].decode()
|
||||||
d_data['type'] = 'coldcard'
|
d_data['type'] = 'coldcard'
|
||||||
d_data['path'] = path
|
d_data['path'] = path
|
||||||
|
d_data['needs_passphrase'] = False
|
||||||
|
|
||||||
client = None
|
client = None
|
||||||
try:
|
try:
|
||||||
@ -251,6 +252,7 @@ def enumerate(password=''):
|
|||||||
d_data['fingerprint'] = client._get_fingerprint_hex()
|
d_data['fingerprint'] = client._get_fingerprint_hex()
|
||||||
d_data['type'] = 'coldcard'
|
d_data['type'] = 'coldcard'
|
||||||
d_data['path'] = CC_SIMULATOR_SOCK
|
d_data['path'] = CC_SIMULATOR_SOCK
|
||||||
|
d_data['needs_passphrase_sent'] = False
|
||||||
results.append(d_data)
|
results.append(d_data)
|
||||||
except RuntimeError as e:
|
except RuntimeError as e:
|
||||||
if str(e) == 'Cannot connect to simulator. Is it running?':
|
if str(e) == 'Cannot connect to simulator. Is it running?':
|
||||||
|
|||||||
@ -603,6 +603,7 @@ def enumerate(password=''):
|
|||||||
else:
|
else:
|
||||||
master_xpub = client.get_pubkey_at_path('m/0h')['xpub']
|
master_xpub = client.get_pubkey_at_path('m/0h')['xpub']
|
||||||
d_data['fingerprint'] = get_xpub_fingerprint_hex(master_xpub)
|
d_data['fingerprint'] = get_xpub_fingerprint_hex(master_xpub)
|
||||||
|
d_data['needs_passphrase_sent'] = True
|
||||||
except HWWError as e:
|
except HWWError as e:
|
||||||
d_data['error'] = "Could not open client or get fingerprint information: " + e.get_msg()
|
d_data['error'] = "Could not open client or get fingerprint information: " + e.get_msg()
|
||||||
d_data['code'] = e.get_code()
|
d_data['code'] = e.get_code()
|
||||||
|
|||||||
@ -26,9 +26,13 @@ def enumerate(password=''):
|
|||||||
client.client.init_device()
|
client.client.init_device()
|
||||||
if not 'keepkey' in client.client.features.vendor:
|
if not 'keepkey' in client.client.features.vendor:
|
||||||
continue
|
continue
|
||||||
|
d_data['needs_passphrase_sent'] = client.client.features.passphrase_protection and not client.client.features.passphrase_cached
|
||||||
|
if d_data['needs_passphrase_sent'] and not password:
|
||||||
|
raise DeviceNotReadyError("Passphrase needs to be specified before the fingerprint information can be retrieved")
|
||||||
if client.client.features.initialized:
|
if client.client.features.initialized:
|
||||||
master_xpub = client.get_pubkey_at_path('m/0h')['xpub']
|
master_xpub = client.get_pubkey_at_path('m/0h')['xpub']
|
||||||
d_data['fingerprint'] = get_xpub_fingerprint_hex(master_xpub)
|
d_data['fingerprint'] = get_xpub_fingerprint_hex(master_xpub)
|
||||||
|
d_data['needs_passphrase_sent'] = False # Passphrase is always needed for the above to have worked, so it's already sent
|
||||||
else:
|
else:
|
||||||
d_data['error'] = 'Not initialized'
|
d_data['error'] = 'Not initialized'
|
||||||
except HWWError as e:
|
except HWWError as e:
|
||||||
|
|||||||
@ -350,9 +350,7 @@ def enumerate(password=''):
|
|||||||
client = LedgerClient(path, password)
|
client = LedgerClient(path, password)
|
||||||
master_xpub = client.get_pubkey_at_path('m/0h')['xpub']
|
master_xpub = client.get_pubkey_at_path('m/0h')['xpub']
|
||||||
d_data['fingerprint'] = get_xpub_fingerprint_hex(master_xpub)
|
d_data['fingerprint'] = get_xpub_fingerprint_hex(master_xpub)
|
||||||
except HWWError as e:
|
d_data['needs_passphrase_sent'] = False
|
||||||
d_data['error'] = "Could not open client or get fingerprint information: " + e.get_msg()
|
|
||||||
d_data['code'] = e.get_code()
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
d_data['error'] = "Could not open client or get fingerprint information: " + str(e)
|
d_data['error'] = "Could not open client or get fingerprint information: " + str(e)
|
||||||
d_data['code'] = UNKNOWN_ERROR
|
d_data['code'] = UNKNOWN_ERROR
|
||||||
|
|||||||
@ -421,9 +421,13 @@ def enumerate(password=''):
|
|||||||
client.client.init_device()
|
client.client.init_device()
|
||||||
if not 'trezor' in client.client.features.vendor:
|
if not 'trezor' in client.client.features.vendor:
|
||||||
continue
|
continue
|
||||||
|
d_data['needs_passphrase_sent'] = client.client.features.passphrase_protection and not client.client.features.passphrase_cached
|
||||||
|
if d_data['needs_passphrase_sent'] and not password:
|
||||||
|
raise DeviceNotReadyError("Passphrase needs to be specified before the fingerprint information can be retrieved")
|
||||||
if client.client.features.initialized:
|
if client.client.features.initialized:
|
||||||
master_xpub = client.get_pubkey_at_path('m/0h')['xpub']
|
master_xpub = client.get_pubkey_at_path('m/0h')['xpub']
|
||||||
d_data['fingerprint'] = get_xpub_fingerprint_hex(master_xpub)
|
d_data['fingerprint'] = get_xpub_fingerprint_hex(master_xpub)
|
||||||
|
d_data['needs_passphrase_sent'] = False # Passphrase is always needed for the above to have worked, so it's already sent
|
||||||
else:
|
else:
|
||||||
d_data['error'] = 'Not initialized'
|
d_data['error'] = 'Not initialized'
|
||||||
except HWWError as e:
|
except HWWError as e:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user