1
0

hww: rm some code duplication: add "scan_and_create_client_for_device"

This commit is contained in:
SomberNight
2020-04-01 20:22:39 +02:00
parent 18c98483ac
commit 81fc3fcce2
7 changed files with 21 additions and 54 deletions

View File

@@ -522,22 +522,15 @@ class ColdcardPlugin(HW_PluginBase):
return None
def setup_device(self, device_info, wizard, purpose):
devmgr = self.device_manager()
device_id = device_info.device.id_
client = devmgr.client_by_id(device_id)
if client is None:
raise UserFacingException(_('Failed to create a client for this device.') + '\n' +
_('Make sure it is in the correct state.'))
client.handler = self.create_handler(wizard)
client = self.scan_and_create_client_for_device(device_id=device_id, wizard=wizard)
def get_xpub(self, device_id, derivation, xtype, wizard):
# this seems to be part of the pairing process only, not during normal ops?
# base_wizard:on_hw_derivation
if xtype not in self.SUPPORTED_XTYPES:
raise ScriptTypeNotSupported(_('This type of script is not supported with {}.').format(self.device))
devmgr = self.device_manager()
client = devmgr.client_by_id(device_id)
client.handler = self.create_handler(wizard)
client = self.scan_and_create_client_for_device(device_id=device_id, wizard=wizard)
client.ping_check()
xpub = client.get_xpub(derivation, xtype)