async def backup_device(ctx, msg): if not storage.is_initialized(): raise wire.ProcessError("Device is not initialized") 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", slip39) storage.set_unfinished_backup(True) storage.set_backed_up() 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) return Success(message="Seed successfully backed up")
async def backup_device(ctx, msg): if not storage.is_initialized(): raise wire.FailureError(ProcessError, 'Device is not initialized') if not storage.needs_backup(): raise wire.FailureError(ProcessError, 'Seed already backed up') mnemonic = storage.get_mnemonic() storage.set_backed_up() # warn user about mnemonic safety await show_warning(ctx) while True: # show mnemonic and require confirmation of a random word await show_mnemonic(ctx, mnemonic) if await check_mnemonic(ctx, mnemonic): break await show_wrong_entry(ctx) return Success(message='Seed successfully backed up')
async def backup_device(ctx, msg): if not storage.is_initialized(): raise wire.ProcessError("Device is not initialized") if not storage.needs_backup(): raise wire.ProcessError("Seed already backed up") words = mnemonic.restore() # warn user about mnemonic safety await show_backup_warning(ctx) storage.set_unfinished_backup(True) storage.set_backed_up() while True: # show mnemonic and require confirmation of a random word await show_mnemonic(ctx, words) if await check_mnemonic(ctx, words): break await show_wrong_entry(ctx) storage.set_unfinished_backup(False) return Success(message="Seed successfully backed up")