From 5aa592a69af8bdf14cb98f01941174b82c753b34 Mon Sep 17 00:00:00 2001 From: Tomas Susanka Date: Fri, 28 Jun 2019 12:26:34 +0200 Subject: [PATCH] core/slip39: modify wording on success screen --- core/src/apps/common/mnemonic/__init__.py | 2 ++ core/src/apps/management/backup_device.py | 13 +++++++------ core/src/apps/management/common/layout.py | 13 ++++++++++--- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/core/src/apps/common/mnemonic/__init__.py b/core/src/apps/common/mnemonic/__init__.py index 198c35f4b..e65d006e1 100644 --- a/core/src/apps/common/mnemonic/__init__.py +++ b/core/src/apps/common/mnemonic/__init__.py @@ -17,6 +17,8 @@ TYPES_WORD_COUNT = {12: bip39, 18: bip39, 24: bip39, 20: slip39, 33: slip39} def get() -> (bytes, int): mnemonic_secret = storage.get_mnemonic_secret() mnemonic_type = storage.get_mnemonic_type() or TYPE_BIP39 + if mnemonic_type not in (TYPE_BIP39, TYPE_SLIP39): + raise RuntimeError("Invalid mnemonic type") return mnemonic_secret, mnemonic_type diff --git a/core/src/apps/management/backup_device.py b/core/src/apps/management/backup_device.py index 63d13d434..376c968d5 100644 --- a/core/src/apps/management/backup_device.py +++ b/core/src/apps/management/backup_device.py @@ -12,18 +12,19 @@ async def backup_device(ctx, msg): if not storage.needs_backup(): raise wire.ProcessError("Seed already backed up") + 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") + await layout.show_backup_warning(ctx, "Back up your seed", "I understand", slip39) storage.set_unfinished_backup(True) storage.set_backed_up() - mnemonic_secret, mnemonic_type = mnemonic.get() - if mnemonic_type == mnemonic.TYPE_BIP39: - await layout.bip39_show_and_confirm_mnemonic(ctx, mnemonic_secret.decode()) - - elif mnemonic_type == mnemonic.TYPE_SLIP39: + if slip39: await backup_slip39_wallet(ctx, mnemonic_secret) + else: + await layout.bip39_show_and_confirm_mnemonic(ctx, mnemonic_secret.decode()) storage.set_unfinished_backup(False) diff --git a/core/src/apps/management/common/layout.py b/core/src/apps/management/common/layout.py index 038254012..19ae80b0b 100644 --- a/core/src/apps/management/common/layout.py +++ b/core/src/apps/management/common/layout.py @@ -129,11 +129,16 @@ async def _confirm_word(ctx, share_index, numbered_share_words): return selected_word == checked_word -async def _show_confirmation_success(ctx, share_index, num_of_shares=None): +async def _show_confirmation_success( + ctx, share_index, num_of_shares=None, slip39=False +): 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.bold("You finished verifying") - text.bold("your recovery shares.") + if slip39: + text.bold("your recovery shares.") + else: + text.bold("your recovery seed.") else: text = Text("Recovery share #%s" % (share_index + 1), ui.ICON_RESET) text.bold("Recovery share #%s" % (share_index + 1)) @@ -344,7 +349,9 @@ async def slip39_show_and_confirm_shares(ctx, shares): # make the user confirm 2 words from the share if await _confirm_share_words(ctx, index, share_words): - await _show_confirmation_success(ctx, index, len(shares)) + await _show_confirmation_success( + ctx, index, num_of_shares=len(shares), slip39=True + ) break # this share is confirmed, go to next one else: await _show_confirmation_failure(ctx, index)