From 35c3af87ddae0df5b61735d55a3a3a71e50a2e43 Mon Sep 17 00:00:00 2001 From: matejcik Date: Wed, 5 Aug 2020 15:51:53 +0200 Subject: [PATCH] python: rename unsafe_prompts to safety_checks --- python/CHANGELOG.md | 2 +- python/docs/OPTIONS.rst | 2 +- python/src/trezorlib/cli/settings.py | 25 +++++++++++++------------ 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/python/CHANGELOG.md b/python/CHANGELOG.md index b4be33d9a..e309ce05f 100644 --- a/python/CHANGELOG.md +++ b/python/CHANGELOG.md @@ -11,7 +11,7 @@ _At the moment, the project does **not** adhere to [Semantic Versioning](https:/ ### Added -- `trezorctl set unsafe-prompts` controls the new "unsafe prompts" feature. [#1126] +- `trezorctl set safety-checks` controls the new "safety checks" feature. [#1126] - `trezorctl btc get-address` can create multisig addresses. - the following commands are now equivalent in trezorctl: `firmware-update`, `firmware-upgrade`, `update-firmware`, `upgrade-firmware` diff --git a/python/docs/OPTIONS.rst b/python/docs/OPTIONS.rst index fb38a1686..83de6c6c8 100644 --- a/python/docs/OPTIONS.rst +++ b/python/docs/OPTIONS.rst @@ -383,7 +383,7 @@ Device settings. label Set new device label. passphrase Enable, disable or configure passphrase protection. pin Set, change or remove PIN. - unsafe-prompts Allow or disallow unsafe prompts. + safety-checks Set safety check level. wipe-code Set or remove the wipe code. Stellar commands. diff --git a/python/src/trezorlib/cli/settings.py b/python/src/trezorlib/cli/settings.py index 9c3670dc4..60a507721 100644 --- a/python/src/trezorlib/cli/settings.py +++ b/python/src/trezorlib/cli/settings.py @@ -20,6 +20,10 @@ from .. import device, messages from . import ChoiceType, with_client ROTATION = {"north": 0, "east": 90, "south": 180, "west": 270} +SAFETY_LEVELS = { + "strict": messages.SafetyCheckLevel.Strict, + "prompt": messages.SafetyCheckLevel.Prompt, +} @click.group(name="set") @@ -136,21 +140,18 @@ def homescreen(client, filename): @cli.command() -@click.argument("allow", type=click.Choice(("on", "off"))) +@click.argument("level", type=ChoiceType(SAFETY_LEVELS)) @with_client -def unsafe_prompts(client, allow): - """Allow or disallow unsafe prompts. +def safety_checks(client, level): + """Set safety check level. - This is a power-user feature. With unsafe prompts enabled, Trezor will ask the user - to confirm possibly dangerous actions instead of rejecting them outright. - Use with caution. - """ - # TODO change this to ChoiceType - if allow == "on": - level = messages.SafetyCheckLevel.Prompt - else: - level = messages.SafetyCheckLevel.Strict + Set to "strict" to get the full Trezor security. + Set to "prompt" if you want to be able to allow potentially unsafe actions, such as + mismatching coin keys or extreme fees. + + This is a power-user feature. Use with caution. + """ return device.apply_settings(client, safety_checks=level)