trezor/keepkey separation: init device

This commit is contained in:
SomberNight 2017-12-04 19:56:46 +01:00
parent 414b6e8a06
commit 84239e168b
2 changed files with 10 additions and 21 deletions

View File

@ -169,26 +169,14 @@ class KeepKeyCompatiblePlugin(HW_PluginBase):
def _initialize_device(self, settings, method, device_id, wizard, handler): def _initialize_device(self, settings, method, device_id, wizard, handler):
item, label, pin_protection, passphrase_protection = settings item, label, pin_protection, passphrase_protection = settings
if method == TIM_RECOVER and self.device == 'TREZOR':
# Warn user about firmware lameness
handler.show_error(_(
"You will be asked to enter 24 words regardless of your "
"seed's actual length. If you enter a word incorrectly or "
"misspell it, you cannot change it or go back - you will need "
"to start again from the beginning.\n\nSo please enter "
"the words carefully!"))
language = 'english' language = 'english'
devmgr = self.device_manager() devmgr = self.device_manager()
client = devmgr.client_by_id(device_id) client = devmgr.client_by_id(device_id)
if method == TIM_NEW: if method == TIM_NEW:
strength = 64 * (item + 2) # 128, 192 or 256 strength = 64 * (item + 2) # 128, 192 or 256
args = [True, strength, passphrase_protection, client.reset_device(True, strength, passphrase_protection,
pin_protection, label, language] pin_protection, label, language)
if self.device == 'TREZOR':
args.extend([0, False]) # u2f_counter, skip_backup
client.reset_device(*args)
elif method == TIM_RECOVER: elif method == TIM_RECOVER:
word_count = 6 * (item + 2) # 12, 18 or 24 word_count = 6 * (item + 2) # 12, 18 or 24
client.step = 0 client.step = 0

View File

@ -168,8 +168,9 @@ class TrezorCompatiblePlugin(HW_PluginBase):
def _initialize_device(self, settings, method, device_id, wizard, handler): def _initialize_device(self, settings, method, device_id, wizard, handler):
item, label, pin_protection, passphrase_protection = settings item, label, pin_protection, passphrase_protection = settings
if method == TIM_RECOVER and self.device == 'TREZOR': if method == TIM_RECOVER:
# Warn user about firmware lameness # FIXME the PIN prompt will appear over this message
# which makes this unreadable
handler.show_error(_( handler.show_error(_(
"You will be asked to enter 24 words regardless of your " "You will be asked to enter 24 words regardless of your "
"seed's actual length. If you enter a word incorrectly or " "seed's actual length. If you enter a word incorrectly or "
@ -183,11 +184,11 @@ class TrezorCompatiblePlugin(HW_PluginBase):
if method == TIM_NEW: if method == TIM_NEW:
strength = 64 * (item + 2) # 128, 192 or 256 strength = 64 * (item + 2) # 128, 192 or 256
args = [True, strength, passphrase_protection, u2f_counter = 0
pin_protection, label, language] skip_backup = False
if self.device == 'TREZOR': client.reset_device(True, strength, passphrase_protection,
args.extend([0, False]) # u2f_counter, skip_backup pin_protection, label, language,
client.reset_device(*args) u2f_counter, skip_backup)
elif method == TIM_RECOVER: elif method == TIM_RECOVER:
word_count = 6 * (item + 2) # 12, 18 or 24 word_count = 6 * (item + 2) # 12, 18 or 24
client.step = 0 client.step = 0