common: add SafetyCheckLevel to Features

pull/1277/head
Martin Milata 4 years ago committed by Tomas Susanka
parent 163ccedb39
commit 9f066e877d

@ -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;
}
}
/**

@ -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),
}

@ -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),
}

Loading…
Cancel
Save