You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
trezor-firmware/core/src/apps/management/backup_device.py

31 lines
1019 B

from trezor import wire
from trezor.messages.Success import Success
6 years ago
from apps.common import mnemonic, storage
from apps.management.common import layout
from apps.management.reset_device import backup_slip39_wallet
async def backup_device(ctx, msg):
if not storage.is_initialized():
6 years ago
raise wire.ProcessError("Device is not initialized")
if not storage.needs_backup():
6 years ago
raise wire.ProcessError("Seed already backed up")
# warn user about mnemonic safety
await layout.show_backup_warning(ctx, "Back up your seed", "I understand")
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:
await backup_slip39_wallet(ctx, mnemonic_secret)
storage.set_unfinished_backup(False)
6 years ago
return Success(message="Seed successfully backed up")