diff --git a/embed/extmod/modtrezorconfig/modtrezorconfig.c b/embed/extmod/modtrezorconfig/modtrezorconfig.c index dcbc0b40b..b6cfd6b50 100644 --- a/embed/extmod/modtrezorconfig/modtrezorconfig.c +++ b/embed/extmod/modtrezorconfig/modtrezorconfig.c @@ -65,20 +65,6 @@ STATIC mp_obj_t mod_trezorconfig_init(size_t n_args, const mp_obj_t *args) { STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_trezorconfig_init_obj, 0, 1, mod_trezorconfig_init); -/// def check_pin(pin: int) -> bool: -/// ''' -/// Check the given PIN. Returns True on success, False on failure. -/// ''' -STATIC mp_obj_t mod_trezorconfig_check_pin(mp_obj_t pin) { - uint32_t pin_i = trezor_obj_get_uint(pin); - if (sectrue != storage_unlock(pin_i)) { - return mp_const_false; - } - return mp_const_true; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_trezorconfig_check_pin_obj, - mod_trezorconfig_check_pin); - /// def unlock(pin: int) -> bool: /// ''' /// Attempts to unlock the storage with given PIN. Returns True on @@ -94,6 +80,16 @@ STATIC mp_obj_t mod_trezorconfig_unlock(mp_obj_t pin) { STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_trezorconfig_unlock_obj, mod_trezorconfig_unlock); +/// def check_pin(pin: int) -> bool: +/// ''' +/// Check the given PIN. Returns True on success, False on failure. +/// ''' +STATIC mp_obj_t mod_trezorconfig_check_pin(mp_obj_t pin) { + return mod_trezorconfig_unlock(pin); +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_trezorconfig_check_pin_obj, + mod_trezorconfig_check_pin); + /// def lock() -> None: /// ''' /// Locks the storage. diff --git a/src/apps/management/recovery_device.py b/src/apps/management/recovery_device.py index c62dd2301..0d050a24b 100644 --- a/src/apps/management/recovery_device.py +++ b/src/apps/management/recovery_device.py @@ -33,18 +33,27 @@ async def recovery_device(ctx, msg): if not msg.dry_run and storage.is_initialized(): raise wire.UnexpectedMessage("Already initialized") - text = Text("Device recovery", ui.ICON_RECOVERY) - text.normal("Do you really want to", "recover the device?", "") + if not msg.dry_run: + title = "Device recovery" + text = Text(title, ui.ICON_RECOVERY) + text.normal("Do you really want to", "recover the device?", "") + else: + title = "Simulated recovery" + text = Text(title, ui.ICON_RECOVERY) + text.normal("Do you really want to", "check the recovery", "seed?") await require_confirm(ctx, text, code=ProtectCall) - if msg.dry_run and config.has_pin(): - curpin = await request_pin_ack(ctx, "Enter PIN", config.get_pin_rem()) + if msg.dry_run: + if config.has_pin(): + curpin = await request_pin_ack(ctx, "Enter PIN", config.get_pin_rem()) + else: + curpin = "" if not config.check_pin(pin_to_int(curpin)): raise wire.PinInvalid("PIN invalid") # ask for the number of words - wordcount = await request_wordcount(ctx) + wordcount = await request_wordcount(ctx, title) # ask for mnemonic words one by one words = await request_mnemonic(ctx, wordcount) @@ -92,10 +101,10 @@ async def recovery_device(ctx, msg): @ui.layout -async def request_wordcount(ctx): +async def request_wordcount(ctx, title: str) -> int: await ctx.call(ButtonRequest(code=MnemonicWordCount), ButtonAck) - text = Text("Device recovery", ui.ICON_RECOVERY) + text = Text(title, ui.ICON_RECOVERY) text.normal("Number of words?") count = await ctx.wait(WordSelector(text))