mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-23 23:08:14 +00:00
core: add backup warnings at correct place; add backup success page
closes #287
This commit is contained in:
parent
68efe429cd
commit
5134cd0b80
@ -15,9 +15,6 @@ async def backup_device(ctx, msg):
|
||||
mnemonic_secret, mnemonic_type = mnemonic.get()
|
||||
slip39 = mnemonic_type == mnemonic.TYPE_SLIP39
|
||||
|
||||
# warn user about mnemonic safety
|
||||
await layout.show_backup_warning(ctx, "Back up your seed", "I understand", slip39)
|
||||
|
||||
storage.device.set_unfinished_backup(True)
|
||||
storage.device.set_backed_up()
|
||||
|
||||
@ -28,4 +25,6 @@ async def backup_device(ctx, msg):
|
||||
|
||||
storage.device.set_unfinished_backup(False)
|
||||
|
||||
await layout.show_backup_success(ctx)
|
||||
|
||||
return Success(message="Seed successfully backed up")
|
||||
|
@ -7,7 +7,6 @@ from trezor.messages import ButtonRequestType
|
||||
from trezor.ui.button import Button, ButtonDefault
|
||||
from trezor.ui.checklist import Checklist
|
||||
from trezor.ui.info import InfoConfirm
|
||||
from trezor.ui.loader import LoadingAnimation
|
||||
from trezor.ui.scroll import Paginated
|
||||
from trezor.ui.shamir import NumInput
|
||||
from trezor.ui.text import Text
|
||||
@ -18,26 +17,6 @@ if __debug__:
|
||||
from apps import debug
|
||||
|
||||
|
||||
async def show_reset_device_warning(ctx, use_slip39: bool):
|
||||
text = Text("Create new wallet", ui.ICON_RESET, new_lines=False)
|
||||
if use_slip39:
|
||||
text.bold("Create a new wallet")
|
||||
text.br()
|
||||
text.bold("with Shamir Backup?")
|
||||
else:
|
||||
text.bold("Do you want to create")
|
||||
text.br()
|
||||
text.bold("a new wallet?")
|
||||
text.br()
|
||||
text.br_half()
|
||||
text.normal("By continuing you agree")
|
||||
text.br()
|
||||
text.normal("to")
|
||||
text.bold("https://trezor.io/tos")
|
||||
await require_confirm(ctx, text, ButtonRequestType.ResetDevice, major_confirm=True)
|
||||
await LoadingAnimation()
|
||||
|
||||
|
||||
async def show_internal_entropy(ctx, entropy: bytes):
|
||||
entropy_str = ubinascii.hexlify(entropy).decode()
|
||||
lines = utils.chunks(entropy_str, 16)
|
||||
@ -161,8 +140,8 @@ async def _show_confirmation_failure(ctx, share_index):
|
||||
)
|
||||
|
||||
|
||||
async def show_backup_warning(ctx, header: str, confirm_text: str, slip39=False):
|
||||
text = Text(header, ui.ICON_NOCOPY)
|
||||
async def show_backup_warning(ctx, slip39=False):
|
||||
text = Text("Back up your seed", ui.ICON_NOCOPY)
|
||||
if slip39:
|
||||
text.normal(
|
||||
"Never make a digital",
|
||||
@ -178,7 +157,17 @@ async def show_backup_warning(ctx, header: str, confirm_text: str, slip39=False)
|
||||
"it online!",
|
||||
)
|
||||
await require_confirm(
|
||||
ctx, text, ButtonRequestType.ResetDevice, confirm_text, cancel=None
|
||||
ctx, text, ButtonRequestType.ResetDevice, "I understand", cancel=None
|
||||
)
|
||||
|
||||
|
||||
async def show_backup_success(ctx):
|
||||
text = Text("Backup is done!", ui.ICON_RESET)
|
||||
text.normal(
|
||||
"Use the backup to", "recover your wallet", "if you ever lose", "the device."
|
||||
)
|
||||
await require_confirm(
|
||||
ctx, text, ButtonRequestType.ResetDevice, "Finish backup", cancel=None
|
||||
)
|
||||
|
||||
|
||||
@ -187,6 +176,9 @@ async def show_backup_warning(ctx, header: str, confirm_text: str, slip39=False)
|
||||
|
||||
|
||||
async def bip39_show_and_confirm_mnemonic(ctx, mnemonic: str):
|
||||
# warn user about mnemonic safety
|
||||
await show_backup_warning(ctx)
|
||||
|
||||
words = mnemonic.split()
|
||||
|
||||
while True:
|
||||
@ -341,6 +333,9 @@ async def slip39_prompt_threshold(ctx, num_of_shares):
|
||||
|
||||
|
||||
async def slip39_show_and_confirm_shares(ctx, shares):
|
||||
# warn user about mnemonic safety
|
||||
await show_backup_warning(ctx, slip39=True)
|
||||
|
||||
for index, share in enumerate(shares):
|
||||
share_words = share.split(" ")
|
||||
while True:
|
||||
|
@ -1,11 +1,15 @@
|
||||
from trezor import config, wire
|
||||
from trezor import config, ui, wire
|
||||
from trezor.crypto import bip39, hashlib, random, slip39
|
||||
from trezor.messages import ButtonRequestType
|
||||
from trezor.messages.EntropyAck import EntropyAck
|
||||
from trezor.messages.EntropyRequest import EntropyRequest
|
||||
from trezor.messages.Success import Success
|
||||
from trezor.pin import pin_to_int
|
||||
from trezor.ui.loader import LoadingAnimation
|
||||
from trezor.ui.text import Text
|
||||
|
||||
from apps.common import mnemonic, storage
|
||||
from apps.common.confirm import require_confirm
|
||||
from apps.management.change_pin import request_pin_confirm
|
||||
from apps.management.common import layout
|
||||
|
||||
@ -21,7 +25,7 @@ async def reset_device(ctx: wire.Context, msg: ResetDevice) -> Success:
|
||||
_validate_reset_device(msg)
|
||||
|
||||
# make sure user knows he's setting up a new wallet
|
||||
await layout.show_reset_device_warning(ctx, msg.slip39)
|
||||
await _show_reset_device_warning(ctx, msg.slip39)
|
||||
|
||||
# request new PIN
|
||||
if msg.pin_protection:
|
||||
@ -80,9 +84,7 @@ async def reset_device(ctx: wire.Context, msg: ResetDevice) -> Success:
|
||||
|
||||
# if we backed up the wallet, show success message
|
||||
if not msg.no_backup and not msg.skip_backup:
|
||||
await layout.show_backup_warning(
|
||||
ctx, "Backup is done!", "Finish backup", msg.slip39
|
||||
)
|
||||
await layout.show_backup_success(ctx)
|
||||
|
||||
return Success(message="Initialized")
|
||||
|
||||
@ -133,3 +135,23 @@ def _compute_secret_from_entropy(
|
||||
strength = strength_in_bytes // 8
|
||||
secret = entropy[:strength]
|
||||
return secret
|
||||
|
||||
|
||||
async def _show_reset_device_warning(ctx, use_slip39: bool):
|
||||
text = Text("Create new wallet", ui.ICON_RESET, new_lines=False)
|
||||
if use_slip39:
|
||||
text.bold("Create a new wallet")
|
||||
text.br()
|
||||
text.bold("with Shamir Backup?")
|
||||
else:
|
||||
text.bold("Do you want to create")
|
||||
text.br()
|
||||
text.bold("a new wallet?")
|
||||
text.br()
|
||||
text.br_half()
|
||||
text.normal("By continuing you agree")
|
||||
text.br()
|
||||
text.normal("to")
|
||||
text.bold("https://trezor.io/tos")
|
||||
await require_confirm(ctx, text, ButtonRequestType.ResetDevice, major_confirm=True)
|
||||
await LoadingAnimation()
|
||||
|
@ -35,6 +35,11 @@ class TestMsgResetDeviceT2(TrezorTest):
|
||||
assert btn_code == B.ResetDevice
|
||||
self.client.debug.press_yes()
|
||||
|
||||
# Confirm warning
|
||||
btn_code = yield
|
||||
assert btn_code == B.ResetDevice
|
||||
self.client.debug.press_yes()
|
||||
|
||||
# shares info
|
||||
btn_code = yield
|
||||
assert btn_code == B.ResetDevice
|
||||
@ -115,6 +120,7 @@ class TestMsgResetDeviceT2(TrezorTest):
|
||||
proto.ButtonRequest(code=B.ResetDevice),
|
||||
proto.ButtonRequest(code=B.ResetDevice),
|
||||
proto.ButtonRequest(code=B.ResetDevice),
|
||||
proto.ButtonRequest(code=B.ResetDevice),
|
||||
proto.ButtonRequest(code=B.Other),
|
||||
proto.ButtonRequest(code=B.ResetDevice),
|
||||
proto.ButtonRequest(code=B.Other),
|
||||
|
@ -45,6 +45,11 @@ class TestMsgResetDeviceT2(TrezorTest):
|
||||
assert btn_code == B.ResetDevice
|
||||
self.client.debug.press_yes()
|
||||
|
||||
# Confirm warning
|
||||
btn_code = yield
|
||||
assert btn_code == B.ResetDevice
|
||||
self.client.debug.press_yes()
|
||||
|
||||
# mnemonic phrases
|
||||
btn_code = yield
|
||||
assert btn_code == B.ResetDevice
|
||||
@ -84,6 +89,7 @@ class TestMsgResetDeviceT2(TrezorTest):
|
||||
proto.ButtonRequest(code=B.ResetDevice),
|
||||
proto.ButtonRequest(code=B.ResetDevice),
|
||||
proto.ButtonRequest(code=B.ResetDevice),
|
||||
proto.ButtonRequest(code=B.ResetDevice),
|
||||
proto.Success(),
|
||||
proto.Features(),
|
||||
]
|
||||
@ -144,6 +150,11 @@ class TestMsgResetDeviceT2(TrezorTest):
|
||||
assert btn_code == B.ResetDevice
|
||||
self.client.debug.press_yes()
|
||||
|
||||
# Confirm warning
|
||||
btn_code = yield
|
||||
assert btn_code == B.ResetDevice
|
||||
self.client.debug.press_yes()
|
||||
|
||||
# mnemonic phrases
|
||||
btn_code = yield
|
||||
assert btn_code == B.ResetDevice
|
||||
@ -186,6 +197,7 @@ class TestMsgResetDeviceT2(TrezorTest):
|
||||
proto.ButtonRequest(code=B.ResetDevice),
|
||||
proto.ButtonRequest(code=B.ResetDevice),
|
||||
proto.ButtonRequest(code=B.ResetDevice),
|
||||
proto.ButtonRequest(code=B.ResetDevice),
|
||||
proto.Success(),
|
||||
proto.Features(),
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user