Skip to content

Commit b02e4e5

Browse files
authored
Merge pull request #5 from qtumproject/cf/fix-nano-x-getdescriptors
fix nano x getdescriptors
2 parents 8529936 + d4d1914 commit b02e4e5

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

hwilib/commands.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070

7171

7272
# Get the client for the device
73-
def get_client(device_type: str, device_path: str, password: str = "", expert: bool = False, chain: Chain = Chain.MAIN) -> Optional[HardwareWalletClient]:
73+
def get_client(device_type: str, device_path: str, password: str = "", expert: bool = False, chain: Chain = Chain.MAIN, model: str = "") -> Optional[HardwareWalletClient]:
7474
"""
7575
Returns a HardwareWalletClient for the given device type at the device path
7676
@@ -95,7 +95,7 @@ def get_client(device_type: str, device_path: str, password: str = "", expert: b
9595
if client:
9696
client.close()
9797
raise UnknownDeviceError('Unknown device type specified')
98-
98+
client.model = model
9999
return client
100100

101101
# Get a list of all available hardware wallets
@@ -150,7 +150,7 @@ def find_device(
150150
try:
151151
assert isinstance(d["type"], str)
152152
assert isinstance(d["path"], str)
153-
client = get_client(d['type'], d['path'], password, expert, chain)
153+
client = get_client(d['type'], d['path'], password, expert, chain, d['model'])
154154
if client is None:
155155
raise Exception()
156156

@@ -405,10 +405,12 @@ def getdescriptors(
405405
master_fpr = client.get_master_fingerprint()
406406

407407
result = {}
408+
support_addr_types = [AddressType.LEGACY, AddressType.SH_WIT] if client.model == "ledger_nano_x" \
409+
else [AddressType.LEGACY, AddressType.WIT, AddressType.SH_WIT]
408410

409411
for internal in [False, True]:
410412
descriptors = []
411-
for addr_type in (AddressType.LEGACY, AddressType.SH_WIT, AddressType.WIT):
413+
for addr_type in support_addr_types:
412414
try:
413415
desc = getdescriptor(client, master_fpr=master_fpr, internal=internal, addr_type=addr_type, account=account)
414416
except UnavailableActionError:

hwilib/hwwclient.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def __init__(self, path: str, password: str, expert: bool, chain: Chain = Chain.
4343
# {bip32_path: <xpub string>}
4444
self.xpub_cache: Dict[str, str] = {}
4545
self.expert = expert
46+
self.model = None
4647

4748
def get_master_xpub(self, addrtype: AddressType = AddressType.WIT, account: int = 0) -> ExtendedKey:
4849
"""

0 commit comments

Comments
 (0)