1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 15:38:11 +00:00

python: add backup_type to reset device

This commit is contained in:
Tomas Susanka 2019-07-22 11:37:44 +02:00
parent 539379bd55
commit e663b7cb54
2 changed files with 13 additions and 5 deletions

View File

@ -113,6 +113,14 @@ CHOICE_OUTPUT_SCRIPT_TYPE = ChoiceType(
} }
) )
CHOICE_RESET_DEVICE_TYPE = ChoiceType(
{
"single": proto.ResetDeviceBackupType.Bip39,
"shamir": proto.ResetDeviceBackupType.Slip39_Single_Group,
"advanced": proto.ResetDeviceBackupType.Slip39_Multiple_Groups,
}
)
class UnderscoreAgnosticGroup(click.Group): class UnderscoreAgnosticGroup(click.Group):
"""Command group that normalizes dashes and underscores. """Command group that normalizes dashes and underscores.
@ -505,7 +513,7 @@ def recovery_device(
@click.option("-u", "--u2f-counter", default=0) @click.option("-u", "--u2f-counter", default=0)
@click.option("-s", "--skip-backup", is_flag=True) @click.option("-s", "--skip-backup", is_flag=True)
@click.option("-n", "--no-backup", is_flag=True) @click.option("-n", "--no-backup", is_flag=True)
@click.option("-x", "--slip39", is_flag=True) @click.option("-b", "--backup-type", type=CHOICE_RESET_DEVICE_TYPE, default="single")
@click.pass_obj @click.pass_obj
def reset_device( def reset_device(
connect, connect,
@ -517,7 +525,7 @@ def reset_device(
u2f_counter, u2f_counter,
skip_backup, skip_backup,
no_backup, no_backup,
slip39, backup_type,
): ):
if strength: if strength:
strength = int(strength) strength = int(strength)
@ -532,7 +540,7 @@ def reset_device(
u2f_counter=u2f_counter, u2f_counter=u2f_counter,
skip_backup=skip_backup, skip_backup=skip_backup,
no_backup=no_backup, no_backup=no_backup,
slip39=slip39, backup_type=backup_type,
) )

View File

@ -167,7 +167,7 @@ def reset(
u2f_counter=0, u2f_counter=0,
skip_backup=False, skip_backup=False,
no_backup=False, no_backup=False,
slip39=False, backup_type=proto.ResetDeviceBackupType.Bip39,
): ):
if client.features.initialized: if client.features.initialized:
raise RuntimeError( raise RuntimeError(
@ -191,7 +191,7 @@ def reset(
u2f_counter=u2f_counter, u2f_counter=u2f_counter,
skip_backup=bool(skip_backup), skip_backup=bool(skip_backup),
no_backup=bool(no_backup), no_backup=bool(no_backup),
slip39=bool(slip39), backup_type=backup_type,
) )
resp = client.call(msg) resp = client.call(msg)