Skip to content

Commit f7e6126

Browse files
committed
Pass '--expert' and '--chain' cmd-line arguments to enumerate() functions
These arguments are currently discarded/ignored for the enumerate command. Pass them through to the per-hw enumerate() calls. In the Jade client, use the 'chain' parameter to enable testnet-configured Jade units to enumerate successfully. Also update error message to reflect latest wording on Jade hw.
1 parent 36ccaf7 commit f7e6126

9 files changed

+13
-13
lines changed

hwilib/_cli.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def displayaddress_handler(args: argparse.Namespace, client: HardwareWalletClien
6060
return displayaddress(client, desc=args.desc, path=args.path, addr_type=args.addr_type)
6161

6262
def enumerate_handler(args: argparse.Namespace) -> List[Dict[str, Any]]:
63-
return enumerate(password=args.password)
63+
return enumerate(password=args.password, expert=args.expert, chain=args.chain)
6464

6565
def getmasterxpub_handler(args: argparse.Namespace, client: HardwareWalletClient) -> Dict[str, str]:
6666
return getmasterxpub(client, addrtype=args.addr_type, account=args.account)

hwilib/commands.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def get_client(device_type: str, device_path: str, password: Optional[str] = Non
101101
return client
102102

103103
# Get a list of all available hardware wallets
104-
def enumerate(password: Optional[str] = None) -> List[Dict[str, Any]]:
104+
def enumerate(password: Optional[str] = None, expert: bool = False, chain: Chain = Chain.MAIN) -> List[Dict[str, Any]]:
105105
"""
106106
Enumerate all of the devices that HWI can potentially access.
107107
@@ -114,7 +114,7 @@ def enumerate(password: Optional[str] = None) -> List[Dict[str, Any]]:
114114
for module in all_devs:
115115
try:
116116
imported_dev = importlib.import_module('.devices.' + module, __package__)
117-
result.extend(imported_dev.enumerate(password))
117+
result.extend(imported_dev.enumerate(password, expert, chain))
118118
except ImportError as e:
119119
# Warn for ImportErrors, but largely ignore them to allow users not install
120120
# all device dependencies if only one or some devices are wanted.

hwilib/devices/bitbox02.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def _xpubs_equal_ignoring_version(xpub1: bytes, xpub2: bytes) -> bool:
174174
return xpub1[4:] == xpub2[4:]
175175

176176

177-
def enumerate(password: Optional[str] = None) -> List[Dict[str, object]]:
177+
def enumerate(password: Optional[str] = None, expert: bool = False, chain: Chain = Chain.MAIN) -> List[Dict[str, Any]]:
178178
"""
179179
Enumerate all BitBox02 devices. Bootloaders excluded.
180180
"""

hwilib/devices/coldcard.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ def can_sign_taproot(self) -> bool:
399399
return False
400400

401401

402-
def enumerate(password: Optional[str] = None) -> List[Dict[str, Any]]:
402+
def enumerate(password: Optional[str] = None, expert: bool = False, chain: Chain = Chain.MAIN) -> List[Dict[str, Any]]:
403403
results = []
404404
devices = hid.enumerate(COINKITE_VID, CKCC_PID)
405405
devices.append({'path': CC_SIMULATOR_SOCK.encode()})

hwilib/devices/digitalbitbox.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ def can_sign_taproot(self) -> bool:
679679
return False
680680

681681

682-
def enumerate(password: Optional[str] = None) -> List[Dict[str, Any]]:
682+
def enumerate(password: Optional[str] = None, expert: bool = False, chain: Chain = Chain.MAIN) -> List[Dict[str, Any]]:
683683
results = []
684684
devices = hid.enumerate(DBB_VENDOR_ID, DBB_DEVICE_ID)
685685
# Try connecting to simulator

hwilib/devices/jade.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@ def __init__(self, path: str, password: Optional[str] = None, expert: bool = Fal
145145
else:
146146
if uninitialized and not HAS_NETWORKING:
147147
# Wallet not initialised/unlocked nor do we have networking dependencies
148-
# User must use 'Emergency Restore' feature to enter mnemonic on Jade hw
149-
raise DeviceNotReadyError('Use "Emergency Restore" feature on Jade hw to enter wallet mnemonic')
148+
# User must use 'Recovery Phrase Login' or 'QR Unlock' feature to access wallet
149+
raise DeviceNotReadyError('Use "Recovery Phrase Login" or "QR PIN Unlock" feature on Jade hw to access wallet')
150150

151151
# Push some host entropy into jade
152152
self.jade.add_entropy(os.urandom(32))
@@ -508,7 +508,7 @@ def can_sign_taproot(self) -> bool:
508508
return False
509509

510510

511-
def enumerate(password: Optional[str] = None) -> List[Dict[str, Any]]:
511+
def enumerate(password: Optional[str] = None, expert: bool = False, chain: Chain = Chain.MAIN) -> List[Dict[str, Any]]:
512512
results = []
513513

514514
def _get_device_entry(device_model: str, device_path: str) -> Dict[str, Any]:
@@ -521,7 +521,7 @@ def _get_device_entry(device_model: str, device_path: str) -> Dict[str, Any]:
521521

522522
client = None
523523
with handle_errors(common_err_msgs['enumerate'], d_data):
524-
client = JadeClient(device_path, password, timeout=1)
524+
client = JadeClient(device_path, password, expert, chain, timeout=1)
525525
d_data['fingerprint'] = client.get_master_fingerprint().hex()
526526

527527
if client:

hwilib/devices/keepkey.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def can_sign_taproot(self) -> bool:
171171
return False
172172

173173

174-
def enumerate(password: Optional[str] = None) -> List[Dict[str, Any]]:
174+
def enumerate(password: Optional[str] = None, expert: bool = False, chain: Chain = Chain.MAIN) -> List[Dict[str, Any]]:
175175
results = []
176176
devs = hid.HidTransport.enumerate(usb_ids=KEEPKEY_HID_IDS)
177177
devs.extend(webusb.WebUsbTransport.enumerate(usb_ids=KEEPKEY_WEBUSB_IDS))

hwilib/devices/ledger.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ def can_sign_taproot(self) -> bool:
539539
return isinstance(self.client, NewClient)
540540

541541

542-
def enumerate(password: Optional[str] = None) -> List[Dict[str, Any]]:
542+
def enumerate(password: Optional[str] = None, expert: bool = False, chain: Chain = Chain.MAIN) -> List[Dict[str, Any]]:
543543
results = []
544544
devices = []
545545
devices.extend(hid.enumerate(LEDGER_VENDOR_ID, 0))

hwilib/devices/trezor.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -847,7 +847,7 @@ def can_sign_taproot(self) -> bool:
847847
return bool(self.client.version >= (1, 10, 4))
848848

849849

850-
def enumerate(password: Optional[str] = None) -> List[Dict[str, Any]]:
850+
def enumerate(password: Optional[str] = None, expert: bool = False, chain: Chain = Chain.MAIN) -> List[Dict[str, Any]]:
851851
results = []
852852
devs = hid.HidTransport.enumerate()
853853
devs.extend(webusb.WebUsbTransport.enumerate())

0 commit comments

Comments
 (0)