Provide error codes in enumerate output
This commit is contained in:
parent
c14896c6eb
commit
129e91d9f0
@ -1,7 +1,7 @@
|
||||
# Coldcard interaction script
|
||||
|
||||
from ..hwwclient import HardwareWalletClient
|
||||
from ..errors import ActionCanceledError, BadArgumentError, DeviceBusyError, UnavailableActionError, DeviceFailureError
|
||||
from ..errors import ActionCanceledError, BadArgumentError, DeviceBusyError, DeviceFailureError, HWWError, UnavailableActionError, UNKNOWN_ERROR
|
||||
from .ckcc.client import ColdcardDevice, COINKITE_VID, CKCC_PID
|
||||
from .ckcc.protocol import CCProtocolPacker, CCBusyError, CCProtoError, CCUserRefused
|
||||
from .ckcc.constants import MAX_BLK_LEN, AF_P2WPKH, AF_CLASSIC, AF_P2WPKH_P2SH
|
||||
@ -230,8 +230,12 @@ def enumerate(password=''):
|
||||
try:
|
||||
client = ColdcardClient(path)
|
||||
d_data['fingerprint'] = client._get_fingerprint_hex()
|
||||
except HWWError as e:
|
||||
d_data['error'] = "Could not open client or get fingerprint information: " + e.get_msg()
|
||||
d_data['code'] = e.get_code()
|
||||
except Exception as e:
|
||||
d_data['error'] = "Could not open client or get fingerprint information: " + str(e)
|
||||
d_data['code'] = UNKNOWN_ERROR
|
||||
|
||||
if client:
|
||||
client.close()
|
||||
|
||||
@ -15,7 +15,7 @@ import sys
|
||||
import time
|
||||
|
||||
from ..hwwclient import HardwareWalletClient
|
||||
from ..errors import ActionCanceledError, BadArgumentError, DeviceFailureError, DeviceAlreadyInitError, DeviceNotReadyError, NoPasswordError, UnavailableActionError, DeviceFailureError
|
||||
from ..errors import ActionCanceledError, BadArgumentError, DeviceFailureError, DeviceAlreadyInitError, DeviceNotReadyError, HWWError, NoPasswordError, UnavailableActionError, UNKNOWN_ERROR
|
||||
from ..serializations import CTransaction, PSBT, hash256, hash160, ser_sig_der, ser_sig_compact, ser_compact_size
|
||||
from ..base58 import get_xpub_fingerprint, decode, to_address, xpub_main_2_test, get_xpub_fingerprint_hex
|
||||
|
||||
@ -603,8 +603,12 @@ def enumerate(password=''):
|
||||
else:
|
||||
master_xpub = client.get_pubkey_at_path('m/0h')['xpub']
|
||||
d_data['fingerprint'] = get_xpub_fingerprint_hex(master_xpub)
|
||||
except HWWError as e:
|
||||
d_data['error'] = "Could not open client or get fingerprint information: " + e.get_msg()
|
||||
d_data['code'] = e.get_code()
|
||||
except Exception as e:
|
||||
d_data['error'] = "Could not open client or get fingerprint information: " + str(e)
|
||||
d_data['code'] = UNKNOWN_ERROR
|
||||
|
||||
if client:
|
||||
client.close()
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
# KeepKey interaction script
|
||||
|
||||
from ..errors import HWWError, UNKNOWN_ERROR
|
||||
from .trezorlib.transport import enumerate_devices
|
||||
from .trezor import TrezorClient
|
||||
from ..base58 import get_xpub_fingerprint_hex
|
||||
@ -30,8 +31,12 @@ def enumerate(password=''):
|
||||
d_data['fingerprint'] = get_xpub_fingerprint_hex(master_xpub)
|
||||
else:
|
||||
d_data['error'] = 'Not initialized'
|
||||
except HWWError as e:
|
||||
d_data['error'] = "Could not open client or get fingerprint information: " + e.get_msg()
|
||||
d_data['code'] = e.get_code()
|
||||
except Exception as e:
|
||||
d_data['error'] = "Could not open client or get fingerprint information: " + str(e)
|
||||
d_data['code'] = UNKNOWN_ERROR
|
||||
|
||||
if client:
|
||||
client.close()
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
# Ledger interaction script
|
||||
|
||||
from ..hwwclient import HardwareWalletClient
|
||||
from ..errors import ActionCanceledError, BadArgumentError, DeviceConnectionError, DeviceFailureError, UnavailableActionError
|
||||
from ..errors import ActionCanceledError, BadArgumentError, DeviceConnectionError, DeviceFailureError, HWWError, UnavailableActionError, UNKNOWN_ERROR
|
||||
from .btchip.btchip import *
|
||||
from .btchip.btchipUtils import *
|
||||
import base64
|
||||
@ -350,8 +350,12 @@ def enumerate(password=''):
|
||||
client = LedgerClient(path, password)
|
||||
master_xpub = client.get_pubkey_at_path('m/0h')['xpub']
|
||||
d_data['fingerprint'] = get_xpub_fingerprint_hex(master_xpub)
|
||||
except HWWError as e:
|
||||
d_data['error'] = "Could not open client or get fingerprint information: " + e.get_msg()
|
||||
d_data['code'] = e.get_code()
|
||||
except Exception as e:
|
||||
d_data['error'] = "Could not open client or get fingerprint information: " + str(e)
|
||||
d_data['code'] = UNKNOWN_ERROR
|
||||
|
||||
if client:
|
||||
client.close()
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
# Trezor interaction script
|
||||
|
||||
from ..hwwclient import HardwareWalletClient
|
||||
from ..errors import ActionCanceledError, BadArgumentError, DeviceAlreadyInitError, DeviceAlreadyUnlockedError, DeviceConnectionError, UnavailableActionError, DeviceNotReadyError
|
||||
from ..errors import ActionCanceledError, BadArgumentError, DeviceAlreadyInitError, DeviceAlreadyUnlockedError, DeviceConnectionError, DeviceNotReadyError, HWWError, UnavailableActionError, UNKNOWN_ERROR
|
||||
from .trezorlib.client import TrezorClient as Trezor
|
||||
from .trezorlib.debuglink import TrezorClientDebugLink, DebugUI
|
||||
from .trezorlib.exceptions import Cancelled
|
||||
@ -426,8 +426,12 @@ def enumerate(password=''):
|
||||
d_data['fingerprint'] = get_xpub_fingerprint_hex(master_xpub)
|
||||
else:
|
||||
d_data['error'] = 'Not initialized'
|
||||
except HWWError as e:
|
||||
d_data['error'] = "Could not open client or get fingerprint information: " + e.get_msg()
|
||||
d_data['code'] = e.get_code()
|
||||
except Exception as e:
|
||||
d_data['error'] = "Could not open client or get fingerprint information: " + str(e)
|
||||
d_data['code'] = UNKNOWN_ERROR
|
||||
|
||||
if client:
|
||||
client.close()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user