Skip to content

Commit

Permalink
un-support AddressType.WIT for ledger_nano_x
Browse files Browse the repository at this point in the history
  • Loading branch information
icodeface committed Jun 1, 2022
1 parent 8529936 commit d4d1914
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
10 changes: 6 additions & 4 deletions hwilib/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@


# Get the client for the device
def get_client(device_type: str, device_path: str, password: str = "", expert: bool = False, chain: Chain = Chain.MAIN) -> Optional[HardwareWalletClient]:
def get_client(device_type: str, device_path: str, password: str = "", expert: bool = False, chain: Chain = Chain.MAIN, model: str = "") -> Optional[HardwareWalletClient]:
"""
Returns a HardwareWalletClient for the given device type at the device path
Expand All @@ -95,7 +95,7 @@ def get_client(device_type: str, device_path: str, password: str = "", expert: b
if client:
client.close()
raise UnknownDeviceError('Unknown device type specified')

client.model = model
return client

# Get a list of all available hardware wallets
Expand Down Expand Up @@ -150,7 +150,7 @@ def find_device(
try:
assert isinstance(d["type"], str)
assert isinstance(d["path"], str)
client = get_client(d['type'], d['path'], password, expert, chain)
client = get_client(d['type'], d['path'], password, expert, chain, d['model'])
if client is None:
raise Exception()

Expand Down Expand Up @@ -405,10 +405,12 @@ def getdescriptors(
master_fpr = client.get_master_fingerprint()

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

for internal in [False, True]:
descriptors = []
for addr_type in (AddressType.LEGACY, AddressType.SH_WIT, AddressType.WIT):
for addr_type in support_addr_types:
try:
desc = getdescriptor(client, master_fpr=master_fpr, internal=internal, addr_type=addr_type, account=account)
except UnavailableActionError:
Expand Down
1 change: 1 addition & 0 deletions hwilib/hwwclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def __init__(self, path: str, password: str, expert: bool, chain: Chain = Chain.
# {bip32_path: <xpub string>}
self.xpub_cache: Dict[str, str] = {}
self.expert = expert
self.model = None

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

0 comments on commit d4d1914

Please sign in to comment.