management: fix layout_load_device

This commit is contained in:
Jan Pochyla 2016-11-11 17:32:25 +01:00
parent b09f0eaf4e
commit f2a0132502
1 changed files with 13 additions and 6 deletions

View File

@ -14,7 +14,14 @@ async def layout_load_device(message, session_id):
if storage.is_initialized(): if storage.is_initialized():
raise wire.FailureError(UnexpectedMessage, 'Already initialized') raise wire.FailureError(UnexpectedMessage, 'Already initialized')
if not message.skip_checksum and not bip39.check(message.mnemonic): skip_checksum = getattr(message, 'skip_checksum', False)
mnemonic = getattr(message, 'mnemonic')
pin = getattr(message, 'pin', None)
label = getattr(message, 'label', None)
language = getattr(message, 'language', None)
passphrase_protection = getattr(message, 'passphrase_protection', False)
if not skip_checksum and not bip39.check(mnemonic):
raise wire.FailureError(Other, 'Mnemonic is not valid') raise wire.FailureError(Other, 'Mnemonic is not valid')
await require_confirm(session_id, Text( await require_confirm(session_id, Text(
@ -22,10 +29,10 @@ async def layout_load_device(message, session_id):
ui.BOLD, 'Loading private seed', 'is not recommended.', ui.BOLD, 'Loading private seed', 'is not recommended.',
ui.NORMAL, 'Continue only if you', 'know what you are doing!')) ui.NORMAL, 'Continue only if you', 'know what you are doing!'))
storage.load_mnemonic(message.mnemonic) storage.load_mnemonic(mnemonic)
storage.load_settings(pin=message.pin, storage.load_settings(pin=pin,
passphrase_protection=message.passphrase_protection, passphrase_protection=passphrase_protection,
language=message.language, language=language,
label=message.label) label=label)
return Success(message='Device loaded') return Success(message='Device loaded')