diff --git a/trezorctl b/trezorctl index e3f859aa48..ec5a18478e 100755 --- a/trezorctl +++ b/trezorctl @@ -441,22 +441,20 @@ def recovery_device( return device.recover( connect(), - int(words), - passphrase_protection, - pin_protection, - label, - "english", - input_callback, - rec_type, - dry_run, + word_count=int(words), + passphrase_protection=passphrase_protection, + pin_protection=pin_protection, + label=label, + language="english", + input_callback=input_callback, + type=rec_type, + dry_run=dry_run, ) @cli.command(help="Perform device setup and generate new seed.") -@click.option("-e", "--entropy", is_flag=True) -@click.option( - "-t", "--strength", type=click.Choice(["128", "192", "256"]), default="256" -) +@click.option("-e", "--show-entropy", is_flag=True) +@click.option("-t", "--strength", type=click.Choice(["128", "192", "256"])) @click.option("-r", "--passphrase-protection", is_flag=True) @click.option("-p", "--pin-protection", is_flag=True) @click.option("-l", "--label") @@ -466,7 +464,7 @@ def recovery_device( @click.pass_obj def reset_device( connect, - entropy, + show_entropy, strength, passphrase_protection, pin_protection, @@ -475,17 +473,19 @@ def reset_device( skip_backup, no_backup, ): + if strength: + strength = int(strength) return device.reset( connect(), - entropy, - int(strength), - passphrase_protection, - pin_protection, - label, - "english", - u2f_counter, - skip_backup, - no_backup, + display_random=show_entropy, + strength=strength, + passphrase_protection=passphrase_protection, + pin_protection=pin_protection, + label=label, + language="english", + u2f_counter=u2f_counter, + skip_backup=skip_backup, + no_backup=no_backup, ) diff --git a/trezorlib/device.py b/trezorlib/device.py index afff38001a..5e9cd48c57 100644 --- a/trezorlib/device.py +++ b/trezorlib/device.py @@ -102,15 +102,18 @@ def wipe(client): @expect(proto.Success, field="message") def recover( client, - word_count, - passphrase_protection, - pin_protection, - label, - language, - input_callback, + word_count=24, + passphrase_protection=False, + pin_protection=True, + label=None, + language="english", + input_callback=None, type=proto.RecoveryDeviceType.ScrambledWords, dry_run=False, ): + if client.features.model == "1" and input_callback is None: + raise RuntimeError("Input callback required for Trezor One") + if word_count not in (12, 18, 24): raise ValueError("Invalid word count. Use 12/18/24") @@ -121,7 +124,7 @@ def recover( res = client.call( proto.RecoveryDevice( - word_count=int(word_count), + word_count=word_count, passphrase_protection=bool(passphrase_protection), pin_protection=bool(pin_protection), label=label, @@ -147,12 +150,12 @@ def recover( @session def reset( client, - display_random, - strength, - passphrase_protection, - pin_protection, - label, - language, + display_random=False, + strength=None, + passphrase_protection=False, + pin_protection=True, + label=None, + language="english", u2f_counter=0, skip_backup=False, no_backup=False, @@ -162,9 +165,15 @@ def reset( "Device is initialized already. Call wipe_device() and try again." ) + if strength is None: + if client.features.model == "1": + strength = 256 + else: + strength = 128 + # Begin with device reset workflow msg = proto.ResetDevice( - display_random=display_random, + display_random=bool(display_random), strength=strength, passphrase_protection=bool(passphrase_protection), pin_protection=bool(pin_protection),