Skip to content

Commit

Permalink
Merge pull request #18 from firoorg/upstream_sync
Browse files Browse the repository at this point in the history
Hardware wallet coin name recognition based on Trezor client version
  • Loading branch information
levonpetrosyan93 authored Mar 10, 2024
2 parents aa3e908 + a027468 commit fc196fc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
21 changes: 15 additions & 6 deletions src/app_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -760,10 +760,8 @@ def read_from_file(self, hw_session: 'HwSessionInfo', file_name: Optional[str] =
self.last_bip32_base_path = def_bip32_path
self.bip32_recursive_search = config.getboolean(section, 'bip32_recursive', fallback=True)

self.hw_type = config.get(section, 'hw_type', fallback=HWType.trezor)
if self.hw_type not in (HWType.trezor, HWType.keepkey, HWType.ledger_nano):
logging.warning('Invalid hardware wallet type: ' + self.hw_type)
self.hw_type = HWType.trezor
type = config.get(section, 'hw_type', fallback=HWType.trezor.value)
self.hw_type = HWType.from_string(type)

self.hw_keepkey_psw_encoding = config.get(section, 'hw_keepkey_psw_encoding', fallback='NFC')
if self.hw_keepkey_psw_encoding not in ('NFC', 'NFKD'):
Expand Down Expand Up @@ -1688,9 +1686,20 @@ def get_firo(self):

@property
def hw_coin_name(self):
if self.hw_type == HWType.ledger_nano:
if self.hw_session_info is None or \
self.hw_session_info.hw_client is None or \
self.hw_session_info.hw_type != HWType.trezor:
return self.get_zcoin()

trezor_version = self.hw_session_info.hw_client.version
if trezor_version[0] == 1 and trezor_version[1] < 10:
return self.get_zcoin()
return self.get_firo()
elif trezor_version[0] == 2 and \
(trezor_version[1] < 3 or \
(trezor_version[1] == 3 and trezor_version[2] < 7)):
return self.get_zcoin()
else:
return self.get_firo()

def get_block_explorer_tx(self):
if self.dash_network == 'MAINNET':
Expand Down
3 changes: 2 additions & 1 deletion src/hw_intf.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def catch_hw_client(*args, **kwargs):
except (OSError, usb1.USBErrorNoDevice) as e:
logging.exception('Exception calling %s function' % func.__name__)
logging.info('Disconnecting HW after OSError occurred')
hw_session.hw_disconnect()
hw_session.disconnect_hardware_wallet()
raise HWNotConnectedException('The hardware wallet device has been disconnected with the '
'following error: ' + str(e))

Expand Down Expand Up @@ -948,6 +948,7 @@ def __init__(self, main_dlg, app_config: 'AppConfig', runtime_data: AppRuntimeDa

self.__locks = {} # key: hw_client, value: EnhRLock
self.__main_dlg = main_dlg
app_config.hw_session_info = self
self.__runtime_data: AppRuntimeData = runtime_data
self.__base_bip32_path: str = ''
self.__base_public_key: bytes = b''
Expand Down

0 comments on commit fc196fc

Please sign in to comment.