From 01bb1e34fad4bd0732b267d817f99602e315856f Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Wed, 28 Feb 2018 21:13:37 +0100 Subject: [PATCH] src/apps/management: implement dry_run in recovery_device --- src/apps/management/recovery_device.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/apps/management/recovery_device.py b/src/apps/management/recovery_device.py index 41bfdde40f..6c39490174 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