mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-28 16:21:03 +00:00
core/slip39: add texts from copy and add success screen in recovery
This commit is contained in:
parent
487cc19750
commit
5394d5a5a5
@ -20,11 +20,13 @@ if __debug__:
|
|||||||
|
|
||||||
async def show_reset_device_warning(ctx, use_slip39: bool):
|
async def show_reset_device_warning(ctx, use_slip39: bool):
|
||||||
text = Text("Create new wallet", ui.ICON_RESET, new_lines=False)
|
text = Text("Create new wallet", ui.ICON_RESET, new_lines=False)
|
||||||
text.bold("Do you want to create")
|
|
||||||
text.br()
|
|
||||||
if use_slip39:
|
if use_slip39:
|
||||||
text.bold("a new Shamir wallet?")
|
text.bold("Create a new wallet")
|
||||||
|
text.br()
|
||||||
|
text.bold("with Shamir Backup?")
|
||||||
else:
|
else:
|
||||||
|
text.bold("Do you want to create")
|
||||||
|
text.br()
|
||||||
text.bold("a new wallet?")
|
text.bold("a new wallet?")
|
||||||
text.br()
|
text.br()
|
||||||
text.br_half()
|
text.br_half()
|
||||||
@ -53,7 +55,7 @@ async def show_backup_success(ctx):
|
|||||||
"it online!",
|
"it online!",
|
||||||
)
|
)
|
||||||
await require_confirm(
|
await require_confirm(
|
||||||
ctx, text, ButtonRequestType.ResetDevice, confirm="Finish setup", cancel=None
|
ctx, text, ButtonRequestType.ResetDevice, confirm="Finish backup", cancel=None
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -64,7 +66,7 @@ async def confirm_backup(ctx):
|
|||||||
text.bold("successfully!")
|
text.bold("successfully!")
|
||||||
text.br()
|
text.br()
|
||||||
text.br_half()
|
text.br_half()
|
||||||
text.normal("You should back your")
|
text.normal("You should back up your")
|
||||||
text.br()
|
text.br()
|
||||||
text.normal("new wallet right now.")
|
text.normal("new wallet right now.")
|
||||||
return await confirm(
|
return await confirm(
|
||||||
@ -72,7 +74,7 @@ async def confirm_backup(ctx):
|
|||||||
text,
|
text,
|
||||||
ButtonRequestType.ResetDevice,
|
ButtonRequestType.ResetDevice,
|
||||||
cancel="Skip",
|
cancel="Skip",
|
||||||
confirm="Backup",
|
confirm="Back up",
|
||||||
major_confirm=True,
|
major_confirm=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -143,14 +145,13 @@ async def _confirm_word(ctx, share_index, numbered_share_words):
|
|||||||
async def _show_confirmation_success(ctx, share_index, num_of_shares=None):
|
async def _show_confirmation_success(ctx, share_index, num_of_shares=None):
|
||||||
if share_index is None or num_of_shares is None or share_index == num_of_shares - 1:
|
if share_index is None or num_of_shares is None or share_index == num_of_shares - 1:
|
||||||
text = Text("Recovery seed", ui.ICON_RESET)
|
text = Text("Recovery seed", ui.ICON_RESET)
|
||||||
text.bold("Recovery seed")
|
text.bold("You finished verifying")
|
||||||
text.bold("checked successfully.")
|
text.bold("your recovery shares.")
|
||||||
else:
|
else:
|
||||||
text = Text("Recovery share #%s" % (share_index + 1), ui.ICON_RESET)
|
text = Text("Recovery share #%s" % (share_index + 1), ui.ICON_RESET)
|
||||||
text.bold("Recovery share #%s" % (share_index + 1))
|
text.bold("Recovery share #%s" % (share_index + 1))
|
||||||
text.bold("checked successfully.")
|
text.bold("checked successfully.")
|
||||||
text.normal("Let's continue with")
|
text.normal("Continue with share #%s." % (share_index + 2))
|
||||||
text.normal("share #%s." % (share_index + 2))
|
|
||||||
return await confirm(
|
return await confirm(
|
||||||
ctx, text, ButtonRequestType.ResetDevice, cancel=None, confirm="Continue"
|
ctx, text, ButtonRequestType.ResetDevice, cancel=None, confirm="Continue"
|
||||||
)
|
)
|
||||||
@ -161,8 +162,7 @@ async def _show_confirmation_failure(ctx, share_index):
|
|||||||
text = Text("Recovery seed", ui.ICON_WRONG, ui.RED)
|
text = Text("Recovery seed", ui.ICON_WRONG, ui.RED)
|
||||||
else:
|
else:
|
||||||
text = Text("Recovery share #%s" % (share_index + 1), ui.ICON_WRONG, ui.RED)
|
text = Text("Recovery share #%s" % (share_index + 1), ui.ICON_WRONG, ui.RED)
|
||||||
text.bold("You have entered")
|
text.bold("That is the wrong word.")
|
||||||
text.bold("wrong seed word.")
|
|
||||||
text.bold("Please check again.")
|
text.bold("Please check again.")
|
||||||
await require_confirm(
|
await require_confirm(
|
||||||
ctx, text, ButtonRequestType.ResetDevice, confirm="Check again", cancel=None
|
ctx, text, ButtonRequestType.ResetDevice, confirm="Check again", cancel=None
|
||||||
@ -242,15 +242,15 @@ def _get_mnemonic_page(words: list):
|
|||||||
async def slip39_show_checklist_set_shares(ctx):
|
async def slip39_show_checklist_set_shares(ctx):
|
||||||
checklist = Checklist("Backup checklist", ui.ICON_RESET)
|
checklist = Checklist("Backup checklist", ui.ICON_RESET)
|
||||||
checklist.add("Set number of shares")
|
checklist.add("Set number of shares")
|
||||||
checklist.add("Set the threshold")
|
checklist.add("Set threshold")
|
||||||
checklist.add(("Write down and check", "all backup shares"))
|
checklist.add(("Write down and check", "all shares"))
|
||||||
checklist.select(0)
|
checklist.select(0)
|
||||||
return await confirm(
|
return await confirm(
|
||||||
ctx,
|
ctx,
|
||||||
checklist,
|
checklist,
|
||||||
ButtonRequestType.ResetDevice,
|
ButtonRequestType.ResetDevice,
|
||||||
cancel=None,
|
cancel=None,
|
||||||
confirm="Set share count",
|
confirm="Continue",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -265,7 +265,7 @@ async def slip39_show_checklist_set_threshold(ctx, num_of_shares):
|
|||||||
checklist,
|
checklist,
|
||||||
ButtonRequestType.ResetDevice,
|
ButtonRequestType.ResetDevice,
|
||||||
cancel=None,
|
cancel=None,
|
||||||
confirm="Set threshold",
|
confirm="Continue",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -280,7 +280,7 @@ async def slip39_show_checklist_show_shares(ctx, num_of_shares, threshold):
|
|||||||
checklist,
|
checklist,
|
||||||
ButtonRequestType.ResetDevice,
|
ButtonRequestType.ResetDevice,
|
||||||
cancel=None,
|
cancel=None,
|
||||||
confirm="Show backup shares",
|
confirm="Continue",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -296,7 +296,7 @@ async def slip39_prompt_number_of_shares(ctx):
|
|||||||
shares,
|
shares,
|
||||||
ButtonRequestType.ResetDevice,
|
ButtonRequestType.ResetDevice,
|
||||||
cancel="Info",
|
cancel="Info",
|
||||||
confirm="Set",
|
confirm="Continue",
|
||||||
major_confirm=True,
|
major_confirm=True,
|
||||||
cancel_style=ButtonDefault,
|
cancel_style=ButtonDefault,
|
||||||
)
|
)
|
||||||
@ -305,13 +305,12 @@ async def slip39_prompt_number_of_shares(ctx):
|
|||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
info = InfoConfirm(
|
info = InfoConfirm(
|
||||||
"Shares are parts of "
|
"Each recovery share is "
|
||||||
"the recovery seed, "
|
"a sequence of 20 "
|
||||||
"each containing 20 "
|
"words. Next you will "
|
||||||
"words. You can later set "
|
"choose how many "
|
||||||
"how many shares you "
|
"shares you need to "
|
||||||
"need to recover your "
|
"recover your wallet."
|
||||||
"wallet."
|
|
||||||
)
|
)
|
||||||
await info
|
await info
|
||||||
|
|
||||||
@ -332,7 +331,7 @@ async def slip39_prompt_threshold(ctx, num_of_shares):
|
|||||||
shares,
|
shares,
|
||||||
ButtonRequestType.ResetDevice,
|
ButtonRequestType.ResetDevice,
|
||||||
cancel="Info",
|
cancel="Info",
|
||||||
confirm="Set",
|
confirm="Continue",
|
||||||
major_confirm=True,
|
major_confirm=True,
|
||||||
cancel_style=ButtonDefault,
|
cancel_style=ButtonDefault,
|
||||||
)
|
)
|
||||||
@ -341,12 +340,12 @@ async def slip39_prompt_threshold(ctx, num_of_shares):
|
|||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
info = InfoConfirm(
|
info = InfoConfirm(
|
||||||
"Threshold sets number "
|
"The threshold sets the "
|
||||||
"shares that you need "
|
"number of shares "
|
||||||
"to recover your wallet. "
|
"needed to recover your "
|
||||||
"i.e. Set it to %s and "
|
"wallet. Set it to %s and "
|
||||||
"you'll need any %s shares "
|
"you will need any %s "
|
||||||
"of the total number." % (count, count)
|
"of your %s shares." % (count, count, num_of_shares)
|
||||||
)
|
)
|
||||||
await info
|
await info
|
||||||
|
|
||||||
@ -381,8 +380,8 @@ async def _slip39_show_share_words(ctx, share_index, share_words):
|
|||||||
|
|
||||||
# first page
|
# first page
|
||||||
text = Text(header_title, header_icon)
|
text = Text(header_title, header_icon)
|
||||||
text.bold("Write down %s words" % len(share_words))
|
text.bold("Write down these")
|
||||||
text.bold("onto paper booklet:")
|
text.bold("%s words:" % len(share_words))
|
||||||
text.br_half()
|
text.br_half()
|
||||||
for index, word in first:
|
for index, word in first:
|
||||||
text.mono("%s. %s" % (index + 1, word))
|
text.mono("%s. %s" % (index + 1, word))
|
||||||
@ -460,7 +459,7 @@ class ShamirNumInput(ui.Control):
|
|||||||
if self.step is ShamirNumInput.SET_SHARES:
|
if self.step is ShamirNumInput.SET_SHARES:
|
||||||
header = "Set num. of shares"
|
header = "Set num. of shares"
|
||||||
elif self.step is ShamirNumInput.SET_THRESHOLD:
|
elif self.step is ShamirNumInput.SET_THRESHOLD:
|
||||||
header = "Set the threshold"
|
header = "Set threshold"
|
||||||
ui.header(header, ui.ICON_RESET, ui.TITLE_GREY, ui.BG, ui.ORANGE_ICON)
|
ui.header(header, ui.ICON_RESET, ui.TITLE_GREY, ui.BG, ui.ORANGE_ICON)
|
||||||
|
|
||||||
# render the counter
|
# render the counter
|
||||||
@ -475,16 +474,16 @@ class ShamirNumInput(ui.Control):
|
|||||||
ui.WIDTH - 12,
|
ui.WIDTH - 12,
|
||||||
)
|
)
|
||||||
ui.display.text(
|
ui.display.text(
|
||||||
12, 156, "will each host one share.", ui.NORMAL, ui.FG, ui.BG
|
12, 156, "will each hold one share.", ui.NORMAL, ui.FG, ui.BG
|
||||||
)
|
)
|
||||||
elif self.step is ShamirNumInput.SET_THRESHOLD:
|
elif self.step is ShamirNumInput.SET_THRESHOLD:
|
||||||
ui.display.text(
|
ui.display.text(
|
||||||
12, 130, "For recovery you'll need", ui.NORMAL, ui.FG, ui.BG
|
12, 130, "For recovery you need", ui.NORMAL, ui.FG, ui.BG
|
||||||
)
|
)
|
||||||
ui.display.text(
|
ui.display.text(
|
||||||
12,
|
12,
|
||||||
156,
|
156,
|
||||||
"any %s of shares." % count,
|
"any %s of the shares." % count,
|
||||||
ui.BOLD,
|
ui.BOLD,
|
||||||
ui.FG,
|
ui.FG,
|
||||||
ui.BG,
|
ui.BG,
|
||||||
@ -514,7 +513,7 @@ class MnemonicWordSelect(ui.Layout):
|
|||||||
self.text = Text("Check seed")
|
self.text = Text("Check seed")
|
||||||
else:
|
else:
|
||||||
self.text = Text("Check share #%s" % (share_index + 1))
|
self.text = Text("Check share #%s" % (share_index + 1))
|
||||||
self.text.normal("Choose the %s word:" % utils.format_ordinal(word_index + 1))
|
self.text.normal("Select the %s word:" % utils.format_ordinal(word_index + 1))
|
||||||
|
|
||||||
def dispatch(self, event, x, y):
|
def dispatch(self, event, x, y):
|
||||||
for btn in self.buttons:
|
for btn in self.buttons:
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
from trezor import config, ui, wire
|
from trezor import config, ui, wire
|
||||||
from trezor.crypto import slip39
|
|
||||||
from trezor.messages import ButtonRequestType
|
from trezor.messages import ButtonRequestType
|
||||||
from trezor.messages.ButtonRequest import ButtonRequest
|
from trezor.messages.ButtonRequest import ButtonRequest
|
||||||
from trezor.messages.MessageType import ButtonAck
|
from trezor.messages.MessageType import ButtonAck
|
||||||
@ -11,6 +10,7 @@ from trezor.ui.mnemonic_slip39 import Slip39Keyboard
|
|||||||
from trezor.ui.text import Text
|
from trezor.ui.text import Text
|
||||||
from trezor.ui.word_select import WordSelector
|
from trezor.ui.word_select import WordSelector
|
||||||
from trezor.utils import format_ordinal
|
from trezor.utils import format_ordinal
|
||||||
|
from trezor.crypto import slip39
|
||||||
|
|
||||||
from apps.common import mnemonic, storage
|
from apps.common import mnemonic, storage
|
||||||
from apps.common.confirm import require_confirm
|
from apps.common.confirm import require_confirm
|
||||||
@ -36,9 +36,9 @@ async def recovery_device(ctx, msg):
|
|||||||
|
|
||||||
if not storage.is_slip39_in_progress():
|
if not storage.is_slip39_in_progress():
|
||||||
if not msg.dry_run:
|
if not msg.dry_run:
|
||||||
title = "Device recovery"
|
title = "Wallet recovery"
|
||||||
text = Text(title, ui.ICON_RECOVERY)
|
text = Text(title, ui.ICON_RECOVERY)
|
||||||
text.normal("Do you really want to", "recover the device?", "")
|
text.normal("Do you really want to", "recover the wallet?", "")
|
||||||
else:
|
else:
|
||||||
title = "Simulated recovery"
|
title = "Simulated recovery"
|
||||||
text = Text(title, ui.ICON_RECOVERY)
|
text = Text(title, ui.ICON_RECOVERY)
|
||||||
@ -116,6 +116,7 @@ async def recovery_device(ctx, msg):
|
|||||||
storage.load_settings(label=msg.label, use_passphrase=msg.passphrase_protection)
|
storage.load_settings(label=msg.label, use_passphrase=msg.passphrase_protection)
|
||||||
mnemonic_module.store(secret=secret, needs_backup=False, no_backup=False)
|
mnemonic_module.store(secret=secret, needs_backup=False, no_backup=False)
|
||||||
|
|
||||||
|
await show_success(ctx)
|
||||||
display_homescreen()
|
display_homescreen()
|
||||||
|
|
||||||
return Success(message="Device recovered")
|
return Success(message="Device recovered")
|
||||||
@ -171,14 +172,23 @@ async def show_keyboard_info(ctx):
|
|||||||
await ctx.wait(info)
|
await ctx.wait(info)
|
||||||
|
|
||||||
|
|
||||||
async def show_remaining_slip39_mnemonics(ctx, title, remaining: int):
|
async def show_success(ctx):
|
||||||
text = Text(title, ui.ICON_RECOVERY)
|
text = Text("Recovery success", ui.ICON_RECOVERY)
|
||||||
text.bold("Good job!")
|
text.normal("You have successfully")
|
||||||
if remaining > 1:
|
text.normal("recovered your wallet.")
|
||||||
text.normal("%s more shares" % remaining)
|
await require_confirm(
|
||||||
else:
|
ctx, text, ButtonRequestType.ProtectCall, cancel=None, confirm="Continue"
|
||||||
text.normal("%s more share" % remaining)
|
)
|
||||||
text.normal("needed to enter.")
|
|
||||||
|
|
||||||
|
async def show_remaining_slip39_mnemonics(ctx, title, remaining: int):
|
||||||
|
text = Text(title, ui.ICON_RECOVERY)
|
||||||
|
text.bold("Good job!")
|
||||||
|
text.normal("Enter %s more recovery " % remaining)
|
||||||
|
if remaining > 1:
|
||||||
|
text.normal("shares.")
|
||||||
|
else:
|
||||||
|
text.normal("share.")
|
||||||
await require_confirm(
|
await require_confirm(
|
||||||
ctx, text, ButtonRequestType.ProtectCall, cancel=None, confirm="Continue"
|
ctx, text, ButtonRequestType.ProtectCall, cancel=None, confirm="Continue"
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user