Beispiel #1
0
async def recovery_homescreen() -> None:
    if not storage.recovery.is_in_progress():
        workflow.replace_default(homescreen)
        return

    # recovery process does not communicate on the wire
    ctx = wire.DummyContext()
    await recovery_process(ctx)
Beispiel #2
0
async def recovery_device(ctx: wire.Context, msg: RecoveryDevice) -> Success:
    """
    Recover BIP39/SLIP39 seed into empty device.
    Recovery is also possible with replugged Trezor. We call this process Persistance.
    User starts the process here using the RecoveryDevice msg and then they can unplug
    the device anytime and continue without a computer.
    """
    _check_state(msg)

    if storage.recovery.is_in_progress():
        return await recovery_process(ctx)

    await _continue_dialog(ctx, msg)

    # for dry run pin needs to be entered
    if msg.dry_run:
        curpin, salt = await request_pin_and_sd_salt(ctx, "Enter PIN")
        if not config.check_pin(pin_to_int(curpin), salt):
            await show_pin_invalid(ctx)
            raise wire.PinInvalid("PIN invalid")

    # set up pin if requested
    if msg.pin_protection:
        if msg.dry_run:
            raise wire.ProcessError("Can't setup PIN during dry_run recovery.")
        newpin = await request_pin_confirm(ctx, allow_cancel=False)
        config.change_pin(pin_to_int(""), pin_to_int(newpin), None, None)

    if msg.u2f_counter:
        storage.device.set_u2f_counter(msg.u2f_counter)
    storage.device.load_settings(label=msg.label,
                                 use_passphrase=msg.passphrase_protection)
    storage.recovery.set_in_progress(True)
    if msg.dry_run:
        storage.recovery.set_dry_run(msg.dry_run)

    workflow.replace_default(recovery_homescreen)
    return await recovery_process(ctx)