diff --git a/src/apps/management/recovery_device.py b/src/apps/management/recovery_device.py index 41bfdde4..6c394901 100644 --- a/src/apps/management/recovery_device.py +++ b/src/apps/management/recovery_device.py @@ -24,7 +24,7 @@ async def recovery_device(ctx, msg): 4. Optionally ask for the PIN, with confirmation. 5. Save into storage. ''' - if storage.is_initialized(): + if not msg.dry_run and storage.is_initialized(): raise wire.FailureError(UnexpectedMessage, 'Already initialized') # ask for the number of words @@ -34,7 +34,7 @@ async def recovery_device(ctx, msg): mnemonic = await request_mnemonic(ctx, wordcount) # check mnemonic validity - if msg.enforce_wordlist: + if msg.enforce_wordlist or msg.dry_run: if not bip39.check(mnemonic): raise wire.FailureError(ProcessError, 'Mnemonic is not valid') @@ -50,8 +50,12 @@ async def recovery_device(ctx, msg): label=msg.label, use_passphrase=msg.passphrase_protection) storage.load_mnemonic( mnemonic=mnemonic, needs_backup=False) - - return Success() + return Success(message='Device recovered') + else: + if storage.get_mnemonic() == mnemonic: + return Success(message='The seed is valid and matches the one in the device') + else: + raise wire.FailureError(ProcessError, 'The seed is valid but does not match the one in the device') @ui.layout