1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-18 12:28:09 +00:00

apps/management/reset_device: fix for new storage

This commit is contained in:
Jan Pochyla 2018-01-11 22:07:38 +01:00
parent 77b78e277a
commit 58c3bba9e2

View File

@ -11,6 +11,7 @@ if __debug__:
@unimport @unimport
async def layout_reset_device(ctx, msg): async def layout_reset_device(ctx, msg):
from trezor import config
from trezor.ui.text import Text from trezor.ui.text import Text
from trezor.crypto import hashlib, random, bip39 from trezor.crypto import hashlib, random, bip39
from trezor.messages.EntropyRequest import EntropyRequest from trezor.messages.EntropyRequest import EntropyRequest
@ -19,7 +20,7 @@ async def layout_reset_device(ctx, msg):
from trezor.messages import ButtonRequestType from trezor.messages import ButtonRequestType
from trezor.messages.wire_types import EntropyAck from trezor.messages.wire_types import EntropyAck
from apps.common.request_pin import request_pin_twice from apps.management.change_pin import request_pin_confirm
from apps.common.confirm import require_confirm from apps.common.confirm import require_confirm
from apps.common import storage from apps.common import storage
@ -42,9 +43,11 @@ async def layout_reset_device(ctx, msg):
await require_confirm(ctx, entropy_content, ButtonRequestType.ResetDevice) await require_confirm(ctx, entropy_content, ButtonRequestType.ResetDevice)
if msg.pin_protection: if msg.pin_protection:
pin = await request_pin_twice(ctx) curpin = ''
newpin = await request_pin_confirm(ctx)
else: else:
pin = None curpin = ''
newpin = ''
external_entropy_ack = await ctx.call(EntropyRequest(), EntropyAck) external_entropy_ack = await ctx.call(EntropyRequest(), EntropyAck)
ehash = hashlib.sha256() ehash = hashlib.sha256()
@ -55,11 +58,11 @@ async def layout_reset_device(ctx, msg):
await show_mnemonic_by_word(ctx, mnemonic) await show_mnemonic_by_word(ctx, mnemonic)
if curpin != newpin:
config.change_pin(curpin, newpin)
storage.load_settings(label=msg.label,
use_passphrase=msg.passphrase_protection)
storage.load_mnemonic(mnemonic) storage.load_mnemonic(mnemonic)
storage.load_settings(pin=pin,
passphrase_protection=msg.passphrase_protection,
language=msg.language,
label=msg.label)
return Success(message='Initialized') return Success(message='Initialized')