mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-16 19:38:09 +00:00
src/apps/management: implement dry_run in recovery_device
This commit is contained in:
parent
1269a0239d
commit
01bb1e34fa
@ -24,7 +24,7 @@ async def recovery_device(ctx, msg):
|
|||||||
4. Optionally ask for the PIN, with confirmation.
|
4. Optionally ask for the PIN, with confirmation.
|
||||||
5. Save into storage.
|
5. Save into storage.
|
||||||
'''
|
'''
|
||||||
if storage.is_initialized():
|
if not msg.dry_run and storage.is_initialized():
|
||||||
raise wire.FailureError(UnexpectedMessage, 'Already initialized')
|
raise wire.FailureError(UnexpectedMessage, 'Already initialized')
|
||||||
|
|
||||||
# ask for the number of words
|
# ask for the number of words
|
||||||
@ -34,7 +34,7 @@ async def recovery_device(ctx, msg):
|
|||||||
mnemonic = await request_mnemonic(ctx, wordcount)
|
mnemonic = await request_mnemonic(ctx, wordcount)
|
||||||
|
|
||||||
# check mnemonic validity
|
# check mnemonic validity
|
||||||
if msg.enforce_wordlist:
|
if msg.enforce_wordlist or msg.dry_run:
|
||||||
if not bip39.check(mnemonic):
|
if not bip39.check(mnemonic):
|
||||||
raise wire.FailureError(ProcessError, 'Mnemonic is not valid')
|
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)
|
label=msg.label, use_passphrase=msg.passphrase_protection)
|
||||||
storage.load_mnemonic(
|
storage.load_mnemonic(
|
||||||
mnemonic=mnemonic, needs_backup=False)
|
mnemonic=mnemonic, needs_backup=False)
|
||||||
|
return Success(message='Device recovered')
|
||||||
return Success()
|
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
|
@ui.layout
|
||||||
|
Loading…
Reference in New Issue
Block a user