From 9f066e877da088e01e10e3941a4bcebcad3fe7e3 Mon Sep 17 00:00:00 2001 From: Martin Milata Date: Wed, 2 Sep 2020 13:07:56 +0200 Subject: [PATCH] common: add SafetyCheckLevel to Features --- common/protob/messages-management.proto | 14 +++++++++----- core/src/trezor/messages/Features.py | 4 ++++ python/src/trezorlib/messages/Features.py | 4 ++++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/common/protob/messages-management.proto b/common/protob/messages-management.proto index 64cecea98..d79601e9e 100644 --- a/common/protob/messages-management.proto +++ b/common/protob/messages-management.proto @@ -14,6 +14,14 @@ enum BackupType { Slip39_Advanced = 2; // also called "Super Shamir" or "Shamir with Groups", see SLIP-0039#two-level-scheme } +/** + * Level of safety checks for unsafe actions like spending from invalid path namespace or setting high transaction fee. + */ +enum SafetyCheckLevel { + Strict = 0; // disallow unsafe actions + Prompt = 1; // ask user before unsafe action +} + /** * Request: Reset device to default state and ask for device details * @start @@ -90,6 +98,7 @@ message Features { optional bool wipe_code_protection = 34; // is wipe code protection enabled optional bytes session_id = 35; optional bool passphrase_always_on_device = 36; // device enforces passphrase entry on Trezor + optional SafetyCheckLevel safety_checks = 37; // safety check level, set to Prompt to limit path namespace enforcement } /** @@ -126,11 +135,6 @@ message ApplySettings { optional uint32 display_rotation = 7; // in degrees from North optional bool passphrase_always_on_device = 8; // do not prompt for passphrase, enforce device entry optional SafetyCheckLevel safety_checks = 9; // Safety check level, set to Prompt to limit path namespace enforcement - - enum SafetyCheckLevel { - Strict = 0; - Prompt = 1; - } } /** diff --git a/core/src/trezor/messages/Features.py b/core/src/trezor/messages/Features.py index 6ba3c39e6..c7f890152 100644 --- a/core/src/trezor/messages/Features.py +++ b/core/src/trezor/messages/Features.py @@ -8,6 +8,7 @@ if __debug__: from typing_extensions import Literal # noqa: F401 EnumTypeCapability = Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17] EnumTypeBackupType = Literal[0, 1, 2] + EnumTypeSafetyCheckLevel = Literal[0, 1] except ImportError: pass @@ -51,6 +52,7 @@ class Features(p.MessageType): wipe_code_protection: bool = None, session_id: bytes = None, passphrase_always_on_device: bool = None, + safety_checks: EnumTypeSafetyCheckLevel = None, ) -> None: self.vendor = vendor self.major_version = major_version @@ -86,6 +88,7 @@ class Features(p.MessageType): self.wipe_code_protection = wipe_code_protection self.session_id = session_id self.passphrase_always_on_device = passphrase_always_on_device + self.safety_checks = safety_checks @classmethod def get_fields(cls) -> Dict: @@ -124,4 +127,5 @@ class Features(p.MessageType): 34: ('wipe_code_protection', p.BoolType, 0), 35: ('session_id', p.BytesType, 0), 36: ('passphrase_always_on_device', p.BoolType, 0), + 37: ('safety_checks', p.EnumType("SafetyCheckLevel", (0, 1)), 0), } diff --git a/python/src/trezorlib/messages/Features.py b/python/src/trezorlib/messages/Features.py index 47d1c9a40..821f8c2b5 100644 --- a/python/src/trezorlib/messages/Features.py +++ b/python/src/trezorlib/messages/Features.py @@ -8,6 +8,7 @@ if __debug__: from typing_extensions import Literal # noqa: F401 EnumTypeCapability = Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17] EnumTypeBackupType = Literal[0, 1, 2] + EnumTypeSafetyCheckLevel = Literal[0, 1] except ImportError: pass @@ -51,6 +52,7 @@ class Features(p.MessageType): wipe_code_protection: bool = None, session_id: bytes = None, passphrase_always_on_device: bool = None, + safety_checks: EnumTypeSafetyCheckLevel = None, ) -> None: self.vendor = vendor self.major_version = major_version @@ -86,6 +88,7 @@ class Features(p.MessageType): self.wipe_code_protection = wipe_code_protection self.session_id = session_id self.passphrase_always_on_device = passphrase_always_on_device + self.safety_checks = safety_checks @classmethod def get_fields(cls) -> Dict: @@ -124,4 +127,5 @@ class Features(p.MessageType): 34: ('wipe_code_protection', p.BoolType, 0), 35: ('session_id', p.BytesType, 0), 36: ('passphrase_always_on_device', p.BoolType, 0), + 37: ('safety_checks', p.EnumType("SafetyCheckLevel", (0, 1)), 0), }