1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-18 20:38:10 +00:00

chore(core): rename recovery type & kind and tweak feature flags

This commit is contained in:
Ioan Bizău 2024-05-23 16:09:16 +02:00 committed by Ioan Bizău
parent 49daeaa746
commit 8870869f93
55 changed files with 784 additions and 609 deletions

View File

@ -81,7 +81,7 @@ message Features {
optional bool unlocked = 16; // is the device unlocked? called "pin_cached" previously optional bool unlocked = 16; // is the device unlocked? called "pin_cached" previously
optional bool _passphrase_cached = 17 [deprecated=true]; // is passphrase already cached in session? optional bool _passphrase_cached = 17 [deprecated=true]; // is passphrase already cached in session?
optional bool firmware_present = 18; // is valid firmware loaded? optional bool firmware_present = 18; // is valid firmware loaded?
optional bool needs_backup = 19; // does storage need backup? (equals to Storage.needs_backup) optional BackupAvailability backup_availability = 19; // does storage need backup? is repeated backup unlocked?
optional uint32 flags = 20; // device flags (equals to Storage.flags) optional uint32 flags = 20; // device flags (equals to Storage.flags)
optional string model = 21; // device hardware model optional string model = 21; // device hardware model
optional uint32 fw_major = 22; // reported firmware version if in bootloader mode optional uint32 fw_major = 22; // reported firmware version if in bootloader mode
@ -107,20 +107,29 @@ message Features {
optional HomescreenFormat homescreen_format = 42; // format of the homescreen, 1 = TOIf, 2 = jpg, 3 = TOIG optional HomescreenFormat homescreen_format = 42; // format of the homescreen, 1 = TOIf, 2 = jpg, 3 = TOIG
optional bool hide_passphrase_from_host = 43; // should we hide the passphrase when it comes from host? optional bool hide_passphrase_from_host = 43; // should we hide the passphrase when it comes from host?
optional string internal_model = 44; // internal model name optional string internal_model = 44; // internal model name
optional uint32 unit_color = 45; // color of the unit/device optional uint32 unit_color = 45; // color of the unit/device
optional bool unit_btconly = 46; // unit/device is intended as bitcoin only optional bool unit_btconly = 46; // unit/device is intended as bitcoin only
optional uint32 homescreen_width = 47; // homescreen width in pixels optional uint32 homescreen_width = 47; // homescreen width in pixels
optional uint32 homescreen_height = 48; // homescreen height in pixels optional uint32 homescreen_height = 48; // homescreen height in pixels
optional bool bootloader_locked = 49; // bootloader is locked optional bool bootloader_locked = 49; // bootloader is locked
optional bool language_version_matches = 50 [default=true]; // translation blob version matches firmware version optional bool language_version_matches = 50 [default=true]; // translation blob version matches firmware version
optional uint32 unit_packaging = 51; // unit/device packaging version optional uint32 unit_packaging = 51; // unit/device packaging version
optional bool haptic_feedback = 52; // haptic feedback is enabled optional bool haptic_feedback = 52; // haptic feedback is enabled
optional RecoveryType recovery_type = 53; // what type of recovery we are in. NB: this works in conjunction with recovery_status
enum BackupAvailability {
/// Device is already backed up, or a previous backup has failed.
NotAvailable = 0;
/// Device is not backed up. Backup is required.
Required = 1;
/// Device is already backed up and can be backed up again.
Available = 2;
}
enum RecoveryStatus { enum RecoveryStatus {
NoRecovery = 0; Nothing = 0; // we are not in recovery mode
InNormalRecovery = 1; Recovery = 1; // we are in "Normal" or "DryRun" recovery
InDryRunRecovery = 2; Backup = 2; // we are in repeated backup mode
InUnlockRepeatedBackupRecovery = 3;
} }
enum Capability { enum Capability {
@ -449,28 +458,28 @@ message RecoveryDevice {
optional string label = 5; // device label optional string label = 5; // device label
optional bool enforce_wordlist = 6; // enforce BIP-39 wordlist during the process (T1 only) optional bool enforce_wordlist = 6; // enforce BIP-39 wordlist during the process (T1 only)
reserved 7; // unused recovery method reserved 7; // unused recovery method
optional RecoveryDeviceType type = 8; // supported recovery type (T1 only) optional RecoveryDeviceInputMethod input_method = 8; // supported recovery input method (T1 only)
optional uint32 u2f_counter = 9; // U2F counter optional uint32 u2f_counter = 9; // U2F counter
optional RecoveryKind kind = 10 [default=NormalRecovery]; // the kind of recovery to perform optional RecoveryType type = 10 [default=NormalRecovery]; // the type of recovery to perform
/** /**
* Type of recovery procedure. These should be used as bitmask, e.g., * Type of recovery procedure. These should be used as bitmask, e.g.,
* `RecoveryDeviceType_ScrambledWords | RecoveryDeviceType_Matrix` * `RecoveryDeviceInputMethod_ScrambledWords | RecoveryDeviceInputMethod_Matrix`
* listing every method supported by the host computer. * listing every method supported by the host computer.
* *
* Note that ScrambledWords must be supported by every implementation * Note that ScrambledWords must be supported by every implementation
* for backward compatibility; there is no way to not support it. * for backward compatibility; there is no way to not support it.
*/ */
enum RecoveryDeviceType { enum RecoveryDeviceInputMethod {
// use powers of two when extending this field // use powers of two when extending this field
RecoveryDeviceType_ScrambledWords = 0; // words in scrambled order ScrambledWords = 0; // words in scrambled order
RecoveryDeviceType_Matrix = 1; // matrix recovery type Matrix = 1; // matrix recovery type
} }
}
enum RecoveryKind { enum RecoveryType {
NormalRecovery = 0; // recovery from seedphrase on an uninitialized device NormalRecovery = 0; // recovery from seedphrase on an uninitialized device
DryRun = 1; // mnemonic validation DryRun = 1; // mnemonic validation
UnlockRepeatedBackup = 2; // unlock SLIP-39 repeated backup UnlockRepeatedBackup = 2; // unlock SLIP-39 repeated backup
}
} }
/** /**

View File

@ -293,7 +293,6 @@ static void _librust_qstrs(void) {
MP_QSTR_joint__title; MP_QSTR_joint__title;
MP_QSTR_joint__to_the_total_amount; MP_QSTR_joint__to_the_total_amount;
MP_QSTR_joint__you_are_contributing; MP_QSTR_joint__you_are_contributing;
MP_QSTR_kind;
MP_QSTR_label; MP_QSTR_label;
MP_QSTR_language; MP_QSTR_language;
MP_QSTR_language__change_to_template; MP_QSTR_language__change_to_template;
@ -454,6 +453,7 @@ static void _librust_qstrs(void) {
MP_QSTR_recovery__x_more_shares_needed_template_plural; MP_QSTR_recovery__x_more_shares_needed_template_plural;
MP_QSTR_recovery__x_of_y_entered_template; MP_QSTR_recovery__x_of_y_entered_template;
MP_QSTR_recovery__you_have_entered; MP_QSTR_recovery__you_have_entered;
MP_QSTR_recovery_type;
MP_QSTR_request_bip39; MP_QSTR_request_bip39;
MP_QSTR_request_complete_repaint; MP_QSTR_request_complete_repaint;
MP_QSTR_request_number; MP_QSTR_request_number;

View File

@ -1331,7 +1331,7 @@ pub enum TranslatedString {
reset__slip39_checklist_num_groups_x_template = 931, // "Number of groups: {0}" reset__slip39_checklist_num_groups_x_template = 931, // "Number of groups: {0}"
brightness__title = 932, // "Set brightness" brightness__title = 932, // "Set brightness"
recovery__title_unlock_repeated_backup = 933, // "Multi-share backup" recovery__title_unlock_repeated_backup = 933, // "Multi-share backup"
recovery__unlock_repeated_backup = 934, // "Do you want to unlock the seed for repeated backup?" recovery__unlock_repeated_backup = 934, // "Create additional backup?"
recovery__unlock_repeated_backup_verb = 935, // "Unlock backup" recovery__unlock_repeated_backup_verb = 935, // "Unlock backup"
} }
@ -2659,7 +2659,7 @@ impl TranslatedString {
Self::reset__slip39_checklist_num_groups_x_template => "Number of groups: {0}", Self::reset__slip39_checklist_num_groups_x_template => "Number of groups: {0}",
Self::brightness__title => "Set brightness", Self::brightness__title => "Set brightness",
Self::recovery__title_unlock_repeated_backup => "Multi-share backup", Self::recovery__title_unlock_repeated_backup => "Multi-share backup",
Self::recovery__unlock_repeated_backup => "Do you want to unlock the seed for repeated backup?", Self::recovery__unlock_repeated_backup => "Create additional backup?",
Self::recovery__unlock_repeated_backup_verb => "Unlock backup", Self::recovery__unlock_repeated_backup_verb => "Unlock backup",
} }
} }

View File

@ -228,8 +228,8 @@ impl ComponentMsgObj for super::component::bl_confirm::Confirm<'_> {
} }
} }
const RECOVERY_KIND_DRY_RUN: u32 = 1; const RECOVERY_TYPE_DRY_RUN: u32 = 1;
const RECOVERY_KIND_UNLOCK_REPEATED_BACKUP: u32 = 2; const RECOVERY_TYPE_UNLOCK_REPEATED_BACKUP: u32 = 2;
/// Function to create and call a `ButtonPage` dialog based on paginable content /// Function to create and call a `ButtonPage` dialog based on paginable content
/// (e.g. `Paragraphs` or `FormattedText`). /// (e.g. `Paragraphs` or `FormattedText`).
@ -1398,7 +1398,7 @@ extern "C" fn new_confirm_recovery(n_args: usize, args: *const Obj, kwargs: *mut
let block = move |_args: &[Obj], kwargs: &Map| { let block = move |_args: &[Obj], kwargs: &Map| {
let description: TString = kwargs.get(Qstr::MP_QSTR_description)?.try_into()?; let description: TString = kwargs.get(Qstr::MP_QSTR_description)?.try_into()?;
let button: TString<'static> = kwargs.get(Qstr::MP_QSTR_button)?.try_into()?; let button: TString<'static> = kwargs.get(Qstr::MP_QSTR_button)?.try_into()?;
let kind: u32 = kwargs.get(Qstr::MP_QSTR_kind)?.try_into()?; let recovery_type: u32 = kwargs.get(Qstr::MP_QSTR_recovery_type)?.try_into()?;
let show_info: bool = kwargs.get(Qstr::MP_QSTR_show_info)?.try_into()?; let show_info: bool = kwargs.get(Qstr::MP_QSTR_show_info)?.try_into()?;
let mut paragraphs = ParagraphVecShort::new(); let mut paragraphs = ParagraphVecShort::new();
@ -1415,9 +1415,9 @@ extern "C" fn new_confirm_recovery(n_args: usize, args: *const Obj, kwargs: *mut
)); ));
} }
let title = match kind { let title = match recovery_type {
RECOVERY_KIND_DRY_RUN => TR::recovery__title_dry_run, RECOVERY_TYPE_DRY_RUN => TR::recovery__title_dry_run,
RECOVERY_KIND_UNLOCK_REPEATED_BACKUP => TR::recovery__title_unlock_repeated_backup, RECOVERY_TYPE_UNLOCK_REPEATED_BACKUP => TR::recovery__title_dry_run,
_ => TR::recovery__title, _ => TR::recovery__title,
}; };
@ -1968,7 +1968,7 @@ pub static mp_module_trezorui2: Module = obj_module! {
/// title: str, # unused on TR /// title: str, # unused on TR
/// description: str, /// description: str,
/// button: str, /// button: str,
/// kind: int, # RecoveryKind enum, passed as an int /// recovery_type: RecoveryType,
/// info_button: bool, # unused on TR /// info_button: bool, # unused on TR
/// show_info: bool, /// show_info: bool,
/// ) -> LayoutObj[UiResult]: /// ) -> LayoutObj[UiResult]:
@ -1977,7 +1977,7 @@ pub static mp_module_trezorui2: Module = obj_module! {
/// def select_word_count( /// def select_word_count(
/// *, /// *,
/// dry_run: bool, # unused on TR /// recovery_type: RecoveryType, # unused on TR
/// ) -> LayoutObj[int | str]: /// ) -> LayoutObj[int | str]:
/// """Select mnemonic word count from (12, 18, 20, 24, 33).""" /// """Select mnemonic word count from (12, 18, 20, 24, 33)."""
Qstr::MP_QSTR_select_word_count => obj_fn_kw!(0, new_select_word_count).as_obj(), Qstr::MP_QSTR_select_word_count => obj_fn_kw!(0, new_select_word_count).as_obj(),

View File

@ -310,8 +310,8 @@ impl ComponentMsgObj for super::component::bl_confirm::Confirm<'_> {
} }
} }
const RECOVERY_KIND_DRY_RUN: u32 = 1; const RECOVERY_TYPE_DRY_RUN: u32 = 1;
const RECOVERY_KIND_UNLOCK_REPEATED_BACKUP: u32 = 2; const RECOVERY_TYPE_UNLOCK_REPEATED_BACKUP: u32 = 2;
extern "C" fn new_confirm_action(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj { extern "C" fn new_confirm_action(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj {
let block = move |_args: &[Obj], kwargs: &Map| { let block = move |_args: &[Obj], kwargs: &Map| {
@ -1368,7 +1368,7 @@ extern "C" fn new_confirm_recovery(n_args: usize, args: *const Obj, kwargs: *mut
let title: TString = kwargs.get(Qstr::MP_QSTR_title)?.try_into()?; let title: TString = kwargs.get(Qstr::MP_QSTR_title)?.try_into()?;
let description: TString = kwargs.get(Qstr::MP_QSTR_description)?.try_into()?; let description: TString = kwargs.get(Qstr::MP_QSTR_description)?.try_into()?;
let button: TString = kwargs.get(Qstr::MP_QSTR_button)?.try_into()?; let button: TString = kwargs.get(Qstr::MP_QSTR_button)?.try_into()?;
let kind: u32 = kwargs.get(Qstr::MP_QSTR_kind)?.try_into()?; let recovery_type: u32 = kwargs.get(Qstr::MP_QSTR_recovery_type)?.try_into()?;
let info_button: bool = kwargs.get_or(Qstr::MP_QSTR_info_button, false)?; let info_button: bool = kwargs.get_or(Qstr::MP_QSTR_info_button, false)?;
let paragraphs = Paragraphs::new([ let paragraphs = Paragraphs::new([
@ -1377,11 +1377,9 @@ extern "C" fn new_confirm_recovery(n_args: usize, args: *const Obj, kwargs: *mut
]) ])
.with_spacing(theme::RECOVERY_SPACING); .with_spacing(theme::RECOVERY_SPACING);
let notification = match kind { let notification = match recovery_type {
RECOVERY_KIND_DRY_RUN => TR::recovery__title_dry_run.into(), RECOVERY_TYPE_DRY_RUN => TR::recovery__title_dry_run.into(),
RECOVERY_KIND_UNLOCK_REPEATED_BACKUP => { RECOVERY_TYPE_UNLOCK_REPEATED_BACKUP => TR::recovery__title_dry_run.into(),
TR::recovery__title_unlock_repeated_backup.into()
}
_ => TR::recovery__title.into(), _ => TR::recovery__title.into(),
}; };
@ -1411,11 +1409,11 @@ extern "C" fn new_confirm_recovery(n_args: usize, args: *const Obj, kwargs: *mut
extern "C" fn new_select_word_count(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj { extern "C" fn new_select_word_count(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj {
let block = move |_args: &[Obj], kwargs: &Map| { let block = move |_args: &[Obj], kwargs: &Map| {
let dry_run: bool = kwargs.get(Qstr::MP_QSTR_dry_run)?.try_into()?; let recovery_type: u32 = kwargs.get(Qstr::MP_QSTR_recovery_type)?.try_into()?;
let title: TString = if dry_run { let title: TString = match recovery_type {
TR::recovery__title_dry_run.into() RECOVERY_TYPE_DRY_RUN => TR::recovery__title_dry_run.into(),
} else { RECOVERY_TYPE_UNLOCK_REPEATED_BACKUP => TR::recovery__title_dry_run.into(),
TR::recovery__title.into() _ => TR::recovery__title.into(),
}; };
let paragraphs = Paragraphs::new(Paragraph::new( let paragraphs = Paragraphs::new(Paragraph::new(
@ -2047,7 +2045,7 @@ pub static mp_module_trezorui2: Module = obj_module! {
/// title: str, /// title: str,
/// description: str, /// description: str,
/// button: str, /// button: str,
/// kind: int, # RecoveryKind enum, passed as an int /// recovery_type: RecoveryType,
/// info_button: bool = False, /// info_button: bool = False,
/// ) -> LayoutObj[UiResult]: /// ) -> LayoutObj[UiResult]:
/// """Device recovery homescreen.""" /// """Device recovery homescreen."""
@ -2055,7 +2053,7 @@ pub static mp_module_trezorui2: Module = obj_module! {
/// def select_word_count( /// def select_word_count(
/// *, /// *,
/// dry_run: bool, /// recovery_type: RecoveryType,
/// ) -> LayoutObj[int | str]: # TT returns int /// ) -> LayoutObj[int | str]: # TT returns int
/// """Select mnemonic word count from (12, 18, 20, 24, 33).""" /// """Select mnemonic word count from (12, 18, 20, 24, 33)."""
Qstr::MP_QSTR_select_word_count => obj_fn_kw!(0, new_select_word_count).as_obj(), Qstr::MP_QSTR_select_word_count => obj_fn_kw!(0, new_select_word_count).as_obj(),

View File

@ -980,7 +980,7 @@ def confirm_recovery(
title: str, # unused on TR title: str, # unused on TR
description: str, description: str,
button: str, button: str,
kind: int, # RecoveryKind enum, passed as an int recovery_type: RecoveryType,
info_button: bool, # unused on TR info_button: bool, # unused on TR
show_info: bool, show_info: bool,
) -> LayoutObj[UiResult]: ) -> LayoutObj[UiResult]:
@ -990,7 +990,7 @@ def confirm_recovery(
# rust/src/ui/model_tr/layout.rs # rust/src/ui/model_tr/layout.rs
def select_word_count( def select_word_count(
*, *,
dry_run: bool, # unused on TR recovery_type: RecoveryType, # unused on TR
) -> LayoutObj[int | str]: ) -> LayoutObj[int | str]:
"""Select mnemonic word count from (12, 18, 20, 24, 33).""" """Select mnemonic word count from (12, 18, 20, 24, 33)."""
@ -1515,7 +1515,7 @@ def confirm_recovery(
title: str, title: str,
description: str, description: str,
button: str, button: str,
kind: int, # RecoveryKind enum, passed as an int recovery_type: RecoveryType,
info_button: bool = False, info_button: bool = False,
) -> LayoutObj[UiResult]: ) -> LayoutObj[UiResult]:
"""Device recovery homescreen.""" """Device recovery homescreen."""
@ -1524,7 +1524,7 @@ def confirm_recovery(
# rust/src/ui/model_tt/layout.rs # rust/src/ui/model_tt/layout.rs
def select_word_count( def select_word_count(
*, *,
dry_run: bool, recovery_type: RecoveryType,
) -> LayoutObj[int | str]: # TT returns int ) -> LayoutObj[int | str]: # TT returns int
"""Select mnemonic word count from (12, 18, 20, 24, 33).""" """Select mnemonic word count from (12, 18, 20, 24, 33)."""

View File

@ -585,7 +585,7 @@ class TR:
recovery__title_remaining_shares: str = "Remaining shares" recovery__title_remaining_shares: str = "Remaining shares"
recovery__title_unlock_repeated_backup: str = "Multi-share backup" recovery__title_unlock_repeated_backup: str = "Multi-share backup"
recovery__type_word_x_of_y_template: str = "Type word {0} of {1}" recovery__type_word_x_of_y_template: str = "Type word {0} of {1}"
recovery__unlock_repeated_backup: str = "Do you want to unlock the seed for repeated backup?" recovery__unlock_repeated_backup: str = "Create additional backup?"
recovery__unlock_repeated_backup_verb: str = "Unlock backup" recovery__unlock_repeated_backup_verb: str = "Unlock backup"
recovery__wallet_recovered: str = "Wallet recovery completed" recovery__wallet_recovered: str = "Wallet recovery completed"
recovery__wanna_cancel_dry_run: str = "Are you sure you want to cancel the backup check?" recovery__wanna_cancel_dry_run: str = "Are you sure you want to cancel the backup check?"

View File

@ -91,6 +91,8 @@ trezor.crypto.slip39
import trezor.crypto.slip39 import trezor.crypto.slip39
trezor.enums.AmountUnit trezor.enums.AmountUnit
import trezor.enums.AmountUnit import trezor.enums.AmountUnit
trezor.enums.BackupAvailability
import trezor.enums.BackupAvailability
trezor.enums.BackupType trezor.enums.BackupType
import trezor.enums.BackupType import trezor.enums.BackupType
trezor.enums.BootCommand trezor.enums.BootCommand
@ -119,12 +121,12 @@ trezor.enums.OutputScriptType
import trezor.enums.OutputScriptType import trezor.enums.OutputScriptType
trezor.enums.PinMatrixRequestType trezor.enums.PinMatrixRequestType
import trezor.enums.PinMatrixRequestType import trezor.enums.PinMatrixRequestType
trezor.enums.RecoveryDeviceType trezor.enums.RecoveryDeviceInputMethod
import trezor.enums.RecoveryDeviceType import trezor.enums.RecoveryDeviceInputMethod
trezor.enums.RecoveryKind
import trezor.enums.RecoveryKind
trezor.enums.RecoveryStatus trezor.enums.RecoveryStatus
import trezor.enums.RecoveryStatus import trezor.enums.RecoveryStatus
trezor.enums.RecoveryType
import trezor.enums.RecoveryType
trezor.enums.RequestType trezor.enums.RequestType
import trezor.enums.RequestType import trezor.enums.RequestType
trezor.enums.SafetyCheckLevel trezor.enums.SafetyCheckLevel

View File

@ -61,11 +61,11 @@ def _language_version_matches() -> bool | None:
def get_features() -> Features: def get_features() -> Features:
import storage.recovery as storage_recovery import storage.recovery as storage_recovery
from trezor import translations from trezor import translations
from trezor.enums import Capability, RecoveryKind, RecoveryStatus from trezor.enums import BackupAvailability, Capability, RecoveryStatus
from trezor.messages import Features from trezor.messages import Features
from trezor.ui import HEIGHT, WIDTH from trezor.ui import HEIGHT, WIDTH
from apps.common import mnemonic, safety_checks from apps.common import backup, mnemonic, safety_checks
v_major, v_minor, v_patch, _v_build = utils.VERSION v_major, v_minor, v_patch, _v_build = utils.VERSION
@ -157,20 +157,22 @@ def get_features() -> Features:
if config.is_unlocked(): if config.is_unlocked():
# passphrase_protection is private, see #1807 # passphrase_protection is private, see #1807
f.passphrase_protection = storage_device.is_passphrase_enabled() f.passphrase_protection = storage_device.is_passphrase_enabled()
f.needs_backup = storage_device.needs_backup() if storage_device.needs_backup():
f.backup_availability = BackupAvailability.Required
elif backup.repeated_backup_enabled():
f.backup_availability = BackupAvailability.Available
else:
f.backup_availability = BackupAvailability.NotAvailable
f.unfinished_backup = storage_device.unfinished_backup() f.unfinished_backup = storage_device.unfinished_backup()
f.no_backup = storage_device.no_backup() f.no_backup = storage_device.no_backup()
f.flags = storage_device.get_flags() f.flags = storage_device.get_flags()
if storage_recovery.is_in_progress(): if storage_recovery.is_in_progress():
kind = storage_recovery.get_kind() f.recovery_status = RecoveryStatus.Recovery
if kind == RecoveryKind.NormalRecovery: f.recovery_type = storage_recovery.get_type()
f.recovery_status = RecoveryStatus.InNormalRecovery elif backup.repeated_backup_enabled():
elif kind == RecoveryKind.DryRun: f.recovery_status = RecoveryStatus.Backup
f.recovery_status = RecoveryStatus.InDryRunRecovery
elif kind == RecoveryKind.UnlockRepeatedBackup:
f.recovery_status = RecoveryStatus.InUnlockRepeatedBackupRecovery
else: else:
f.recovery_status = RecoveryStatus.NoRecovery f.recovery_status = RecoveryStatus.Nothing
f.backup_type = mnemonic.get_type() f.backup_type = mnemonic.get_type()
# Only some models are capable of SD card # Only some models are capable of SD card
@ -417,7 +419,7 @@ async def unlock_device() -> None:
_SCREENSAVER_IS_ON = False _SCREENSAVER_IS_ON = False
set_homescreen() set_homescreen()
wire.filters.remove(_pinlock_filter) wire.remove_filter(_pinlock_filter)
def _pinlock_filter(msg_type: int, prev_handler: Handler[Msg]) -> Handler[Msg]: def _pinlock_filter(msg_type: int, prev_handler: Handler[Msg]) -> Handler[Msg]:
@ -431,30 +433,6 @@ def _pinlock_filter(msg_type: int, prev_handler: Handler[Msg]) -> Handler[Msg]:
return wrapper return wrapper
_ALLOW_WHILE_REPEATED_BACKUP_UNLOCKED = (
MessageType.Initialize,
MessageType.GetFeatures,
MessageType.EndSession,
MessageType.BackupDevice,
MessageType.WipeDevice,
MessageType.Cancel,
)
def _repeated_backup_filter(msg_type: int, prev_handler: Handler[Msg]) -> Handler[Msg]:
if msg_type in _ALLOW_WHILE_REPEATED_BACKUP_UNLOCKED:
return prev_handler
else:
raise wire.ProcessError("Operation not allowed when in repeated backup state")
def remove_repeated_backup_filter():
try:
wire.filters.remove(_repeated_backup_filter)
except ValueError:
pass
# this function is also called when handling ApplySettings # this function is also called when handling ApplySettings
def reload_settings_from_storage() -> None: def reload_settings_from_storage() -> None:
from trezor import ui from trezor import ui
@ -469,6 +447,8 @@ def reload_settings_from_storage() -> None:
def boot() -> None: def boot() -> None:
from apps.common import backup
MT = MessageType # local_cache_global MT = MessageType # local_cache_global
# Register workflow handlers # Register workflow handlers
@ -488,8 +468,8 @@ def boot() -> None:
reload_settings_from_storage() reload_settings_from_storage()
if storage_cache.get_bool(storage_cache.APP_RECOVERY_REPEATED_BACKUP_UNLOCKED): if backup.repeated_backup_enabled():
wire.filters.append(_repeated_backup_filter) backup.activate_repeated_backup()
if not config.is_unlocked(): if not config.is_unlocked():
# pinlocked handler should always be the last one # pinlocked handler should always be the last one
wire.filters.append(_pinlock_filter) wire.filters.append(_pinlock_filter)

View File

@ -1,7 +1,39 @@
from typing import TYPE_CHECKING
def disable_repeated_backup(): import storage.cache as storage_cache
import storage.cache as storage_cache from trezor import wire
from apps import base from trezor.enums import MessageType
if TYPE_CHECKING:
from trezor.wire import Handler, Msg
def repeated_backup_enabled() -> bool:
return storage_cache.get_bool(storage_cache.APP_RECOVERY_REPEATED_BACKUP_UNLOCKED)
def activate_repeated_backup():
storage_cache.set_bool(storage_cache.APP_RECOVERY_REPEATED_BACKUP_UNLOCKED, True)
wire.filters.append(_repeated_backup_filter)
def deactivate_repeated_backup():
storage_cache.delete(storage_cache.APP_RECOVERY_REPEATED_BACKUP_UNLOCKED) storage_cache.delete(storage_cache.APP_RECOVERY_REPEATED_BACKUP_UNLOCKED)
base.remove_repeated_backup_filter() wire.remove_filter(_repeated_backup_filter)
_ALLOW_WHILE_REPEATED_BACKUP_UNLOCKED = (
MessageType.Initialize,
MessageType.GetFeatures,
MessageType.EndSession,
MessageType.BackupDevice,
MessageType.WipeDevice,
MessageType.Cancel,
)
def _repeated_backup_filter(msg_type: int, prev_handler: Handler[Msg]) -> Handler[Msg]:
if msg_type in _ALLOW_WHILE_REPEATED_BACKUP_UNLOCKED:
return prev_handler
else:
raise wire.ProcessError("Operation not allowed when in repeated backup state")

View File

@ -10,7 +10,6 @@ BAK_T_BIP39 = BackupType.Bip39 # global_import_cache
async def backup_device(msg: BackupDevice) -> Success: async def backup_device(msg: BackupDevice) -> Success:
import storage.cache as storage_cache
import storage.device as storage_device import storage.device as storage_device
from trezor import wire from trezor import wire
from trezor.messages import Success from trezor.messages import Success
@ -21,13 +20,11 @@ async def backup_device(msg: BackupDevice) -> Success:
# do this early before we show any UI # do this early before we show any UI
# the homescreen will clear the flag right after its own UI is gone # the homescreen will clear the flag right after its own UI is gone
repeated_backup_unlocked = storage_cache.get_bool( repeated_backup_enabled = backup.repeated_backup_enabled()
storage_cache.APP_RECOVERY_REPEATED_BACKUP_UNLOCKED
)
if not storage_device.is_initialized(): if not storage_device.is_initialized():
raise wire.NotInitialized("Device is not initialized") raise wire.NotInitialized("Device is not initialized")
if not storage_device.needs_backup() and not repeated_backup_unlocked: if not storage_device.needs_backup() and not repeated_backup_enabled:
raise wire.ProcessError("Seed already backed up") raise wire.ProcessError("Seed already backed up")
mnemonic_secret, backup_type = mnemonic.get() mnemonic_secret, backup_type = mnemonic.get()
@ -47,10 +44,10 @@ async def backup_device(msg: BackupDevice) -> Success:
elif len(groups) > 0: elif len(groups) > 0:
raise wire.DataError("group_threshold is missing") raise wire.DataError("group_threshold is missing")
if not repeated_backup_unlocked: if not repeated_backup_enabled:
storage_device.set_unfinished_backup(True) storage_device.set_unfinished_backup(True)
backup.disable_repeated_backup() backup.deactivate_repeated_backup()
storage_device.set_backed_up() storage_device.set_backed_up()
if group_threshold is not None: if group_threshold is not None:

View File

@ -1,14 +1,14 @@
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from trezor.enums import RecoveryKind from trezor.enums import RecoveryType
if TYPE_CHECKING: if TYPE_CHECKING:
from trezor.messages import RecoveryDevice, Success from trezor.messages import RecoveryDevice, Success
# List of RecoveryDevice fields that can be set when doing dry-run recovery. # List of RecoveryDevice fields that can be set when doing dry-run recovery.
# All except `kind` are allowed for T1 compatibility, but their values are ignored. # All except `type` are allowed for T1 compatibility, but their values are ignored.
# If set, `enforce_wordlist` must be True, because we do not support non-enforcing. # If set, `enforce_wordlist` must be True, because we do not support non-enforcing.
DRY_RUN_ALLOWED_FIELDS = ("kind", "word_count", "enforce_wordlist", "type") DRY_RUN_ALLOWED_FIELDS = ("type", "word_count", "enforce_wordlist", "input_method")
async def recovery_device(msg: RecoveryDevice) -> Success: async def recovery_device(msg: RecoveryDevice) -> Success:
@ -34,18 +34,18 @@ async def recovery_device(msg: RecoveryDevice) -> Success:
from .homescreen import recovery_homescreen, recovery_process from .homescreen import recovery_homescreen, recovery_process
recovery_kind = msg.kind # local_cache_attribute recovery_type = msg.type # local_cache_attribute
# -------------------------------------------------------- # --------------------------------------------------------
# validate # validate
if recovery_kind == RecoveryKind.NormalRecovery: if recovery_type == RecoveryType.NormalRecovery:
if storage_device.is_initialized(): if storage_device.is_initialized():
raise wire.UnexpectedMessage("Already initialized") raise wire.UnexpectedMessage("Already initialized")
elif recovery_kind in (RecoveryKind.DryRun, RecoveryKind.UnlockRepeatedBackup): elif recovery_type in (RecoveryType.DryRun, RecoveryType.UnlockRepeatedBackup):
if not storage_device.is_initialized(): if not storage_device.is_initialized():
raise wire.NotInitialized("Device is not initialized") raise wire.NotInitialized("Device is not initialized")
if ( if (
recovery_kind == RecoveryKind.UnlockRepeatedBackup recovery_type == RecoveryType.UnlockRepeatedBackup
and mnemonic.get_type() == BackupType.Bip39 and mnemonic.get_type() == BackupType.Bip39
): ):
raise wire.ProcessError("Repeated Backup not available for BIP39 backups") raise wire.ProcessError("Repeated Backup not available for BIP39 backups")
@ -54,7 +54,7 @@ async def recovery_device(msg: RecoveryDevice) -> Success:
if key not in DRY_RUN_ALLOWED_FIELDS and value is not None: if key not in DRY_RUN_ALLOWED_FIELDS and value is not None:
raise wire.ProcessError(f"Forbidden field set in dry-run: {key}") raise wire.ProcessError(f"Forbidden field set in dry-run: {key}")
else: else:
raise RuntimeError # Unknown RecoveryKind raise RuntimeError # Unknown RecoveryType
if msg.enforce_wordlist is False: if msg.enforce_wordlist is False:
raise wire.ProcessError( raise wire.ProcessError(
@ -66,7 +66,7 @@ async def recovery_device(msg: RecoveryDevice) -> Success:
if storage_recovery.is_in_progress(): if storage_recovery.is_in_progress():
return await recovery_process() return await recovery_process()
if recovery_kind == RecoveryKind.NormalRecovery: if recovery_type == RecoveryType.NormalRecovery:
await confirm_reset_device(TR.recovery__title_recover, recovery=True) await confirm_reset_device(TR.recovery__title_recover, recovery=True)
# wipe storage to make sure the device is in a clear state # wipe storage to make sure the device is in a clear state
@ -85,10 +85,10 @@ async def recovery_device(msg: RecoveryDevice) -> Success:
if msg.label is not None: if msg.label is not None:
storage_device.set_label(msg.label) storage_device.set_label(msg.label)
elif recovery_kind in (RecoveryKind.DryRun, RecoveryKind.UnlockRepeatedBackup): elif recovery_type in (RecoveryType.DryRun, RecoveryType.UnlockRepeatedBackup):
title = ( title = (
TR.recovery__title_dry_run TR.recovery__title_dry_run
if recovery_kind == RecoveryKind.DryRun if recovery_type == RecoveryType.DryRun
else TR.recovery__title_unlock_repeated_backup else TR.recovery__title_unlock_repeated_backup
) )
await confirm_action( await confirm_action(
@ -105,7 +105,7 @@ async def recovery_device(msg: RecoveryDevice) -> Success:
storage_recovery.set_in_progress(True) storage_recovery.set_in_progress(True)
storage_recovery.set_kind(int(recovery_kind)) storage_recovery.set_type(int(recovery_type))
workflow.set_default(recovery_homescreen) workflow.set_default(recovery_homescreen)

View File

@ -1,6 +1,5 @@
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
import storage.cache as storage_cache
import storage.device as storage_device import storage.device as storage_device
import storage.recovery as storage_recovery import storage.recovery as storage_recovery
import storage.recovery_shares as storage_recovery_shares import storage.recovery_shares as storage_recovery_shares
@ -12,15 +11,17 @@ from apps.common import backup_types
from . import layout, recover from . import layout, recover
if TYPE_CHECKING: if TYPE_CHECKING:
from trezor.enums import BackupType, RecoveryKind from trezor.enums import BackupType, RecoveryType
async def recovery_homescreen() -> None: async def recovery_homescreen() -> None:
from trezor import workflow from trezor import workflow
from apps.common import backup
from apps.homescreen import homescreen from apps.homescreen import homescreen
if storage_cache.get_bool(storage_cache.APP_RECOVERY_REPEATED_BACKUP_UNLOCKED): if backup.repeated_backup_enabled():
storage_recovery.end_progress()
await _continue_repeated_backup() await _continue_repeated_backup()
elif not storage_recovery.is_in_progress(): elif not storage_recovery.is_in_progress():
workflow.set_default(homescreen) workflow.set_default(homescreen)
@ -30,11 +31,11 @@ async def recovery_homescreen() -> None:
async def recovery_process() -> Success: async def recovery_process() -> Success:
import storage import storage
from trezor.enums import MessageType, RecoveryKind from trezor.enums import MessageType, RecoveryType
from apps.common import backup from apps.common import backup
kind = storage_recovery.get_kind() recovery_type = storage_recovery.get_type()
wire.AVOID_RESTARTING_FOR = ( wire.AVOID_RESTARTING_FOR = (
MessageType.Initialize, MessageType.Initialize,
@ -44,24 +45,18 @@ async def recovery_process() -> Success:
try: try:
return await _continue_recovery_process() return await _continue_recovery_process()
except recover.RecoveryAborted: except recover.RecoveryAborted:
if kind == RecoveryKind.DryRun: storage_recovery.end_progress()
storage_recovery.end_progress() backup.deactivate_repeated_backup()
elif kind == RecoveryKind.UnlockRepeatedBackup: if recovery_type == RecoveryType.NormalRecovery:
backup.disable_repeated_backup()
storage_recovery.end_progress()
else:
storage.wipe() storage.wipe()
raise wire.ActionCancelled raise wire.ActionCancelled
async def _continue_repeated_backup() -> None: async def _continue_repeated_backup() -> None:
from trezor import workflow
from trezor.enums import ButtonRequestType, MessageType from trezor.enums import ButtonRequestType, MessageType
from trezor.ui.layouts import confirm_action from trezor.ui.layouts import confirm_action
from trezor.wire import ActionCancelled
from apps.common import backup, mnemonic from apps.common import backup, mnemonic
from apps.homescreen import homescreen
from apps.management.reset_device import backup_seed from apps.management.reset_device import backup_seed
wire.AVOID_RESTARTING_FOR = ( wire.AVOID_RESTARTING_FOR = (
@ -84,20 +79,17 @@ async def _continue_repeated_backup() -> None:
raise RuntimeError raise RuntimeError
await backup_seed(backup_type, mnemonic_secret) await backup_seed(backup_type, mnemonic_secret)
except ActionCancelled:
workflow.set_default(homescreen)
finally: finally:
backup.disable_repeated_backup() backup.deactivate_repeated_backup()
storage_recovery.end_progress()
async def _continue_recovery_process() -> Success: async def _continue_recovery_process() -> Success:
from trezor import utils from trezor import utils
from trezor.enums import RecoveryKind from trezor.enums import RecoveryType
from trezor.errors import MnemonicError from trezor.errors import MnemonicError
# gather the current recovery state from storage # gather the current recovery state from storage
kind = storage_recovery.get_kind() recovery_type = storage_recovery.get_type()
word_count, backup_type = recover.load_slip39_state() word_count, backup_type = recover.load_slip39_state()
# Both word_count and backup_type are derived from the same data. Both will be # Both word_count and backup_type are derived from the same data. Both will be
@ -109,7 +101,7 @@ async def _continue_recovery_process() -> Success:
if not is_first_step: if not is_first_step:
assert word_count is not None assert word_count is not None
# If we continue recovery, show starting screen with word count immediately. # If we continue recovery, show starting screen with word count immediately.
await _request_share_first_screen(word_count, kind) await _request_share_first_screen(word_count, recovery_type)
secret = None secret = None
while secret is None: while secret is None:
@ -122,9 +114,9 @@ async def _continue_recovery_process() -> Success:
TR.buttons__continue, TR.recovery__num_of_words TR.buttons__continue, TR.recovery__num_of_words
) )
# ask for the number of words # ask for the number of words
word_count = await layout.request_word_count(kind == RecoveryKind.DryRun) word_count = await layout.request_word_count(recovery_type)
# ...and only then show the starting screen with word count. # ...and only then show the starting screen with word count.
await _request_share_first_screen(word_count, kind) await _request_share_first_screen(word_count, recovery_type)
assert word_count is not None assert word_count is not None
# ask for mnemonic words one by one # ask for mnemonic words one by one
@ -144,9 +136,9 @@ async def _continue_recovery_process() -> Success:
await layout.show_invalid_mnemonic(word_count) await layout.show_invalid_mnemonic(word_count)
assert backup_type is not None assert backup_type is not None
if kind == RecoveryKind.DryRun: if recovery_type == RecoveryType.DryRun:
result = await _finish_recovery_dry_run(secret, backup_type) result = await _finish_recovery_dry_run(secret, backup_type)
elif kind == RecoveryKind.UnlockRepeatedBackup: elif recovery_type == RecoveryType.UnlockRepeatedBackup:
result = await _finish_recovery_unlock_repeated_backup(secret, backup_type) result = await _finish_recovery_unlock_repeated_backup(secret, backup_type)
else: else:
result = await _finish_recovery(secret, backup_type) result = await _finish_recovery(secret, backup_type)
@ -154,7 +146,9 @@ async def _continue_recovery_process() -> Success:
return result return result
def _check_secret_against_stored_secret(secret: bytes, is_slip39: bool, backup_type: BackupType) -> bool: def _check_secret_against_stored_secret(
secret: bytes, is_slip39: bool, backup_type: BackupType
) -> bool:
from trezor import utils from trezor import utils
from trezor.crypto.hashlib import sha256 from trezor.crypto.hashlib import sha256
@ -205,7 +199,7 @@ async def _finish_recovery_dry_run(secret: bytes, backup_type: BackupType) -> Su
async def _finish_recovery_unlock_repeated_backup( async def _finish_recovery_unlock_repeated_backup(
secret: bytes, backup_type: BackupType secret: bytes, backup_type: BackupType
) -> Success: ) -> Success:
import storage.cache as storage_cache from apps.common import backup
if backup_type is None: if backup_type is None:
raise RuntimeError raise RuntimeError
@ -215,9 +209,7 @@ async def _finish_recovery_unlock_repeated_backup(
result = _check_secret_against_stored_secret(secret, is_slip39, backup_type) result = _check_secret_against_stored_secret(secret, is_slip39, backup_type)
if result: if result:
storage_cache.set_bool( backup.activate_repeated_backup()
storage_cache.APP_RECOVERY_REPEATED_BACKUP_UNLOCKED, True
)
return Success(message="Backup unlocked") return Success(message="Backup unlocked")
else: else:
raise wire.ProcessError("The seed does not match the one in the device") raise wire.ProcessError("The seed does not match the one in the device")
@ -272,15 +264,17 @@ async def _process_words(words: str) -> tuple[bytes | None, BackupType]:
return secret, backup_type return secret, backup_type
async def _request_share_first_screen(word_count: int, kind: RecoveryKind) -> None: async def _request_share_first_screen(
from trezor.enums import RecoveryKind word_count: int, recovery_type: RecoveryType
) -> None:
from trezor.enums import RecoveryType
if backup_types.is_slip39_word_count(word_count): if backup_types.is_slip39_word_count(word_count):
remaining = storage_recovery.fetch_slip39_remaining_shares() remaining = storage_recovery.fetch_slip39_remaining_shares()
if remaining: if remaining:
await _request_share_next_screen() await _request_share_next_screen()
else: else:
if kind == RecoveryKind.UnlockRepeatedBackup: if recovery_type == RecoveryType.UnlockRepeatedBackup:
text = TR.recovery__enter_backup text = TR.recovery__enter_backup
button_label = TR.buttons__continue button_label = TR.buttons__continue
else: else:

View File

@ -149,23 +149,23 @@ async def homescreen_dialog(
show_info: bool = False, show_info: bool = False,
) -> None: ) -> None:
import storage.recovery as storage_recovery import storage.recovery as storage_recovery
from trezor.enums import RecoveryKind from trezor.enums import RecoveryType
from trezor.ui.layouts.recovery import continue_recovery from trezor.ui.layouts.recovery import continue_recovery
from trezor.wire import ActionCancelled from trezor.wire import ActionCancelled
from .recover import RecoveryAborted from .recover import RecoveryAborted
kind = storage_recovery.get_kind() recovery_type = storage_recovery.get_type()
while True: while True:
if await continue_recovery( if await continue_recovery(
button_label, text, subtext, info_func, kind, show_info button_label, text, subtext, info_func, recovery_type, show_info
): ):
# go forward in the recovery process # go forward in the recovery process
break break
# user has chosen to abort, confirm the choice # user has chosen to abort, confirm the choice
try: try:
await _confirm_abort(kind != RecoveryKind.NormalRecovery) await _confirm_abort(recovery_type != RecoveryType.NormalRecovery)
except ActionCancelled: except ActionCancelled:
pass pass
else: else:

View File

@ -4,7 +4,7 @@ from typing import TYPE_CHECKING
from storage import common from storage import common
if TYPE_CHECKING: if TYPE_CHECKING:
from trezor.enums import RecoveryKind from trezor.enums import RecoveryType
# Namespace: # Namespace:
_NAMESPACE = common.APP_RECOVERY _NAMESPACE = common.APP_RECOVERY
@ -12,7 +12,7 @@ _NAMESPACE = common.APP_RECOVERY
# fmt: off # fmt: off
# Keys: # Keys:
_IN_PROGRESS = const(0x00) # bool _IN_PROGRESS = const(0x00) # bool
_KIND = const(0x01) # int _TYPE = const(0x01) # int
_SLIP39_IDENTIFIER = const(0x03) # bytes _SLIP39_IDENTIFIER = const(0x03) # bytes
_REMAINING = const(0x05) # int _REMAINING = const(0x05) # int
_SLIP39_ITERATION_EXPONENT = const(0x06) # int _SLIP39_ITERATION_EXPONENT = const(0x06) # int
@ -41,27 +41,27 @@ def is_in_progress() -> bool:
return common.get_bool(_NAMESPACE, _IN_PROGRESS) return common.get_bool(_NAMESPACE, _IN_PROGRESS)
def set_kind(val: int) -> None: def set_type(val: int) -> None:
_require_progress() _require_progress()
common.set_uint8(_NAMESPACE, _KIND, val) common.set_uint8(_NAMESPACE, _TYPE, val)
def get_kind() -> RecoveryKind: def get_type() -> RecoveryType:
from trezor.enums import RecoveryKind from trezor.enums import RecoveryType
_require_progress() _require_progress()
recovery_kind = common.get_uint8(_NAMESPACE, _KIND) recovery_type = common.get_uint8(_NAMESPACE, _TYPE)
if recovery_kind is None: if recovery_type is None:
recovery_kind = RecoveryKind.NormalRecovery recovery_type = RecoveryType.NormalRecovery
if recovery_kind not in ( if recovery_type not in (
RecoveryKind.NormalRecovery, RecoveryType.NormalRecovery,
RecoveryKind.DryRun, RecoveryType.DryRun,
RecoveryKind.UnlockRepeatedBackup, RecoveryType.UnlockRepeatedBackup,
): ):
# Invalid recovery kind # Invalid recovery type
raise RuntimeError raise RuntimeError
return recovery_kind return recovery_type
def set_slip39_identifier(identifier: int) -> None: def set_slip39_identifier(identifier: int) -> None:
@ -146,7 +146,7 @@ def end_progress() -> None:
_require_progress() _require_progress()
for key in ( for key in (
_IN_PROGRESS, _IN_PROGRESS,
_KIND, _TYPE,
_SLIP39_IDENTIFIER, _SLIP39_IDENTIFIER,
_REMAINING, _REMAINING,
_SLIP39_ITERATION_EXPONENT, _SLIP39_ITERATION_EXPONENT,

View File

@ -0,0 +1,7 @@
# Automatically generated by pb2py
# fmt: off
# isort:skip_file
NotAvailable = 0
Required = 1
Available = 2

View File

@ -2,7 +2,6 @@
# fmt: off # fmt: off
# isort:skip_file # isort:skip_file
NoRecovery = 0 Nothing = 0
InNormalRecovery = 1 Recovery = 1
InDryRunRecovery = 2 Backup = 2
InUnlockRepeatedBackupRecovery = 3

View File

@ -440,11 +440,20 @@ if TYPE_CHECKING:
Jpeg = 2 Jpeg = 2
ToiG = 3 ToiG = 3
class RecoveryType(IntEnum):
NormalRecovery = 0
DryRun = 1
UnlockRepeatedBackup = 2
class BackupAvailability(IntEnum):
NotAvailable = 0
Required = 1
Available = 2
class RecoveryStatus(IntEnum): class RecoveryStatus(IntEnum):
NoRecovery = 0 Nothing = 0
InNormalRecovery = 1 Recovery = 1
InDryRunRecovery = 2 Backup = 2
InUnlockRepeatedBackupRecovery = 3
class Capability(IntEnum): class Capability(IntEnum):
Bitcoin = 1 Bitcoin = 1
@ -474,15 +483,10 @@ if TYPE_CHECKING:
ENABLE = 1 ENABLE = 1
REFRESH = 2 REFRESH = 2
class RecoveryDeviceType(IntEnum): class RecoveryDeviceInputMethod(IntEnum):
ScrambledWords = 0 ScrambledWords = 0
Matrix = 1 Matrix = 1
class RecoveryKind(IntEnum):
NormalRecovery = 0
DryRun = 1
UnlockRepeatedBackup = 2
class WordRequestType(IntEnum): class WordRequestType(IntEnum):
Plain = 0 Plain = 0
Matrix9 = 1 Matrix9 = 1

View File

@ -17,6 +17,7 @@ def __getattr__(name: str) -> Any:
if TYPE_CHECKING: if TYPE_CHECKING:
from typing import TypeGuard from typing import TypeGuard
from trezor.enums import AmountUnit # noqa: F401 from trezor.enums import AmountUnit # noqa: F401
from trezor.enums import BackupAvailability # noqa: F401
from trezor.enums import BackupType # noqa: F401 from trezor.enums import BackupType # noqa: F401
from trezor.enums import BinanceOrderSide # noqa: F401 from trezor.enums import BinanceOrderSide # noqa: F401
from trezor.enums import BinanceOrderType # noqa: F401 from trezor.enums import BinanceOrderType # noqa: F401
@ -53,9 +54,9 @@ if TYPE_CHECKING:
from trezor.enums import NEMSupplyChangeType # noqa: F401 from trezor.enums import NEMSupplyChangeType # noqa: F401
from trezor.enums import OutputScriptType # noqa: F401 from trezor.enums import OutputScriptType # noqa: F401
from trezor.enums import PinMatrixRequestType # noqa: F401 from trezor.enums import PinMatrixRequestType # noqa: F401
from trezor.enums import RecoveryDeviceType # noqa: F401 from trezor.enums import RecoveryDeviceInputMethod # noqa: F401
from trezor.enums import RecoveryKind # noqa: F401
from trezor.enums import RecoveryStatus # noqa: F401 from trezor.enums import RecoveryStatus # noqa: F401
from trezor.enums import RecoveryType # noqa: F401
from trezor.enums import RequestType # noqa: F401 from trezor.enums import RequestType # noqa: F401
from trezor.enums import SafetyCheckLevel # noqa: F401 from trezor.enums import SafetyCheckLevel # noqa: F401
from trezor.enums import SdProtectOperationType # noqa: F401 from trezor.enums import SdProtectOperationType # noqa: F401
@ -2133,7 +2134,7 @@ if TYPE_CHECKING:
imported: "bool | None" imported: "bool | None"
unlocked: "bool | None" unlocked: "bool | None"
firmware_present: "bool | None" firmware_present: "bool | None"
needs_backup: "bool | None" backup_availability: "BackupAvailability | None"
flags: "int | None" flags: "int | None"
model: "str | None" model: "str | None"
fw_major: "int | None" fw_major: "int | None"
@ -2166,6 +2167,7 @@ if TYPE_CHECKING:
language_version_matches: "bool" language_version_matches: "bool"
unit_packaging: "int | None" unit_packaging: "int | None"
haptic_feedback: "bool | None" haptic_feedback: "bool | None"
recovery_type: "RecoveryType | None"
def __init__( def __init__(
self, self,
@ -2187,7 +2189,7 @@ if TYPE_CHECKING:
imported: "bool | None" = None, imported: "bool | None" = None,
unlocked: "bool | None" = None, unlocked: "bool | None" = None,
firmware_present: "bool | None" = None, firmware_present: "bool | None" = None,
needs_backup: "bool | None" = None, backup_availability: "BackupAvailability | None" = None,
flags: "int | None" = None, flags: "int | None" = None,
model: "str | None" = None, model: "str | None" = None,
fw_major: "int | None" = None, fw_major: "int | None" = None,
@ -2219,6 +2221,7 @@ if TYPE_CHECKING:
language_version_matches: "bool | None" = None, language_version_matches: "bool | None" = None,
unit_packaging: "int | None" = None, unit_packaging: "int | None" = None,
haptic_feedback: "bool | None" = None, haptic_feedback: "bool | None" = None,
recovery_type: "RecoveryType | None" = None,
) -> None: ) -> None:
pass pass
@ -2600,9 +2603,9 @@ if TYPE_CHECKING:
pin_protection: "bool | None" pin_protection: "bool | None"
label: "str | None" label: "str | None"
enforce_wordlist: "bool | None" enforce_wordlist: "bool | None"
type: "RecoveryDeviceType | None" input_method: "RecoveryDeviceInputMethod | None"
u2f_counter: "int | None" u2f_counter: "int | None"
kind: "RecoveryKind" type: "RecoveryType"
def __init__( def __init__(
self, self,
@ -2612,9 +2615,9 @@ if TYPE_CHECKING:
pin_protection: "bool | None" = None, pin_protection: "bool | None" = None,
label: "str | None" = None, label: "str | None" = None,
enforce_wordlist: "bool | None" = None, enforce_wordlist: "bool | None" = None,
type: "RecoveryDeviceType | None" = None, input_method: "RecoveryDeviceInputMethod | None" = None,
u2f_counter: "int | None" = None, u2f_counter: "int | None" = None,
kind: "RecoveryKind | None" = None, type: "RecoveryType | None" = None,
) -> None: ) -> None:
pass pass

View File

@ -2,15 +2,15 @@ from typing import Callable, Iterable
import trezorui2 import trezorui2
from trezor import TR from trezor import TR
from trezor.enums import ButtonRequestType, RecoveryKind from trezor.enums import ButtonRequestType, RecoveryType
from ..common import interact from ..common import interact
from . import RustLayout, raise_if_not_confirmed, show_warning from . import RustLayout, raise_if_not_confirmed, show_warning
async def request_word_count(dry_run: bool) -> int: async def request_word_count(recovery_type: RecoveryType) -> int:
count = await interact( count = await interact(
RustLayout(trezorui2.select_word_count(dry_run=dry_run)), RustLayout(trezorui2.select_word_count(recovery_type=recovery_type)),
"word_count", "word_count",
ButtonRequestType.MnemonicWordCount, ButtonRequestType.MnemonicWordCount,
) )
@ -76,7 +76,7 @@ async def continue_recovery(
text: str, text: str,
subtext: str | None, subtext: str | None,
info_func: Callable | None, info_func: Callable | None,
kind: RecoveryKind, recovery_type: RecoveryType,
show_info: bool = False, show_info: bool = False,
) -> bool: ) -> bool:
# TODO: implement info_func? # TODO: implement info_func?
@ -84,7 +84,7 @@ async def continue_recovery(
# (and having middle button would mean shortening the right button text) # (and having middle button would mean shortening the right button text)
# Never showing info for dry-run, user already saw it and it is disturbing # Never showing info for dry-run, user already saw it and it is disturbing
if kind in (RecoveryKind.DryRun, RecoveryKind.UnlockRepeatedBackup): if recovery_type in (RecoveryType.DryRun, RecoveryType.UnlockRepeatedBackup):
show_info = False show_info = False
if subtext: if subtext:
@ -95,7 +95,7 @@ async def continue_recovery(
title="", title="",
description=text, description=text,
button=button_label, button=button_label,
kind=kind, recovery_type=recovery_type,
info_button=False, info_button=False,
show_info=show_info, # type: ignore [No parameter named "show_info"] show_info=show_info, # type: ignore [No parameter named "show_info"]
) )

View File

@ -2,7 +2,7 @@ from typing import Callable, Iterable
import trezorui2 import trezorui2
from trezor import TR from trezor import TR
from trezor.enums import ButtonRequestType, RecoveryKind from trezor.enums import ButtonRequestType, RecoveryType
from ..common import interact from ..common import interact
from . import RustLayout, raise_if_not_confirmed from . import RustLayout, raise_if_not_confirmed
@ -25,8 +25,8 @@ async def _is_confirmed_info(
return result is CONFIRMED return result is CONFIRMED
async def request_word_count(dry_run: bool) -> int: async def request_word_count(recovery_type: RecoveryType) -> int:
selector = RustLayout(trezorui2.select_word_count(dry_run=dry_run)) selector = RustLayout(trezorui2.select_word_count(recovery_type=recovery_type))
count = await interact(selector, "word_count", ButtonRequestType.MnemonicWordCount) count = await interact(selector, "word_count", ButtonRequestType.MnemonicWordCount)
return int(count) return int(count)
@ -116,7 +116,7 @@ async def continue_recovery(
text: str, text: str,
subtext: str | None, subtext: str | None,
info_func: Callable | None, info_func: Callable | None,
kind: RecoveryKind, recovery_type: RecoveryType,
show_info: bool = False, # unused on TT show_info: bool = False, # unused on TT
) -> bool: ) -> bool:
from ..common import button_request from ..common import button_request
@ -132,7 +132,7 @@ async def continue_recovery(
title=text, title=text,
description=description, description=description,
button=button_label, button=button_label,
kind=kind, recovery_type=recovery_type,
info_button=info_func is not None, info_button=info_func is not None,
) )
) )

View File

@ -31,7 +31,7 @@ from trezor import log, loop, protobuf, utils, workflow
from trezor.enums import FailureType from trezor.enums import FailureType
from trezor.messages import Failure from trezor.messages import Failure
from trezor.wire import codec_v1, context from trezor.wire import codec_v1, context
from trezor.wire.errors import ActionCancelled, DataError, Error from trezor.wire.errors import ActionCancelled, DataError, Error, UnexpectedMessage
# Import all errors into namespace, so that `wire.Error` is available from # Import all errors into namespace, so that `wire.Error` is available from
# other packages. # other packages.
@ -261,11 +261,12 @@ async def handle_session(
def find_handler(iface: WireInterface, msg_type: int) -> Handler: def find_handler(iface: WireInterface, msg_type: int) -> Handler:
import usb import usb
from apps import workflow_handlers from apps import workflow_handlers
handler = workflow_handlers.find_registered_handler(iface, msg_type) handler = workflow_handlers.find_registered_handler(iface, msg_type)
if handler is None: if handler is None:
raise context.UnexpectedMessage(msg="Unexpected message") raise UnexpectedMessage("Unexpected message")
if __debug__ and iface is usb.iface_debug: if __debug__ and iface is usb.iface_debug:
# no filtering allowed for debuglink # no filtering allowed for debuglink
@ -297,8 +298,21 @@ filter "wins" and the latest behavior triggers first.
Please note that this behavior is really unsuited to anything other than what we are Please note that this behavior is really unsuited to anything other than what we are
using it for now. It might be necessary to modify the semantics if we need more complex using it for now. It might be necessary to modify the semantics if we need more complex
usecases. usecases.
NB: `filters` is currently public so callers can have control over where they insert
new filters, but removal should be done using `remove_filter`!
We should, however, change it such that filters must be added using an `add_filter`
and `filters` becomes private!
""" """
def remove_filter(filter):
try:
filters.remove(filter)
except ValueError:
pass
AVOID_RESTARTING_FOR: Container[int] = () AVOID_RESTARTING_FOR: Container[int] = ()

View File

@ -589,7 +589,7 @@
"recovery__title_remaining_shares": "Remaining shares", "recovery__title_remaining_shares": "Remaining shares",
"recovery__title_unlock_repeated_backup": "Multi-share backup", "recovery__title_unlock_repeated_backup": "Multi-share backup",
"recovery__type_word_x_of_y_template": "Type word {0} of {1}", "recovery__type_word_x_of_y_template": "Type word {0} of {1}",
"recovery__unlock_repeated_backup": "Do you want to unlock the seed for repeated backup?", "recovery__unlock_repeated_backup": "Create additional backup?",
"recovery__unlock_repeated_backup_verb": "Unlock backup", "recovery__unlock_repeated_backup_verb": "Unlock backup",
"recovery__wallet_recovered": "Wallet recovery completed", "recovery__wallet_recovered": "Wallet recovery completed",
"recovery__wanna_cancel_dry_run": "Are you sure you want to cancel the backup check?", "recovery__wanna_cancel_dry_run": "Are you sure you want to cancel the backup check?",

View File

@ -60,8 +60,11 @@ bool get_features(Features *resp) {
resp->has_imported = config_getImported(&(resp->imported)); resp->has_imported = config_getImported(&(resp->imported));
resp->has_unlocked = true; resp->has_unlocked = true;
resp->unlocked = session_isUnlocked(); resp->unlocked = session_isUnlocked();
resp->has_needs_backup = true; resp->has_backup_availability = true;
config_getNeedsBackup(&(resp->needs_backup)); bool needs_backup = false;
config_getNeedsBackup(&needs_backup);
resp->backup_availability = needs_backup ? BackupAvailability_Required
: BackupAvailability_NotAvailable;
resp->has_unfinished_backup = true; resp->has_unfinished_backup = true;
config_getUnfinishedBackup(&(resp->unfinished_backup)); config_getUnfinishedBackup(&(resp->unfinished_backup));
resp->has_no_backup = true; resp->has_no_backup = true;
@ -491,11 +494,11 @@ void fsm_msgApplyFlags(const ApplyFlags *msg) {
void fsm_msgRecoveryDevice(const RecoveryDevice *msg) { void fsm_msgRecoveryDevice(const RecoveryDevice *msg) {
CHECK_PIN_UNCACHED CHECK_PIN_UNCACHED
CHECK_PARAM(!msg->has_kind || msg->kind == RecoveryKind_NormalRecovery || CHECK_PARAM(msg->type == RecoveryType_NormalRecovery ||
msg->kind == RecoveryKind_DryRun, msg->type == RecoveryType_DryRun,
_("UnlockRepeatedBackup not supported")) _("UnlockRepeatedBackup not supported"))
const bool dry_run = msg->has_kind ? msg->kind == RecoveryKind_DryRun : false; const bool dry_run = msg->has_type ? msg->type == RecoveryType_DryRun : false;
if (!dry_run) { if (!dry_run) {
CHECK_NOT_INITIALIZED CHECK_NOT_INITIALIZED
} else { } else {
@ -516,7 +519,7 @@ void fsm_msgRecoveryDevice(const RecoveryDevice *msg) {
msg->has_language ? msg->language : 0, msg->has_language ? msg->language : 0,
msg->has_label ? msg->label : 0, msg->has_label ? msg->label : 0,
msg->has_enforce_wordlist && msg->enforce_wordlist, msg->has_enforce_wordlist && msg->enforce_wordlist,
msg->has_type ? msg->type : 0, msg->has_input_method ? msg->input_method : 0,
msg->has_u2f_counter ? msg->u2f_counter : 0, dry_run); msg->has_u2f_counter ? msg->u2f_counter : 0, dry_run);
} }

View File

@ -474,8 +474,8 @@ void next_word(void) {
void recovery_init(uint32_t _word_count, bool passphrase_protection, void recovery_init(uint32_t _word_count, bool passphrase_protection,
bool pin_protection, const char *language, const char *label, bool pin_protection, const char *language, const char *label,
bool _enforce_wordlist, uint32_t type, uint32_t u2f_counter, bool _enforce_wordlist, uint32_t input_method,
bool _dry_run) { uint32_t u2f_counter, bool _dry_run) {
if (_word_count != 12 && _word_count != 18 && _word_count != 24) return; if (_word_count != 12 && _word_count != 18 && _word_count != 24) return;
recovery_mode = RECOVERY_NONE; recovery_mode = RECOVERY_NONE;
@ -510,7 +510,7 @@ void recovery_init(uint32_t _word_count, bool passphrase_protection,
} }
// Prefer matrix recovery if the host supports it. // Prefer matrix recovery if the host supports it.
if ((type & RecoveryDeviceType_RecoveryDeviceType_Matrix) != 0) { if ((input_method & RecoveryDeviceInputMethod_Matrix) != 0) {
recovery_mode = RECOVERY_MATRIX; recovery_mode = RECOVERY_MATRIX;
next_matrix(); next_matrix();
} else { } else {

View File

@ -25,8 +25,8 @@
void recovery_init(uint32_t _word_count, bool passphrase_protection, void recovery_init(uint32_t _word_count, bool passphrase_protection,
bool pin_protection, const char *language, const char *label, bool pin_protection, const char *language, const char *label,
bool _enforce_wordlist, uint32_t type, uint32_t u2f_counter, bool _enforce_wordlist, uint32_t input_method,
bool _dry_run); uint32_t u2f_counter, bool _dry_run);
void recovery_word(const char *word); void recovery_word(const char *word);
void recovery_abort(void); void recovery_abort(void);
const char *recovery_get_fake_word(void); const char *recovery_get_fake_word(void);

View File

@ -28,9 +28,9 @@ if TYPE_CHECKING:
from ..protobuf import MessageType from ..protobuf import MessageType
from . import TrezorConnection from . import TrezorConnection
RECOVERY_TYPE = { RECOVERY_DEVICE_INPUT_METHOD = {
"scrambled": messages.RecoveryDeviceType.ScrambledWords, "scrambled": messages.RecoveryDeviceInputMethod.ScrambledWords,
"matrix": messages.RecoveryDeviceType.Matrix, "matrix": messages.RecoveryDeviceInputMethod.Matrix,
} }
BACKUP_TYPE = { BACKUP_TYPE = {
@ -148,7 +148,12 @@ def load(
@click.option("-l", "--label") @click.option("-l", "--label")
@click.option("-u", "--u2f-counter", default=None, type=int) @click.option("-u", "--u2f-counter", default=None, type=int)
@click.option( @click.option(
"-t", "--type", "rec_type", type=ChoiceType(RECOVERY_TYPE), default="scrambled" "-i",
"--input_method",
"-t",
"--type",
type=ChoiceType(RECOVERY_DEVICE_INPUT_METHOD),
default="scrambled",
) )
@click.option("-d", "--dry-run", is_flag=True) @click.option("-d", "--dry-run", is_flag=True)
@click.option("-b", "--unlock-repeated-backup", is_flag=True) @click.option("-b", "--unlock-repeated-backup", is_flag=True)
@ -161,12 +166,12 @@ def recover(
passphrase_protection: bool, passphrase_protection: bool,
label: Optional[str], label: Optional[str],
u2f_counter: int, u2f_counter: int,
rec_type: messages.RecoveryDeviceType, input_method: messages.RecoveryDeviceInputMethod,
dry_run: bool, dry_run: bool,
unlock_repeated_backup: bool, unlock_repeated_backup: bool,
) -> "MessageType": ) -> "MessageType":
"""Start safe recovery workflow.""" """Start safe recovery workflow."""
if rec_type == messages.RecoveryDeviceType.ScrambledWords: if input_method == messages.RecoveryDeviceInputMethod.ScrambledWords:
input_callback = ui.mnemonic_words(expand) input_callback = ui.mnemonic_words(expand)
else: else:
input_callback = ui.matrix_words input_callback = ui.matrix_words
@ -175,11 +180,11 @@ def recover(
if dry_run and unlock_repeated_backup: if dry_run and unlock_repeated_backup:
raise click.ClickException("Cannot use -d and -b together.") raise click.ClickException("Cannot use -d and -b together.")
recovery_kind = None type = None
if dry_run: if dry_run:
recovery_kind = messages.RecoveryKind.DryRun type = messages.RecoveryType.DryRun
if unlock_repeated_backup: if unlock_repeated_backup:
recovery_kind = messages.RecoveryKind.UnlockRepeatedBackup type = messages.RecoveryType.UnlockRepeatedBackup
return device.recover( return device.recover(
client, client,
@ -189,8 +194,8 @@ def recover(
label=label, label=label,
u2f_counter=u2f_counter, u2f_counter=u2f_counter,
input_callback=input_callback, input_callback=input_callback,
type=rec_type, input_method=input_method,
recovery_kind=recovery_kind, type=type,
) )

View File

@ -159,11 +159,11 @@ def recover(
label: Optional[str] = None, label: Optional[str] = None,
language: Optional[str] = None, language: Optional[str] = None,
input_callback: Optional[Callable] = None, input_callback: Optional[Callable] = None,
type: messages.RecoveryDeviceType = messages.RecoveryDeviceType.ScrambledWords, input_method: messages.RecoveryDeviceInputMethod = messages.RecoveryDeviceInputMethod.ScrambledWords,
dry_run: Optional[bool] = None, dry_run: Optional[bool] = None,
u2f_counter: Optional[int] = None, u2f_counter: Optional[int] = None,
*, *,
recovery_kind: Optional[messages.RecoveryKind] = None, type: Optional[messages.RecoveryType] = None,
) -> "MessageType": ) -> "MessageType":
if language is not None: if language is not None:
warnings.warn( warnings.warn(
@ -173,21 +173,19 @@ def recover(
if dry_run is not None: if dry_run is not None:
warnings.warn( warnings.warn(
"Use recovery_kind=RecoveryKind.DryRun instead!", "Use type=RecoveryType.DryRun instead!",
DeprecationWarning, DeprecationWarning,
) )
if recovery_kind is not None: if type is not None:
raise ValueError( raise ValueError("Cannot use both dry_run and type simultaneously.")
"Cannot use both dry_run and recovery_kind simultaneously."
)
elif dry_run: elif dry_run:
recovery_kind = messages.RecoveryKind.DryRun type = messages.RecoveryType.DryRun
else: else:
recovery_kind = messages.RecoveryKind.NormalRecovery type = messages.RecoveryType.NormalRecovery
if recovery_kind is None: if type is None:
recovery_kind = messages.RecoveryKind.NormalRecovery type = messages.RecoveryType.NormalRecovery
if client.features.model == "1" and input_callback is None: if client.features.model == "1" and input_callback is None:
raise RuntimeError("Input callback required for Trezor One") raise RuntimeError("Input callback required for Trezor One")
@ -195,10 +193,7 @@ def recover(
if word_count not in (12, 18, 24): if word_count not in (12, 18, 24):
raise ValueError("Invalid word count. Use 12/18/24") raise ValueError("Invalid word count. Use 12/18/24")
if ( if client.features.initialized and type == messages.RecoveryType.NormalRecovery:
client.features.initialized
and recovery_kind == messages.RecoveryKind.NormalRecovery
):
raise RuntimeError( raise RuntimeError(
"Device already initialized. Call device.wipe() and try again." "Device already initialized. Call device.wipe() and try again."
) )
@ -207,10 +202,13 @@ def recover(
u2f_counter = int(time.time()) u2f_counter = int(time.time())
msg = messages.RecoveryDevice( msg = messages.RecoveryDevice(
word_count=word_count, enforce_wordlist=True, type=type, kind=recovery_kind word_count=word_count,
enforce_wordlist=True,
input_method=input_method,
type=type,
) )
if recovery_kind == messages.RecoveryKind.NormalRecovery: if type == messages.RecoveryType.NormalRecovery:
# set additional parameters # set additional parameters
msg.passphrase_protection = passphrase_protection msg.passphrase_protection = passphrase_protection
msg.pin_protection = pin_protection msg.pin_protection = pin_protection

View File

@ -472,11 +472,22 @@ class HomescreenFormat(IntEnum):
ToiG = 3 ToiG = 3
class RecoveryType(IntEnum):
NormalRecovery = 0
DryRun = 1
UnlockRepeatedBackup = 2
class BackupAvailability(IntEnum):
NotAvailable = 0
Required = 1
Available = 2
class RecoveryStatus(IntEnum): class RecoveryStatus(IntEnum):
NoRecovery = 0 Nothing = 0
InNormalRecovery = 1 Recovery = 1
InDryRunRecovery = 2 Backup = 2
InUnlockRepeatedBackupRecovery = 3
class Capability(IntEnum): class Capability(IntEnum):
@ -509,17 +520,11 @@ class SdProtectOperationType(IntEnum):
REFRESH = 2 REFRESH = 2
class RecoveryDeviceType(IntEnum): class RecoveryDeviceInputMethod(IntEnum):
ScrambledWords = 0 ScrambledWords = 0
Matrix = 1 Matrix = 1
class RecoveryKind(IntEnum):
NormalRecovery = 0
DryRun = 1
UnlockRepeatedBackup = 2
class WordRequestType(IntEnum): class WordRequestType(IntEnum):
Plain = 0 Plain = 0
Matrix9 = 1 Matrix9 = 1
@ -3245,7 +3250,7 @@ class Features(protobuf.MessageType):
16: protobuf.Field("unlocked", "bool", repeated=False, required=False, default=None), 16: protobuf.Field("unlocked", "bool", repeated=False, required=False, default=None),
17: protobuf.Field("_passphrase_cached", "bool", repeated=False, required=False, default=None), 17: protobuf.Field("_passphrase_cached", "bool", repeated=False, required=False, default=None),
18: protobuf.Field("firmware_present", "bool", repeated=False, required=False, default=None), 18: protobuf.Field("firmware_present", "bool", repeated=False, required=False, default=None),
19: protobuf.Field("needs_backup", "bool", repeated=False, required=False, default=None), 19: protobuf.Field("backup_availability", "BackupAvailability", repeated=False, required=False, default=None),
20: protobuf.Field("flags", "uint32", repeated=False, required=False, default=None), 20: protobuf.Field("flags", "uint32", repeated=False, required=False, default=None),
21: protobuf.Field("model", "string", repeated=False, required=False, default=None), 21: protobuf.Field("model", "string", repeated=False, required=False, default=None),
22: protobuf.Field("fw_major", "uint32", repeated=False, required=False, default=None), 22: protobuf.Field("fw_major", "uint32", repeated=False, required=False, default=None),
@ -3278,6 +3283,7 @@ class Features(protobuf.MessageType):
50: protobuf.Field("language_version_matches", "bool", repeated=False, required=False, default=True), 50: protobuf.Field("language_version_matches", "bool", repeated=False, required=False, default=True),
51: protobuf.Field("unit_packaging", "uint32", repeated=False, required=False, default=None), 51: protobuf.Field("unit_packaging", "uint32", repeated=False, required=False, default=None),
52: protobuf.Field("haptic_feedback", "bool", repeated=False, required=False, default=None), 52: protobuf.Field("haptic_feedback", "bool", repeated=False, required=False, default=None),
53: protobuf.Field("recovery_type", "RecoveryType", repeated=False, required=False, default=None),
} }
def __init__( def __init__(
@ -3301,7 +3307,7 @@ class Features(protobuf.MessageType):
unlocked: Optional["bool"] = None, unlocked: Optional["bool"] = None,
_passphrase_cached: Optional["bool"] = None, _passphrase_cached: Optional["bool"] = None,
firmware_present: Optional["bool"] = None, firmware_present: Optional["bool"] = None,
needs_backup: Optional["bool"] = None, backup_availability: Optional["BackupAvailability"] = None,
flags: Optional["int"] = None, flags: Optional["int"] = None,
model: Optional["str"] = None, model: Optional["str"] = None,
fw_major: Optional["int"] = None, fw_major: Optional["int"] = None,
@ -3333,6 +3339,7 @@ class Features(protobuf.MessageType):
language_version_matches: Optional["bool"] = True, language_version_matches: Optional["bool"] = True,
unit_packaging: Optional["int"] = None, unit_packaging: Optional["int"] = None,
haptic_feedback: Optional["bool"] = None, haptic_feedback: Optional["bool"] = None,
recovery_type: Optional["RecoveryType"] = None,
) -> None: ) -> None:
self.capabilities: Sequence["Capability"] = capabilities if capabilities is not None else [] self.capabilities: Sequence["Capability"] = capabilities if capabilities is not None else []
self.major_version = major_version self.major_version = major_version
@ -3352,7 +3359,7 @@ class Features(protobuf.MessageType):
self.unlocked = unlocked self.unlocked = unlocked
self._passphrase_cached = _passphrase_cached self._passphrase_cached = _passphrase_cached
self.firmware_present = firmware_present self.firmware_present = firmware_present
self.needs_backup = needs_backup self.backup_availability = backup_availability
self.flags = flags self.flags = flags
self.model = model self.model = model
self.fw_major = fw_major self.fw_major = fw_major
@ -3384,6 +3391,7 @@ class Features(protobuf.MessageType):
self.language_version_matches = language_version_matches self.language_version_matches = language_version_matches
self.unit_packaging = unit_packaging self.unit_packaging = unit_packaging
self.haptic_feedback = haptic_feedback self.haptic_feedback = haptic_feedback
self.recovery_type = recovery_type
class LockDevice(protobuf.MessageType): class LockDevice(protobuf.MessageType):
@ -3794,9 +3802,9 @@ class RecoveryDevice(protobuf.MessageType):
4: protobuf.Field("language", "string", repeated=False, required=False, default=None), 4: protobuf.Field("language", "string", repeated=False, required=False, default=None),
5: protobuf.Field("label", "string", repeated=False, required=False, default=None), 5: protobuf.Field("label", "string", repeated=False, required=False, default=None),
6: protobuf.Field("enforce_wordlist", "bool", repeated=False, required=False, default=None), 6: protobuf.Field("enforce_wordlist", "bool", repeated=False, required=False, default=None),
8: protobuf.Field("type", "RecoveryDeviceType", repeated=False, required=False, default=None), 8: protobuf.Field("input_method", "RecoveryDeviceInputMethod", repeated=False, required=False, default=None),
9: protobuf.Field("u2f_counter", "uint32", repeated=False, required=False, default=None), 9: protobuf.Field("u2f_counter", "uint32", repeated=False, required=False, default=None),
10: protobuf.Field("kind", "RecoveryKind", repeated=False, required=False, default=RecoveryKind.NormalRecovery), 10: protobuf.Field("type", "RecoveryType", repeated=False, required=False, default=RecoveryType.NormalRecovery),
} }
def __init__( def __init__(
@ -3808,9 +3816,9 @@ class RecoveryDevice(protobuf.MessageType):
language: Optional["str"] = None, language: Optional["str"] = None,
label: Optional["str"] = None, label: Optional["str"] = None,
enforce_wordlist: Optional["bool"] = None, enforce_wordlist: Optional["bool"] = None,
type: Optional["RecoveryDeviceType"] = None, input_method: Optional["RecoveryDeviceInputMethod"] = None,
u2f_counter: Optional["int"] = None, u2f_counter: Optional["int"] = None,
kind: Optional["RecoveryKind"] = RecoveryKind.NormalRecovery, type: Optional["RecoveryType"] = RecoveryType.NormalRecovery,
) -> None: ) -> None:
self.word_count = word_count self.word_count = word_count
self.passphrase_protection = passphrase_protection self.passphrase_protection = passphrase_protection
@ -3818,9 +3826,9 @@ class RecoveryDevice(protobuf.MessageType):
self.language = language self.language = language
self.label = label self.label = label
self.enforce_wordlist = enforce_wordlist self.enforce_wordlist = enforce_wordlist
self.type = type self.input_method = input_method
self.u2f_counter = u2f_counter self.u2f_counter = u2f_counter
self.kind = kind self.type = type
class WordRequest(protobuf.MessageType): class WordRequest(protobuf.MessageType):

View File

@ -78,8 +78,7 @@ fn do_main() -> Result<(), trezor_client::Error> {
//optional bool pin_cached = 16; // is PIN already cached in session? //optional bool pin_cached = 16; // is PIN already cached in session?
//optional bool passphrase_cached = 17; // is passphrase already cached in session? //optional bool passphrase_cached = 17; // is passphrase already cached in session?
//optional bool firmware_present = 18; // is valid firmware loaded? //optional bool firmware_present = 18; // is valid firmware loaded?
//optional bool needs_backup = 19; // does storage need backup? (equals to //optional uint32 flags = 20; // device flags (equals
// Storage.needs_backup) optional uint32 flags = 20; // device flags (equals
// to Storage.flags) optional string model = 21; // device hardware model // to Storage.flags) optional string model = 21; // device hardware model
//optional uint32 fw_major = 22; // reported firmware version if in bootloader //optional uint32 fw_major = 22; // reported firmware version if in bootloader
// mode optional uint32 fw_minor = 23; // reported firmware version if in // mode optional uint32 fw_minor = 23; // reported firmware version if in

View File

@ -170,13 +170,11 @@ impl Trezor {
req.set_label(label); req.set_label(label);
req.set_enforce_wordlist(true); req.set_enforce_wordlist(true);
if dry_run { if dry_run {
req.set_kind(protos::recovery_device::RecoveryKind::DryRun); req.set_type(protos::RecoveryType::DryRun);
} else { } else {
req.set_kind(protos::recovery_device::RecoveryKind::NormalRecovery); req.set_type(protos::RecoveryType::NormalRecovery);
} }
req.set_type( req.set_input_method(protos::recovery_device::RecoveryDeviceInputMethod::ScrambledWords);
protos::recovery_device::RecoveryDeviceType::RecoveryDeviceType_ScrambledWords,
);
//TODO(stevenroose) support languages //TODO(stevenroose) support languages
req.set_language("english".to_owned()); req.set_language("english".to_owned());
self.call(req, Box::new(|_, _| Ok(()))) self.call(req, Box::new(|_, _| Ok(())))

View File

@ -398,8 +398,8 @@ pub struct Features {
pub _passphrase_cached: ::std::option::Option<bool>, pub _passphrase_cached: ::std::option::Option<bool>,
// @@protoc_insertion_point(field:hw.trezor.messages.management.Features.firmware_present) // @@protoc_insertion_point(field:hw.trezor.messages.management.Features.firmware_present)
pub firmware_present: ::std::option::Option<bool>, pub firmware_present: ::std::option::Option<bool>,
// @@protoc_insertion_point(field:hw.trezor.messages.management.Features.needs_backup) // @@protoc_insertion_point(field:hw.trezor.messages.management.Features.backup_availability)
pub needs_backup: ::std::option::Option<bool>, pub backup_availability: ::std::option::Option<::protobuf::EnumOrUnknown<features::BackupAvailability>>,
// @@protoc_insertion_point(field:hw.trezor.messages.management.Features.flags) // @@protoc_insertion_point(field:hw.trezor.messages.management.Features.flags)
pub flags: ::std::option::Option<u32>, pub flags: ::std::option::Option<u32>,
// @@protoc_insertion_point(field:hw.trezor.messages.management.Features.model) // @@protoc_insertion_point(field:hw.trezor.messages.management.Features.model)
@ -464,6 +464,8 @@ pub struct Features {
pub unit_packaging: ::std::option::Option<u32>, pub unit_packaging: ::std::option::Option<u32>,
// @@protoc_insertion_point(field:hw.trezor.messages.management.Features.haptic_feedback) // @@protoc_insertion_point(field:hw.trezor.messages.management.Features.haptic_feedback)
pub haptic_feedback: ::std::option::Option<bool>, pub haptic_feedback: ::std::option::Option<bool>,
// @@protoc_insertion_point(field:hw.trezor.messages.management.Features.recovery_type)
pub recovery_type: ::std::option::Option<::protobuf::EnumOrUnknown<RecoveryType>>,
// special fields // special fields
// @@protoc_insertion_point(special_field:hw.trezor.messages.management.Features.special_fields) // @@protoc_insertion_point(special_field:hw.trezor.messages.management.Features.special_fields)
pub special_fields: ::protobuf::SpecialFields, pub special_fields: ::protobuf::SpecialFields,
@ -905,23 +907,26 @@ impl Features {
self.firmware_present = ::std::option::Option::Some(v); self.firmware_present = ::std::option::Option::Some(v);
} }
// optional bool needs_backup = 19; // optional .hw.trezor.messages.management.Features.BackupAvailability backup_availability = 19;
pub fn needs_backup(&self) -> bool { pub fn backup_availability(&self) -> features::BackupAvailability {
self.needs_backup.unwrap_or(false) match self.backup_availability {
Some(e) => e.enum_value_or(features::BackupAvailability::NotAvailable),
None => features::BackupAvailability::NotAvailable,
}
} }
pub fn clear_needs_backup(&mut self) { pub fn clear_backup_availability(&mut self) {
self.needs_backup = ::std::option::Option::None; self.backup_availability = ::std::option::Option::None;
} }
pub fn has_needs_backup(&self) -> bool { pub fn has_backup_availability(&self) -> bool {
self.needs_backup.is_some() self.backup_availability.is_some()
} }
// Param is passed by value, moved // Param is passed by value, moved
pub fn set_needs_backup(&mut self, v: bool) { pub fn set_backup_availability(&mut self, v: features::BackupAvailability) {
self.needs_backup = ::std::option::Option::Some(v); self.backup_availability = ::std::option::Option::Some(::protobuf::EnumOrUnknown::new(v));
} }
// optional uint32 flags = 20; // optional uint32 flags = 20;
@ -1114,8 +1119,8 @@ impl Features {
pub fn recovery_status(&self) -> features::RecoveryStatus { pub fn recovery_status(&self) -> features::RecoveryStatus {
match self.recovery_status { match self.recovery_status {
Some(e) => e.enum_value_or(features::RecoveryStatus::NoRecovery), Some(e) => e.enum_value_or(features::RecoveryStatus::Nothing),
None => features::RecoveryStatus::NoRecovery, None => features::RecoveryStatus::Nothing,
} }
} }
@ -1593,8 +1598,30 @@ impl Features {
self.haptic_feedback = ::std::option::Option::Some(v); self.haptic_feedback = ::std::option::Option::Some(v);
} }
// optional .hw.trezor.messages.management.RecoveryType recovery_type = 53;
pub fn recovery_type(&self) -> RecoveryType {
match self.recovery_type {
Some(e) => e.enum_value_or(RecoveryType::NormalRecovery),
None => RecoveryType::NormalRecovery,
}
}
pub fn clear_recovery_type(&mut self) {
self.recovery_type = ::std::option::Option::None;
}
pub fn has_recovery_type(&self) -> bool {
self.recovery_type.is_some()
}
// Param is passed by value, moved
pub fn set_recovery_type(&mut self, v: RecoveryType) {
self.recovery_type = ::std::option::Option::Some(::protobuf::EnumOrUnknown::new(v));
}
fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData {
let mut fields = ::std::vec::Vec::with_capacity(50); let mut fields = ::std::vec::Vec::with_capacity(51);
let mut oneofs = ::std::vec::Vec::with_capacity(0); let mut oneofs = ::std::vec::Vec::with_capacity(0);
fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>(
"vendor", "vendor",
@ -1682,9 +1709,9 @@ impl Features {
|m: &mut Features| { &mut m.firmware_present }, |m: &mut Features| { &mut m.firmware_present },
)); ));
fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>(
"needs_backup", "backup_availability",
|m: &Features| { &m.needs_backup }, |m: &Features| { &m.backup_availability },
|m: &mut Features| { &mut m.needs_backup }, |m: &mut Features| { &mut m.backup_availability },
)); ));
fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>(
"flags", "flags",
@ -1846,6 +1873,11 @@ impl Features {
|m: &Features| { &m.haptic_feedback }, |m: &Features| { &m.haptic_feedback },
|m: &mut Features| { &mut m.haptic_feedback }, |m: &mut Features| { &mut m.haptic_feedback },
)); ));
fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>(
"recovery_type",
|m: &Features| { &m.recovery_type },
|m: &mut Features| { &mut m.recovery_type },
));
::protobuf::reflect::GeneratedMessageDescriptorData::new_2::<Features>( ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::<Features>(
"Features", "Features",
fields, fields,
@ -1925,7 +1957,7 @@ impl ::protobuf::Message for Features {
self.firmware_present = ::std::option::Option::Some(is.read_bool()?); self.firmware_present = ::std::option::Option::Some(is.read_bool()?);
}, },
152 => { 152 => {
self.needs_backup = ::std::option::Option::Some(is.read_bool()?); self.backup_availability = ::std::option::Option::Some(is.read_enum_or_unknown()?);
}, },
160 => { 160 => {
self.flags = ::std::option::Option::Some(is.read_uint32()?); self.flags = ::std::option::Option::Some(is.read_uint32()?);
@ -2026,6 +2058,9 @@ impl ::protobuf::Message for Features {
416 => { 416 => {
self.haptic_feedback = ::std::option::Option::Some(is.read_bool()?); self.haptic_feedback = ::std::option::Option::Some(is.read_bool()?);
}, },
424 => {
self.recovery_type = ::std::option::Option::Some(is.read_enum_or_unknown()?);
},
tag => { tag => {
::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?;
}, },
@ -2089,8 +2124,8 @@ impl ::protobuf::Message for Features {
if let Some(v) = self.firmware_present { if let Some(v) = self.firmware_present {
my_size += 2 + 1; my_size += 2 + 1;
} }
if let Some(v) = self.needs_backup { if let Some(v) = self.backup_availability {
my_size += 2 + 1; my_size += ::protobuf::rt::int32_size(19, v.value());
} }
if let Some(v) = self.flags { if let Some(v) = self.flags {
my_size += ::protobuf::rt::uint32_size(20, v); my_size += ::protobuf::rt::uint32_size(20, v);
@ -2188,6 +2223,9 @@ impl ::protobuf::Message for Features {
if let Some(v) = self.haptic_feedback { if let Some(v) = self.haptic_feedback {
my_size += 2 + 1; my_size += 2 + 1;
} }
if let Some(v) = self.recovery_type {
my_size += ::protobuf::rt::int32_size(53, v.value());
}
my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields());
self.special_fields.cached_size().set(my_size as u32); self.special_fields.cached_size().set(my_size as u32);
my_size my_size
@ -2245,8 +2283,8 @@ impl ::protobuf::Message for Features {
if let Some(v) = self.firmware_present { if let Some(v) = self.firmware_present {
os.write_bool(18, v)?; os.write_bool(18, v)?;
} }
if let Some(v) = self.needs_backup { if let Some(v) = self.backup_availability {
os.write_bool(19, v)?; os.write_enum(19, ::protobuf::EnumOrUnknown::value(&v))?;
} }
if let Some(v) = self.flags { if let Some(v) = self.flags {
os.write_uint32(20, v)?; os.write_uint32(20, v)?;
@ -2344,6 +2382,9 @@ impl ::protobuf::Message for Features {
if let Some(v) = self.haptic_feedback { if let Some(v) = self.haptic_feedback {
os.write_bool(52, v)?; os.write_bool(52, v)?;
} }
if let Some(v) = self.recovery_type {
os.write_enum(53, ::protobuf::EnumOrUnknown::value(&v))?;
}
os.write_unknown_fields(self.special_fields.unknown_fields())?; os.write_unknown_fields(self.special_fields.unknown_fields())?;
::std::result::Result::Ok(()) ::std::result::Result::Ok(())
} }
@ -2378,7 +2419,7 @@ impl ::protobuf::Message for Features {
self.unlocked = ::std::option::Option::None; self.unlocked = ::std::option::Option::None;
self._passphrase_cached = ::std::option::Option::None; self._passphrase_cached = ::std::option::Option::None;
self.firmware_present = ::std::option::Option::None; self.firmware_present = ::std::option::Option::None;
self.needs_backup = ::std::option::Option::None; self.backup_availability = ::std::option::Option::None;
self.flags = ::std::option::Option::None; self.flags = ::std::option::Option::None;
self.model = ::std::option::Option::None; self.model = ::std::option::Option::None;
self.fw_major = ::std::option::Option::None; self.fw_major = ::std::option::Option::None;
@ -2411,6 +2452,7 @@ impl ::protobuf::Message for Features {
self.language_version_matches = ::std::option::Option::None; self.language_version_matches = ::std::option::Option::None;
self.unit_packaging = ::std::option::Option::None; self.unit_packaging = ::std::option::Option::None;
self.haptic_feedback = ::std::option::Option::None; self.haptic_feedback = ::std::option::Option::None;
self.recovery_type = ::std::option::Option::None;
self.special_fields.clear(); self.special_fields.clear();
} }
@ -2433,7 +2475,7 @@ impl ::protobuf::Message for Features {
unlocked: ::std::option::Option::None, unlocked: ::std::option::Option::None,
_passphrase_cached: ::std::option::Option::None, _passphrase_cached: ::std::option::Option::None,
firmware_present: ::std::option::Option::None, firmware_present: ::std::option::Option::None,
needs_backup: ::std::option::Option::None, backup_availability: ::std::option::Option::None,
flags: ::std::option::Option::None, flags: ::std::option::Option::None,
model: ::std::option::Option::None, model: ::std::option::Option::None,
fw_major: ::std::option::Option::None, fw_major: ::std::option::Option::None,
@ -2466,6 +2508,7 @@ impl ::protobuf::Message for Features {
language_version_matches: ::std::option::Option::None, language_version_matches: ::std::option::Option::None,
unit_packaging: ::std::option::Option::None, unit_packaging: ::std::option::Option::None,
haptic_feedback: ::std::option::Option::None, haptic_feedback: ::std::option::Option::None,
recovery_type: ::std::option::Option::None,
special_fields: ::protobuf::SpecialFields::new(), special_fields: ::protobuf::SpecialFields::new(),
}; };
&instance &instance
@ -2491,17 +2534,82 @@ impl ::protobuf::reflect::ProtobufValue for Features {
/// Nested message and enums of message `Features` /// Nested message and enums of message `Features`
pub mod features { pub mod features {
#[derive(Clone,Copy,PartialEq,Eq,Debug,Hash)]
// @@protoc_insertion_point(enum:hw.trezor.messages.management.Features.BackupAvailability)
pub enum BackupAvailability {
// @@protoc_insertion_point(enum_value:hw.trezor.messages.management.Features.BackupAvailability.NotAvailable)
NotAvailable = 0,
// @@protoc_insertion_point(enum_value:hw.trezor.messages.management.Features.BackupAvailability.Required)
Required = 1,
// @@protoc_insertion_point(enum_value:hw.trezor.messages.management.Features.BackupAvailability.Available)
Available = 2,
}
impl ::protobuf::Enum for BackupAvailability {
const NAME: &'static str = "BackupAvailability";
fn value(&self) -> i32 {
*self as i32
}
fn from_i32(value: i32) -> ::std::option::Option<BackupAvailability> {
match value {
0 => ::std::option::Option::Some(BackupAvailability::NotAvailable),
1 => ::std::option::Option::Some(BackupAvailability::Required),
2 => ::std::option::Option::Some(BackupAvailability::Available),
_ => ::std::option::Option::None
}
}
fn from_str(str: &str) -> ::std::option::Option<BackupAvailability> {
match str {
"NotAvailable" => ::std::option::Option::Some(BackupAvailability::NotAvailable),
"Required" => ::std::option::Option::Some(BackupAvailability::Required),
"Available" => ::std::option::Option::Some(BackupAvailability::Available),
_ => ::std::option::Option::None
}
}
const VALUES: &'static [BackupAvailability] = &[
BackupAvailability::NotAvailable,
BackupAvailability::Required,
BackupAvailability::Available,
];
}
impl ::protobuf::EnumFull for BackupAvailability {
fn enum_descriptor() -> ::protobuf::reflect::EnumDescriptor {
static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::EnumDescriptor> = ::protobuf::rt::Lazy::new();
descriptor.get(|| super::file_descriptor().enum_by_package_relative_name("Features.BackupAvailability").unwrap()).clone()
}
fn descriptor(&self) -> ::protobuf::reflect::EnumValueDescriptor {
let index = *self as usize;
Self::enum_descriptor().value_by_index(index)
}
}
impl ::std::default::Default for BackupAvailability {
fn default() -> Self {
BackupAvailability::NotAvailable
}
}
impl BackupAvailability {
pub(in super) fn generated_enum_descriptor_data() -> ::protobuf::reflect::GeneratedEnumDescriptorData {
::protobuf::reflect::GeneratedEnumDescriptorData::new::<BackupAvailability>("Features.BackupAvailability")
}
}
#[derive(Clone,Copy,PartialEq,Eq,Debug,Hash)] #[derive(Clone,Copy,PartialEq,Eq,Debug,Hash)]
// @@protoc_insertion_point(enum:hw.trezor.messages.management.Features.RecoveryStatus) // @@protoc_insertion_point(enum:hw.trezor.messages.management.Features.RecoveryStatus)
pub enum RecoveryStatus { pub enum RecoveryStatus {
// @@protoc_insertion_point(enum_value:hw.trezor.messages.management.Features.RecoveryStatus.NoRecovery) // @@protoc_insertion_point(enum_value:hw.trezor.messages.management.Features.RecoveryStatus.Nothing)
NoRecovery = 0, Nothing = 0,
// @@protoc_insertion_point(enum_value:hw.trezor.messages.management.Features.RecoveryStatus.InNormalRecovery) // @@protoc_insertion_point(enum_value:hw.trezor.messages.management.Features.RecoveryStatus.Recovery)
InNormalRecovery = 1, Recovery = 1,
// @@protoc_insertion_point(enum_value:hw.trezor.messages.management.Features.RecoveryStatus.InDryRunRecovery) // @@protoc_insertion_point(enum_value:hw.trezor.messages.management.Features.RecoveryStatus.Backup)
InDryRunRecovery = 2, Backup = 2,
// @@protoc_insertion_point(enum_value:hw.trezor.messages.management.Features.RecoveryStatus.InUnlockRepeatedBackupRecovery)
InUnlockRepeatedBackupRecovery = 3,
} }
impl ::protobuf::Enum for RecoveryStatus { impl ::protobuf::Enum for RecoveryStatus {
@ -2513,29 +2621,26 @@ pub mod features {
fn from_i32(value: i32) -> ::std::option::Option<RecoveryStatus> { fn from_i32(value: i32) -> ::std::option::Option<RecoveryStatus> {
match value { match value {
0 => ::std::option::Option::Some(RecoveryStatus::NoRecovery), 0 => ::std::option::Option::Some(RecoveryStatus::Nothing),
1 => ::std::option::Option::Some(RecoveryStatus::InNormalRecovery), 1 => ::std::option::Option::Some(RecoveryStatus::Recovery),
2 => ::std::option::Option::Some(RecoveryStatus::InDryRunRecovery), 2 => ::std::option::Option::Some(RecoveryStatus::Backup),
3 => ::std::option::Option::Some(RecoveryStatus::InUnlockRepeatedBackupRecovery),
_ => ::std::option::Option::None _ => ::std::option::Option::None
} }
} }
fn from_str(str: &str) -> ::std::option::Option<RecoveryStatus> { fn from_str(str: &str) -> ::std::option::Option<RecoveryStatus> {
match str { match str {
"NoRecovery" => ::std::option::Option::Some(RecoveryStatus::NoRecovery), "Nothing" => ::std::option::Option::Some(RecoveryStatus::Nothing),
"InNormalRecovery" => ::std::option::Option::Some(RecoveryStatus::InNormalRecovery), "Recovery" => ::std::option::Option::Some(RecoveryStatus::Recovery),
"InDryRunRecovery" => ::std::option::Option::Some(RecoveryStatus::InDryRunRecovery), "Backup" => ::std::option::Option::Some(RecoveryStatus::Backup),
"InUnlockRepeatedBackupRecovery" => ::std::option::Option::Some(RecoveryStatus::InUnlockRepeatedBackupRecovery),
_ => ::std::option::Option::None _ => ::std::option::Option::None
} }
} }
const VALUES: &'static [RecoveryStatus] = &[ const VALUES: &'static [RecoveryStatus] = &[
RecoveryStatus::NoRecovery, RecoveryStatus::Nothing,
RecoveryStatus::InNormalRecovery, RecoveryStatus::Recovery,
RecoveryStatus::InDryRunRecovery, RecoveryStatus::Backup,
RecoveryStatus::InUnlockRepeatedBackupRecovery,
]; ];
} }
@ -2553,7 +2658,7 @@ pub mod features {
impl ::std::default::Default for RecoveryStatus { impl ::std::default::Default for RecoveryStatus {
fn default() -> Self { fn default() -> Self {
RecoveryStatus::NoRecovery RecoveryStatus::Nothing
} }
} }
@ -7839,12 +7944,12 @@ pub struct RecoveryDevice {
pub label: ::std::option::Option<::std::string::String>, pub label: ::std::option::Option<::std::string::String>,
// @@protoc_insertion_point(field:hw.trezor.messages.management.RecoveryDevice.enforce_wordlist) // @@protoc_insertion_point(field:hw.trezor.messages.management.RecoveryDevice.enforce_wordlist)
pub enforce_wordlist: ::std::option::Option<bool>, pub enforce_wordlist: ::std::option::Option<bool>,
// @@protoc_insertion_point(field:hw.trezor.messages.management.RecoveryDevice.type) // @@protoc_insertion_point(field:hw.trezor.messages.management.RecoveryDevice.input_method)
pub type_: ::std::option::Option<::protobuf::EnumOrUnknown<recovery_device::RecoveryDeviceType>>, pub input_method: ::std::option::Option<::protobuf::EnumOrUnknown<recovery_device::RecoveryDeviceInputMethod>>,
// @@protoc_insertion_point(field:hw.trezor.messages.management.RecoveryDevice.u2f_counter) // @@protoc_insertion_point(field:hw.trezor.messages.management.RecoveryDevice.u2f_counter)
pub u2f_counter: ::std::option::Option<u32>, pub u2f_counter: ::std::option::Option<u32>,
// @@protoc_insertion_point(field:hw.trezor.messages.management.RecoveryDevice.kind) // @@protoc_insertion_point(field:hw.trezor.messages.management.RecoveryDevice.type)
pub kind: ::std::option::Option<::protobuf::EnumOrUnknown<recovery_device::RecoveryKind>>, pub type_: ::std::option::Option<::protobuf::EnumOrUnknown<RecoveryType>>,
// special fields // special fields
// @@protoc_insertion_point(special_field:hw.trezor.messages.management.RecoveryDevice.special_fields) // @@protoc_insertion_point(special_field:hw.trezor.messages.management.RecoveryDevice.special_fields)
pub special_fields: ::protobuf::SpecialFields, pub special_fields: ::protobuf::SpecialFields,
@ -8009,26 +8114,26 @@ impl RecoveryDevice {
self.enforce_wordlist = ::std::option::Option::Some(v); self.enforce_wordlist = ::std::option::Option::Some(v);
} }
// optional .hw.trezor.messages.management.RecoveryDevice.RecoveryDeviceType type = 8; // optional .hw.trezor.messages.management.RecoveryDevice.RecoveryDeviceInputMethod input_method = 8;
pub fn type_(&self) -> recovery_device::RecoveryDeviceType { pub fn input_method(&self) -> recovery_device::RecoveryDeviceInputMethod {
match self.type_ { match self.input_method {
Some(e) => e.enum_value_or(recovery_device::RecoveryDeviceType::RecoveryDeviceType_ScrambledWords), Some(e) => e.enum_value_or(recovery_device::RecoveryDeviceInputMethod::ScrambledWords),
None => recovery_device::RecoveryDeviceType::RecoveryDeviceType_ScrambledWords, None => recovery_device::RecoveryDeviceInputMethod::ScrambledWords,
} }
} }
pub fn clear_type_(&mut self) { pub fn clear_input_method(&mut self) {
self.type_ = ::std::option::Option::None; self.input_method = ::std::option::Option::None;
} }
pub fn has_type(&self) -> bool { pub fn has_input_method(&self) -> bool {
self.type_.is_some() self.input_method.is_some()
} }
// Param is passed by value, moved // Param is passed by value, moved
pub fn set_type(&mut self, v: recovery_device::RecoveryDeviceType) { pub fn set_input_method(&mut self, v: recovery_device::RecoveryDeviceInputMethod) {
self.type_ = ::std::option::Option::Some(::protobuf::EnumOrUnknown::new(v)); self.input_method = ::std::option::Option::Some(::protobuf::EnumOrUnknown::new(v));
} }
// optional uint32 u2f_counter = 9; // optional uint32 u2f_counter = 9;
@ -8050,26 +8155,26 @@ impl RecoveryDevice {
self.u2f_counter = ::std::option::Option::Some(v); self.u2f_counter = ::std::option::Option::Some(v);
} }
// optional .hw.trezor.messages.management.RecoveryDevice.RecoveryKind kind = 10; // optional .hw.trezor.messages.management.RecoveryType type = 10;
pub fn kind(&self) -> recovery_device::RecoveryKind { pub fn type_(&self) -> RecoveryType {
match self.kind { match self.type_ {
Some(e) => e.enum_value_or(recovery_device::RecoveryKind::NormalRecovery), Some(e) => e.enum_value_or(RecoveryType::NormalRecovery),
None => recovery_device::RecoveryKind::NormalRecovery, None => RecoveryType::NormalRecovery,
} }
} }
pub fn clear_kind(&mut self) { pub fn clear_type_(&mut self) {
self.kind = ::std::option::Option::None; self.type_ = ::std::option::Option::None;
} }
pub fn has_kind(&self) -> bool { pub fn has_type(&self) -> bool {
self.kind.is_some() self.type_.is_some()
} }
// Param is passed by value, moved // Param is passed by value, moved
pub fn set_kind(&mut self, v: recovery_device::RecoveryKind) { pub fn set_type(&mut self, v: RecoveryType) {
self.kind = ::std::option::Option::Some(::protobuf::EnumOrUnknown::new(v)); self.type_ = ::std::option::Option::Some(::protobuf::EnumOrUnknown::new(v));
} }
fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData {
@ -8106,9 +8211,9 @@ impl RecoveryDevice {
|m: &mut RecoveryDevice| { &mut m.enforce_wordlist }, |m: &mut RecoveryDevice| { &mut m.enforce_wordlist },
)); ));
fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>(
"type", "input_method",
|m: &RecoveryDevice| { &m.type_ }, |m: &RecoveryDevice| { &m.input_method },
|m: &mut RecoveryDevice| { &mut m.type_ }, |m: &mut RecoveryDevice| { &mut m.input_method },
)); ));
fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>(
"u2f_counter", "u2f_counter",
@ -8116,9 +8221,9 @@ impl RecoveryDevice {
|m: &mut RecoveryDevice| { &mut m.u2f_counter }, |m: &mut RecoveryDevice| { &mut m.u2f_counter },
)); ));
fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>(
"kind", "type",
|m: &RecoveryDevice| { &m.kind }, |m: &RecoveryDevice| { &m.type_ },
|m: &mut RecoveryDevice| { &mut m.kind }, |m: &mut RecoveryDevice| { &mut m.type_ },
)); ));
::protobuf::reflect::GeneratedMessageDescriptorData::new_2::<RecoveryDevice>( ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::<RecoveryDevice>(
"RecoveryDevice", "RecoveryDevice",
@ -8157,13 +8262,13 @@ impl ::protobuf::Message for RecoveryDevice {
self.enforce_wordlist = ::std::option::Option::Some(is.read_bool()?); self.enforce_wordlist = ::std::option::Option::Some(is.read_bool()?);
}, },
64 => { 64 => {
self.type_ = ::std::option::Option::Some(is.read_enum_or_unknown()?); self.input_method = ::std::option::Option::Some(is.read_enum_or_unknown()?);
}, },
72 => { 72 => {
self.u2f_counter = ::std::option::Option::Some(is.read_uint32()?); self.u2f_counter = ::std::option::Option::Some(is.read_uint32()?);
}, },
80 => { 80 => {
self.kind = ::std::option::Option::Some(is.read_enum_or_unknown()?); self.type_ = ::std::option::Option::Some(is.read_enum_or_unknown()?);
}, },
tag => { tag => {
::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?;
@ -8195,13 +8300,13 @@ impl ::protobuf::Message for RecoveryDevice {
if let Some(v) = self.enforce_wordlist { if let Some(v) = self.enforce_wordlist {
my_size += 1 + 1; my_size += 1 + 1;
} }
if let Some(v) = self.type_ { if let Some(v) = self.input_method {
my_size += ::protobuf::rt::int32_size(8, v.value()); my_size += ::protobuf::rt::int32_size(8, v.value());
} }
if let Some(v) = self.u2f_counter { if let Some(v) = self.u2f_counter {
my_size += ::protobuf::rt::uint32_size(9, v); my_size += ::protobuf::rt::uint32_size(9, v);
} }
if let Some(v) = self.kind { if let Some(v) = self.type_ {
my_size += ::protobuf::rt::int32_size(10, v.value()); my_size += ::protobuf::rt::int32_size(10, v.value());
} }
my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields());
@ -8228,13 +8333,13 @@ impl ::protobuf::Message for RecoveryDevice {
if let Some(v) = self.enforce_wordlist { if let Some(v) = self.enforce_wordlist {
os.write_bool(6, v)?; os.write_bool(6, v)?;
} }
if let Some(v) = self.type_ { if let Some(v) = self.input_method {
os.write_enum(8, ::protobuf::EnumOrUnknown::value(&v))?; os.write_enum(8, ::protobuf::EnumOrUnknown::value(&v))?;
} }
if let Some(v) = self.u2f_counter { if let Some(v) = self.u2f_counter {
os.write_uint32(9, v)?; os.write_uint32(9, v)?;
} }
if let Some(v) = self.kind { if let Some(v) = self.type_ {
os.write_enum(10, ::protobuf::EnumOrUnknown::value(&v))?; os.write_enum(10, ::protobuf::EnumOrUnknown::value(&v))?;
} }
os.write_unknown_fields(self.special_fields.unknown_fields())?; os.write_unknown_fields(self.special_fields.unknown_fields())?;
@ -8260,9 +8365,9 @@ impl ::protobuf::Message for RecoveryDevice {
self.language = ::std::option::Option::None; self.language = ::std::option::Option::None;
self.label = ::std::option::Option::None; self.label = ::std::option::Option::None;
self.enforce_wordlist = ::std::option::Option::None; self.enforce_wordlist = ::std::option::Option::None;
self.type_ = ::std::option::Option::None; self.input_method = ::std::option::Option::None;
self.u2f_counter = ::std::option::Option::None; self.u2f_counter = ::std::option::Option::None;
self.kind = ::std::option::Option::None; self.type_ = ::std::option::Option::None;
self.special_fields.clear(); self.special_fields.clear();
} }
@ -8274,9 +8379,9 @@ impl ::protobuf::Message for RecoveryDevice {
language: ::std::option::Option::None, language: ::std::option::Option::None,
label: ::std::option::Option::None, label: ::std::option::Option::None,
enforce_wordlist: ::std::option::Option::None, enforce_wordlist: ::std::option::Option::None,
type_: ::std::option::Option::None, input_method: ::std::option::Option::None,
u2f_counter: ::std::option::Option::None, u2f_counter: ::std::option::Option::None,
kind: ::std::option::Option::None, type_: ::std::option::Option::None,
special_fields: ::protobuf::SpecialFields::new(), special_fields: ::protobuf::SpecialFields::new(),
}; };
&instance &instance
@ -8303,47 +8408,47 @@ impl ::protobuf::reflect::ProtobufValue for RecoveryDevice {
/// Nested message and enums of message `RecoveryDevice` /// Nested message and enums of message `RecoveryDevice`
pub mod recovery_device { pub mod recovery_device {
#[derive(Clone,Copy,PartialEq,Eq,Debug,Hash)] #[derive(Clone,Copy,PartialEq,Eq,Debug,Hash)]
// @@protoc_insertion_point(enum:hw.trezor.messages.management.RecoveryDevice.RecoveryDeviceType) // @@protoc_insertion_point(enum:hw.trezor.messages.management.RecoveryDevice.RecoveryDeviceInputMethod)
pub enum RecoveryDeviceType { pub enum RecoveryDeviceInputMethod {
// @@protoc_insertion_point(enum_value:hw.trezor.messages.management.RecoveryDevice.RecoveryDeviceType.RecoveryDeviceType_ScrambledWords) // @@protoc_insertion_point(enum_value:hw.trezor.messages.management.RecoveryDevice.RecoveryDeviceInputMethod.ScrambledWords)
RecoveryDeviceType_ScrambledWords = 0, ScrambledWords = 0,
// @@protoc_insertion_point(enum_value:hw.trezor.messages.management.RecoveryDevice.RecoveryDeviceType.RecoveryDeviceType_Matrix) // @@protoc_insertion_point(enum_value:hw.trezor.messages.management.RecoveryDevice.RecoveryDeviceInputMethod.Matrix)
RecoveryDeviceType_Matrix = 1, Matrix = 1,
} }
impl ::protobuf::Enum for RecoveryDeviceType { impl ::protobuf::Enum for RecoveryDeviceInputMethod {
const NAME: &'static str = "RecoveryDeviceType"; const NAME: &'static str = "RecoveryDeviceInputMethod";
fn value(&self) -> i32 { fn value(&self) -> i32 {
*self as i32 *self as i32
} }
fn from_i32(value: i32) -> ::std::option::Option<RecoveryDeviceType> { fn from_i32(value: i32) -> ::std::option::Option<RecoveryDeviceInputMethod> {
match value { match value {
0 => ::std::option::Option::Some(RecoveryDeviceType::RecoveryDeviceType_ScrambledWords), 0 => ::std::option::Option::Some(RecoveryDeviceInputMethod::ScrambledWords),
1 => ::std::option::Option::Some(RecoveryDeviceType::RecoveryDeviceType_Matrix), 1 => ::std::option::Option::Some(RecoveryDeviceInputMethod::Matrix),
_ => ::std::option::Option::None _ => ::std::option::Option::None
} }
} }
fn from_str(str: &str) -> ::std::option::Option<RecoveryDeviceType> { fn from_str(str: &str) -> ::std::option::Option<RecoveryDeviceInputMethod> {
match str { match str {
"RecoveryDeviceType_ScrambledWords" => ::std::option::Option::Some(RecoveryDeviceType::RecoveryDeviceType_ScrambledWords), "ScrambledWords" => ::std::option::Option::Some(RecoveryDeviceInputMethod::ScrambledWords),
"RecoveryDeviceType_Matrix" => ::std::option::Option::Some(RecoveryDeviceType::RecoveryDeviceType_Matrix), "Matrix" => ::std::option::Option::Some(RecoveryDeviceInputMethod::Matrix),
_ => ::std::option::Option::None _ => ::std::option::Option::None
} }
} }
const VALUES: &'static [RecoveryDeviceType] = &[ const VALUES: &'static [RecoveryDeviceInputMethod] = &[
RecoveryDeviceType::RecoveryDeviceType_ScrambledWords, RecoveryDeviceInputMethod::ScrambledWords,
RecoveryDeviceType::RecoveryDeviceType_Matrix, RecoveryDeviceInputMethod::Matrix,
]; ];
} }
impl ::protobuf::EnumFull for RecoveryDeviceType { impl ::protobuf::EnumFull for RecoveryDeviceInputMethod {
fn enum_descriptor() -> ::protobuf::reflect::EnumDescriptor { fn enum_descriptor() -> ::protobuf::reflect::EnumDescriptor {
static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::EnumDescriptor> = ::protobuf::rt::Lazy::new(); static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::EnumDescriptor> = ::protobuf::rt::Lazy::new();
descriptor.get(|| super::file_descriptor().enum_by_package_relative_name("RecoveryDevice.RecoveryDeviceType").unwrap()).clone() descriptor.get(|| super::file_descriptor().enum_by_package_relative_name("RecoveryDevice.RecoveryDeviceInputMethod").unwrap()).clone()
} }
fn descriptor(&self) -> ::protobuf::reflect::EnumValueDescriptor { fn descriptor(&self) -> ::protobuf::reflect::EnumValueDescriptor {
@ -8352,82 +8457,15 @@ pub mod recovery_device {
} }
} }
impl ::std::default::Default for RecoveryDeviceType { impl ::std::default::Default for RecoveryDeviceInputMethod {
fn default() -> Self { fn default() -> Self {
RecoveryDeviceType::RecoveryDeviceType_ScrambledWords RecoveryDeviceInputMethod::ScrambledWords
} }
} }
impl RecoveryDeviceType { impl RecoveryDeviceInputMethod {
pub(in super) fn generated_enum_descriptor_data() -> ::protobuf::reflect::GeneratedEnumDescriptorData { pub(in super) fn generated_enum_descriptor_data() -> ::protobuf::reflect::GeneratedEnumDescriptorData {
::protobuf::reflect::GeneratedEnumDescriptorData::new::<RecoveryDeviceType>("RecoveryDevice.RecoveryDeviceType") ::protobuf::reflect::GeneratedEnumDescriptorData::new::<RecoveryDeviceInputMethod>("RecoveryDevice.RecoveryDeviceInputMethod")
}
}
#[derive(Clone,Copy,PartialEq,Eq,Debug,Hash)]
// @@protoc_insertion_point(enum:hw.trezor.messages.management.RecoveryDevice.RecoveryKind)
pub enum RecoveryKind {
// @@protoc_insertion_point(enum_value:hw.trezor.messages.management.RecoveryDevice.RecoveryKind.NormalRecovery)
NormalRecovery = 0,
// @@protoc_insertion_point(enum_value:hw.trezor.messages.management.RecoveryDevice.RecoveryKind.DryRun)
DryRun = 1,
// @@protoc_insertion_point(enum_value:hw.trezor.messages.management.RecoveryDevice.RecoveryKind.UnlockRepeatedBackup)
UnlockRepeatedBackup = 2,
}
impl ::protobuf::Enum for RecoveryKind {
const NAME: &'static str = "RecoveryKind";
fn value(&self) -> i32 {
*self as i32
}
fn from_i32(value: i32) -> ::std::option::Option<RecoveryKind> {
match value {
0 => ::std::option::Option::Some(RecoveryKind::NormalRecovery),
1 => ::std::option::Option::Some(RecoveryKind::DryRun),
2 => ::std::option::Option::Some(RecoveryKind::UnlockRepeatedBackup),
_ => ::std::option::Option::None
}
}
fn from_str(str: &str) -> ::std::option::Option<RecoveryKind> {
match str {
"NormalRecovery" => ::std::option::Option::Some(RecoveryKind::NormalRecovery),
"DryRun" => ::std::option::Option::Some(RecoveryKind::DryRun),
"UnlockRepeatedBackup" => ::std::option::Option::Some(RecoveryKind::UnlockRepeatedBackup),
_ => ::std::option::Option::None
}
}
const VALUES: &'static [RecoveryKind] = &[
RecoveryKind::NormalRecovery,
RecoveryKind::DryRun,
RecoveryKind::UnlockRepeatedBackup,
];
}
impl ::protobuf::EnumFull for RecoveryKind {
fn enum_descriptor() -> ::protobuf::reflect::EnumDescriptor {
static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::EnumDescriptor> = ::protobuf::rt::Lazy::new();
descriptor.get(|| super::file_descriptor().enum_by_package_relative_name("RecoveryDevice.RecoveryKind").unwrap()).clone()
}
fn descriptor(&self) -> ::protobuf::reflect::EnumValueDescriptor {
let index = *self as usize;
Self::enum_descriptor().value_by_index(index)
}
}
impl ::std::default::Default for RecoveryKind {
fn default() -> Self {
RecoveryKind::NormalRecovery
}
}
impl RecoveryKind {
pub(in super) fn generated_enum_descriptor_data() -> ::protobuf::reflect::GeneratedEnumDescriptorData {
::protobuf::reflect::GeneratedEnumDescriptorData::new::<RecoveryKind>("RecoveryDevice.RecoveryKind")
} }
} }
} }
@ -10979,12 +11017,79 @@ impl HomescreenFormat {
} }
} }
#[derive(Clone,Copy,PartialEq,Eq,Debug,Hash)]
// @@protoc_insertion_point(enum:hw.trezor.messages.management.RecoveryType)
pub enum RecoveryType {
// @@protoc_insertion_point(enum_value:hw.trezor.messages.management.RecoveryType.NormalRecovery)
NormalRecovery = 0,
// @@protoc_insertion_point(enum_value:hw.trezor.messages.management.RecoveryType.DryRun)
DryRun = 1,
// @@protoc_insertion_point(enum_value:hw.trezor.messages.management.RecoveryType.UnlockRepeatedBackup)
UnlockRepeatedBackup = 2,
}
impl ::protobuf::Enum for RecoveryType {
const NAME: &'static str = "RecoveryType";
fn value(&self) -> i32 {
*self as i32
}
fn from_i32(value: i32) -> ::std::option::Option<RecoveryType> {
match value {
0 => ::std::option::Option::Some(RecoveryType::NormalRecovery),
1 => ::std::option::Option::Some(RecoveryType::DryRun),
2 => ::std::option::Option::Some(RecoveryType::UnlockRepeatedBackup),
_ => ::std::option::Option::None
}
}
fn from_str(str: &str) -> ::std::option::Option<RecoveryType> {
match str {
"NormalRecovery" => ::std::option::Option::Some(RecoveryType::NormalRecovery),
"DryRun" => ::std::option::Option::Some(RecoveryType::DryRun),
"UnlockRepeatedBackup" => ::std::option::Option::Some(RecoveryType::UnlockRepeatedBackup),
_ => ::std::option::Option::None
}
}
const VALUES: &'static [RecoveryType] = &[
RecoveryType::NormalRecovery,
RecoveryType::DryRun,
RecoveryType::UnlockRepeatedBackup,
];
}
impl ::protobuf::EnumFull for RecoveryType {
fn enum_descriptor() -> ::protobuf::reflect::EnumDescriptor {
static descriptor: ::protobuf::rt::Lazy<::protobuf::reflect::EnumDescriptor> = ::protobuf::rt::Lazy::new();
descriptor.get(|| file_descriptor().enum_by_package_relative_name("RecoveryType").unwrap()).clone()
}
fn descriptor(&self) -> ::protobuf::reflect::EnumValueDescriptor {
let index = *self as usize;
Self::enum_descriptor().value_by_index(index)
}
}
impl ::std::default::Default for RecoveryType {
fn default() -> Self {
RecoveryType::NormalRecovery
}
}
impl RecoveryType {
fn generated_enum_descriptor_data() -> ::protobuf::reflect::GeneratedEnumDescriptorData {
::protobuf::reflect::GeneratedEnumDescriptorData::new::<RecoveryType>("RecoveryType")
}
}
static file_descriptor_proto_data: &'static [u8] = b"\ static file_descriptor_proto_data: &'static [u8] = b"\
\n\x19messages-management.proto\x12\x1dhw.trezor.messages.management\x1a\ \n\x19messages-management.proto\x12\x1dhw.trezor.messages.management\x1a\
\x0emessages.proto\"\x80\x01\n\nInitialize\x12\x1d\n\nsession_id\x18\x01\ \x0emessages.proto\"\x80\x01\n\nInitialize\x12\x1d\n\nsession_id\x18\x01\
\x20\x01(\x0cR\tsessionId\x12,\n\x10_skip_passphrase\x18\x02\x20\x01(\ \x20\x01(\x0cR\tsessionId\x12,\n\x10_skip_passphrase\x18\x02\x20\x01(\
\x08R\x0eSkipPassphraseB\x02\x18\x01\x12%\n\x0ederive_cardano\x18\x03\ \x08R\x0eSkipPassphraseB\x02\x18\x01\x12%\n\x0ederive_cardano\x18\x03\
\x20\x01(\x08R\rderiveCardano\"\r\n\x0bGetFeatures\"\x8f\x16\n\x08Featur\ \x20\x01(\x08R\rderiveCardano\"\r\n\x0bGetFeatures\"\xb7\x17\n\x08Featur\
es\x12\x16\n\x06vendor\x18\x01\x20\x01(\tR\x06vendor\x12#\n\rmajor_versi\ es\x12\x16\n\x06vendor\x18\x01\x20\x01(\tR\x06vendor\x12#\n\rmajor_versi\
on\x18\x02\x20\x02(\rR\x0cmajorVersion\x12#\n\rminor_version\x18\x03\x20\ on\x18\x02\x20\x02(\rR\x0cmajorVersion\x12#\n\rminor_version\x18\x03\x20\
\x02(\rR\x0cminorVersion\x12#\n\rpatch_version\x18\x04\x20\x02(\rR\x0cpa\ \x02(\rR\x0cminorVersion\x12#\n\rpatch_version\x18\x04\x20\x02(\rR\x0cpa\
@ -10999,17 +11104,18 @@ static file_descriptor_proto_data: &'static [u8] = b"\
\x18\x0f\x20\x01(\x08R\x08imported\x12\x1a\n\x08unlocked\x18\x10\x20\x01\ \x18\x0f\x20\x01(\x08R\x08imported\x12\x1a\n\x08unlocked\x18\x10\x20\x01\
(\x08R\x08unlocked\x120\n\x12_passphrase_cached\x18\x11\x20\x01(\x08R\ (\x08R\x08unlocked\x120\n\x12_passphrase_cached\x18\x11\x20\x01(\x08R\
\x10PassphraseCachedB\x02\x18\x01\x12)\n\x10firmware_present\x18\x12\x20\ \x10PassphraseCachedB\x02\x18\x01\x12)\n\x10firmware_present\x18\x12\x20\
\x01(\x08R\x0ffirmwarePresent\x12!\n\x0cneeds_backup\x18\x13\x20\x01(\ \x01(\x08R\x0ffirmwarePresent\x12k\n\x13backup_availability\x18\x13\x20\
\x08R\x0bneedsBackup\x12\x14\n\x05flags\x18\x14\x20\x01(\rR\x05flags\x12\ \x01(\x0e2:.hw.trezor.messages.management.Features.BackupAvailabilityR\
\x14\n\x05model\x18\x15\x20\x01(\tR\x05model\x12\x19\n\x08fw_major\x18\ \x12backupAvailability\x12\x14\n\x05flags\x18\x14\x20\x01(\rR\x05flags\
\x16\x20\x01(\rR\x07fwMajor\x12\x19\n\x08fw_minor\x18\x17\x20\x01(\rR\ \x12\x14\n\x05model\x18\x15\x20\x01(\tR\x05model\x12\x19\n\x08fw_major\
\x07fwMinor\x12\x19\n\x08fw_patch\x18\x18\x20\x01(\rR\x07fwPatch\x12\x1b\ \x18\x16\x20\x01(\rR\x07fwMajor\x12\x19\n\x08fw_minor\x18\x17\x20\x01(\r\
\n\tfw_vendor\x18\x19\x20\x01(\tR\x08fwVendor\x12+\n\x11unfinished_backu\ R\x07fwMinor\x12\x19\n\x08fw_patch\x18\x18\x20\x01(\rR\x07fwPatch\x12\
p\x18\x1b\x20\x01(\x08R\x10unfinishedBackup\x12\x1b\n\tno_backup\x18\x1c\ \x1b\n\tfw_vendor\x18\x19\x20\x01(\tR\x08fwVendor\x12+\n\x11unfinished_b\
\x20\x01(\x08R\x08noBackup\x12_\n\x0frecovery_status\x18\x1d\x20\x01(\ ackup\x18\x1b\x20\x01(\x08R\x10unfinishedBackup\x12\x1b\n\tno_backup\x18\
\x0e26.hw.trezor.messages.management.Features.RecoveryStatusR\x0erecover\ \x1c\x20\x01(\x08R\x08noBackup\x12_\n\x0frecovery_status\x18\x1d\x20\x01\
yStatus\x12V\n\x0ccapabilities\x18\x1e\x20\x03(\x0e22.hw.trezor.messages\ (\x0e26.hw.trezor.messages.management.Features.RecoveryStatusR\x0erecove\
.management.Features.CapabilityR\x0ccapabilities\x12J\n\x0bbackup_type\ ryStatus\x12V\n\x0ccapabilities\x18\x1e\x20\x03(\x0e22.hw.trezor.message\
s.management.Features.CapabilityR\x0ccapabilities\x12J\n\x0bbackup_type\
\x18\x1f\x20\x01(\x0e2).hw.trezor.messages.management.BackupTypeR\nbacku\ \x18\x1f\x20\x01(\x0e2).hw.trezor.messages.management.BackupTypeR\nbacku\
pType\x12&\n\x0fsd_card_present\x18\x20\x20\x01(\x08R\rsdCardPresent\x12\ pType\x12&\n\x0fsd_card_present\x18\x20\x20\x01(\x08R\rsdCardPresent\x12\
#\n\rsd_protection\x18!\x20\x01(\x08R\x0csdProtection\x120\n\x14wipe_cod\ #\n\rsd_protection\x18!\x20\x01(\x08R\x0csdProtection\x120\n\x14wipe_cod\
@ -11031,35 +11137,37 @@ static file_descriptor_proto_data: &'static [u8] = b"\
\x20\x01(\x08R\x10bootloaderLocked\x12>\n\x18language_version_matches\ \x20\x01(\x08R\x10bootloaderLocked\x12>\n\x18language_version_matches\
\x182\x20\x01(\x08:\x04trueR\x16languageVersionMatches\x12%\n\x0eunit_pa\ \x182\x20\x01(\x08:\x04trueR\x16languageVersionMatches\x12%\n\x0eunit_pa\
ckaging\x183\x20\x01(\rR\runitPackaging\x12'\n\x0fhaptic_feedback\x184\ ckaging\x183\x20\x01(\rR\runitPackaging\x12'\n\x0fhaptic_feedback\x184\
\x20\x01(\x08R\x0ehapticFeedback\"p\n\x0eRecoveryStatus\x12\x0e\n\nNoRec\ \x20\x01(\x08R\x0ehapticFeedback\x12P\n\rrecovery_type\x185\x20\x01(\x0e\
overy\x10\0\x12\x14\n\x10InNormalRecovery\x10\x01\x12\x14\n\x10InDryRunR\ 2+.hw.trezor.messages.management.RecoveryTypeR\x0crecoveryType\"C\n\x12B\
ecovery\x10\x02\x12\"\n\x1eInUnlockRepeatedBackupRecovery\x10\x03\"\xc2\ ackupAvailability\x12\x10\n\x0cNotAvailable\x10\0\x12\x0c\n\x08Required\
\x04\n\nCapability\x12\x1c\n\x12Capability_Bitcoin\x10\x01\x1a\x04\x80\ \x10\x01\x12\r\n\tAvailable\x10\x02\"7\n\x0eRecoveryStatus\x12\x0b\n\x07\
\xa6\x1d\x01\x12\x1b\n\x17Capability_Bitcoin_like\x10\x02\x12\x16\n\x12C\ Nothing\x10\0\x12\x0c\n\x08Recovery\x10\x01\x12\n\n\x06Backup\x10\x02\"\
apability_Binance\x10\x03\x12\x16\n\x12Capability_Cardano\x10\x04\x12\ \xc2\x04\n\nCapability\x12\x1c\n\x12Capability_Bitcoin\x10\x01\x1a\x04\
\x1b\n\x11Capability_Crypto\x10\x05\x1a\x04\x80\xa6\x1d\x01\x12\x12\n\ \x80\xa6\x1d\x01\x12\x1b\n\x17Capability_Bitcoin_like\x10\x02\x12\x16\n\
\x0eCapability_EOS\x10\x06\x12\x17\n\x13Capability_Ethereum\x10\x07\x12\ \x12Capability_Binance\x10\x03\x12\x16\n\x12Capability_Cardano\x10\x04\
\x17\n\x0fCapability_Lisk\x10\x08\x1a\x02\x08\x01\x12\x15\n\x11Capabilit\ \x12\x1b\n\x11Capability_Crypto\x10\x05\x1a\x04\x80\xa6\x1d\x01\x12\x12\
y_Monero\x10\t\x12\x12\n\x0eCapability_NEM\x10\n\x12\x15\n\x11Capability\ \n\x0eCapability_EOS\x10\x06\x12\x17\n\x13Capability_Ethereum\x10\x07\
_Ripple\x10\x0b\x12\x16\n\x12Capability_Stellar\x10\x0c\x12\x14\n\x10Cap\ \x12\x17\n\x0fCapability_Lisk\x10\x08\x1a\x02\x08\x01\x12\x15\n\x11Capab\
ability_Tezos\x10\r\x12\x12\n\x0eCapability_U2F\x10\x0e\x12\x1b\n\x11Cap\ ility_Monero\x10\t\x12\x12\n\x0eCapability_NEM\x10\n\x12\x15\n\x11Capabi\
ability_Shamir\x10\x0f\x1a\x04\x80\xa6\x1d\x01\x12!\n\x17Capability_Sham\ lity_Ripple\x10\x0b\x12\x16\n\x12Capability_Stellar\x10\x0c\x12\x14\n\
irGroups\x10\x10\x1a\x04\x80\xa6\x1d\x01\x12$\n\x1aCapability_Passphrase\ \x10Capability_Tezos\x10\r\x12\x12\n\x0eCapability_U2F\x10\x0e\x12\x1b\n\
Entry\x10\x11\x1a\x04\x80\xa6\x1d\x01\x12\x15\n\x11Capability_Solana\x10\ \x11Capability_Shamir\x10\x0f\x1a\x04\x80\xa6\x1d\x01\x12!\n\x17Capabili\
\x12\x12!\n\x17Capability_Translations\x10\x13\x1a\x04\x80\xa6\x1d\x01\ ty_ShamirGroups\x10\x10\x1a\x04\x80\xa6\x1d\x01\x12$\n\x1aCapability_Pas\
\x12\x1f\n\x15Capability_Brightness\x10\x14\x1a\x04\x80\xa6\x1d\x01\x12\ sphraseEntry\x10\x11\x1a\x04\x80\xa6\x1d\x01\x12\x15\n\x11Capability_Sol\
\x1b\n\x11Capability_Haptic\x10\x15\x1a\x04\x80\xa6\x1d\x01\x1a\x04\xc8\ ana\x10\x12\x12!\n\x17Capability_Translations\x10\x13\x1a\x04\x80\xa6\
\xf3\x18\x01\"\x0c\n\nLockDevice\"&\n\x07SetBusy\x12\x1b\n\texpiry_ms\ \x1d\x01\x12\x1f\n\x15Capability_Brightness\x10\x14\x1a\x04\x80\xa6\x1d\
\x18\x01\x20\x01(\rR\x08expiryMs\"\x0c\n\nEndSession\"\xc4\x04\n\rApplyS\ \x01\x12\x1b\n\x11Capability_Haptic\x10\x15\x1a\x04\x80\xa6\x1d\x01\x1a\
ettings\x12\x1e\n\x08language\x18\x01\x20\x01(\tR\x08languageB\x02\x18\ \x04\xc8\xf3\x18\x01\"\x0c\n\nLockDevice\"&\n\x07SetBusy\x12\x1b\n\texpi\
\x01\x12\x14\n\x05label\x18\x02\x20\x01(\tR\x05label\x12%\n\x0euse_passp\ ry_ms\x18\x01\x20\x01(\rR\x08expiryMs\"\x0c\n\nEndSession\"\xc4\x04\n\rA\
hrase\x18\x03\x20\x01(\x08R\rusePassphrase\x12\x1e\n\nhomescreen\x18\x04\ pplySettings\x12\x1e\n\x08language\x18\x01\x20\x01(\tR\x08languageB\x02\
\x20\x01(\x0cR\nhomescreen\x120\n\x12_passphrase_source\x18\x05\x20\x01(\ \x18\x01\x12\x14\n\x05label\x18\x02\x20\x01(\tR\x05label\x12%\n\x0euse_p\
\rR\x10PassphraseSourceB\x02\x18\x01\x12+\n\x12auto_lock_delay_ms\x18\ assphrase\x18\x03\x20\x01(\x08R\rusePassphrase\x12\x1e\n\nhomescreen\x18\
\x06\x20\x01(\rR\x0fautoLockDelayMs\x12)\n\x10display_rotation\x18\x07\ \x04\x20\x01(\x0cR\nhomescreen\x120\n\x12_passphrase_source\x18\x05\x20\
\x20\x01(\rR\x0fdisplayRotation\x12=\n\x1bpassphrase_always_on_device\ \x01(\rR\x10PassphraseSourceB\x02\x18\x01\x12+\n\x12auto_lock_delay_ms\
\x18\x08\x20\x01(\x08R\x18passphraseAlwaysOnDevice\x12T\n\rsafety_checks\ \x18\x06\x20\x01(\rR\x0fautoLockDelayMs\x12)\n\x10display_rotation\x18\
\x18\t\x20\x01(\x0e2/.hw.trezor.messages.management.SafetyCheckLevelR\ \x07\x20\x01(\rR\x0fdisplayRotation\x12=\n\x1bpassphrase_always_on_devic\
e\x18\x08\x20\x01(\x08R\x18passphraseAlwaysOnDevice\x12T\n\rsafety_check\
s\x18\t\x20\x01(\x0e2/.hw.trezor.messages.management.SafetyCheckLevelR\
\x0csafetyChecks\x123\n\x15experimental_features\x18\n\x20\x01(\x08R\x14\ \x0csafetyChecks\x123\n\x15experimental_features\x18\n\x20\x01(\x08R\x14\
experimentalFeatures\x129\n\x19hide_passphrase_from_host\x18\x0b\x20\x01\ experimentalFeatures\x129\n\x19hide_passphrase_from_host\x18\x0b\x20\x01\
(\x08R\x16hidePassphraseFromHost\x12'\n\x0fhaptic_feedback\x18\r\x20\x01\ (\x08R\x16hidePassphraseFromHost\x12'\n\x0fhaptic_feedback\x18\r\x20\x01\
@ -11107,25 +11215,23 @@ static file_descriptor_proto_data: &'static [u8] = b"\
ackupDevice.Slip39GroupR\x06groups\x1a[\n\x0bSlip39Group\x12)\n\x10membe\ ackupDevice.Slip39GroupR\x06groups\x1a[\n\x0bSlip39Group\x12)\n\x10membe\
r_threshold\x18\x01\x20\x02(\rR\x0fmemberThreshold\x12!\n\x0cmember_coun\ r_threshold\x18\x01\x20\x02(\rR\x0fmemberThreshold\x12!\n\x0cmember_coun\
t\x18\x02\x20\x02(\rR\x0bmemberCount\"\x10\n\x0eEntropyRequest\"&\n\nEnt\ t\x18\x02\x20\x02(\rR\x0bmemberCount\"\x10\n\x0eEntropyRequest\"&\n\nEnt\
ropyAck\x12\x18\n\x07entropy\x18\x01\x20\x02(\x0cR\x07entropy\"\xef\x04\ ropyAck\x12\x18\n\x07entropy\x18\x01\x20\x02(\x0cR\x07entropy\"\x8d\x04\
\n\x0eRecoveryDevice\x12\x1d\n\nword_count\x18\x01\x20\x01(\rR\twordCoun\ \n\x0eRecoveryDevice\x12\x1d\n\nword_count\x18\x01\x20\x01(\rR\twordCoun\
t\x123\n\x15passphrase_protection\x18\x02\x20\x01(\x08R\x14passphrasePro\ t\x123\n\x15passphrase_protection\x18\x02\x20\x01(\x08R\x14passphrasePro\
tection\x12%\n\x0epin_protection\x18\x03\x20\x01(\x08R\rpinProtection\ tection\x12%\n\x0epin_protection\x18\x03\x20\x01(\x08R\rpinProtection\
\x12\x1e\n\x08language\x18\x04\x20\x01(\tR\x08languageB\x02\x18\x01\x12\ \x12\x1e\n\x08language\x18\x04\x20\x01(\tR\x08languageB\x02\x18\x01\x12\
\x14\n\x05label\x18\x05\x20\x01(\tR\x05label\x12)\n\x10enforce_wordlist\ \x14\n\x05label\x18\x05\x20\x01(\tR\x05label\x12)\n\x10enforce_wordlist\
\x18\x06\x20\x01(\x08R\x0fenforceWordlist\x12T\n\x04type\x18\x08\x20\x01\ \x18\x06\x20\x01(\x08R\x0fenforceWordlist\x12j\n\x0cinput_method\x18\x08\
(\x0e2@.hw.trezor.messages.management.RecoveryDevice.RecoveryDeviceTypeR\ \x20\x01(\x0e2G.hw.trezor.messages.management.RecoveryDevice.RecoveryDev\
\x04type\x12\x1f\n\x0bu2f_counter\x18\t\x20\x01(\rR\nu2fCounter\x12^\n\ iceInputMethodR\x0binputMethod\x12\x1f\n\x0bu2f_counter\x18\t\x20\x01(\r\
\x04kind\x18\n\x20\x01(\x0e2:.hw.trezor.messages.management.RecoveryDevi\ R\nu2fCounter\x12O\n\x04type\x18\n\x20\x01(\x0e2+.hw.trezor.messages.man\
ce.RecoveryKind:\x0eNormalRecoveryR\x04kind\"Z\n\x12RecoveryDeviceType\ agement.RecoveryType:\x0eNormalRecoveryR\x04type\";\n\x19RecoveryDeviceI\
\x12%\n!RecoveryDeviceType_ScrambledWords\x10\0\x12\x1d\n\x19RecoveryDev\ nputMethod\x12\x12\n\x0eScrambledWords\x10\0\x12\n\n\x06Matrix\x10\x01J\
iceType_Matrix\x10\x01\"H\n\x0cRecoveryKind\x12\x12\n\x0eNormalRecovery\ \x04\x08\x07\x10\x08\"\xc5\x01\n\x0bWordRequest\x12N\n\x04type\x18\x01\
\x10\0\x12\n\n\x06DryRun\x10\x01\x12\x18\n\x14UnlockRepeatedBackup\x10\ \x20\x02(\x0e2:.hw.trezor.messages.management.WordRequest.WordRequestTyp\
\x02J\x04\x08\x07\x10\x08\"\xc5\x01\n\x0bWordRequest\x12N\n\x04type\x18\ eR\x04type\"f\n\x0fWordRequestType\x12\x19\n\x15WordRequestType_Plain\
\x01\x20\x02(\x0e2:.hw.trezor.messages.management.WordRequest.WordReques\ \x10\0\x12\x1b\n\x17WordRequestType_Matrix9\x10\x01\x12\x1b\n\x17WordReq\
tTypeR\x04type\"f\n\x0fWordRequestType\x12\x19\n\x15WordRequestType_Plai\ uestType_Matrix6\x10\x02\"\x1d\n\x07WordAck\x12\x12\n\x04word\x18\x01\
n\x10\0\x12\x1b\n\x17WordRequestType_Matrix9\x10\x01\x12\x1b\n\x17WordRe\
questType_Matrix6\x10\x02\"\x1d\n\x07WordAck\x12\x12\n\x04word\x18\x01\
\x20\x02(\tR\x04word\"0\n\rSetU2FCounter\x12\x1f\n\x0bu2f_counter\x18\ \x20\x02(\tR\x04word\"0\n\rSetU2FCounter\x12\x1f\n\x0bu2f_counter\x18\
\x01\x20\x02(\rR\nu2fCounter\"\x13\n\x11GetNextU2FCounter\"1\n\x0eNextU2\ \x01\x20\x02(\rR\nu2fCounter\"\x13\n\x11GetNextU2FCounter\"1\n\x0eNextU2\
FCounter\x12\x1f\n\x0bu2f_counter\x18\x01\x20\x02(\rR\nu2fCounter\"\x11\ FCounter\x12\x1f\n\x0bu2f_counter\x18\x01\x20\x02(\rR\nu2fCounter\"\x11\
@ -11148,8 +11254,10 @@ static file_descriptor_proto_data: &'static [u8] = b"\
\x04\x12\x1e\n\x1aSlip39_Advanced_Extendable\x10\x05*G\n\x10SafetyCheckL\ \x04\x12\x1e\n\x1aSlip39_Advanced_Extendable\x10\x05*G\n\x10SafetyCheckL\
evel\x12\n\n\x06Strict\x10\0\x12\x10\n\x0cPromptAlways\x10\x01\x12\x15\n\ evel\x12\n\n\x06Strict\x10\0\x12\x10\n\x0cPromptAlways\x10\x01\x12\x15\n\
\x11PromptTemporarily\x10\x02*0\n\x10HomescreenFormat\x12\x08\n\x04Toif\ \x11PromptTemporarily\x10\x02*0\n\x10HomescreenFormat\x12\x08\n\x04Toif\
\x10\x01\x12\x08\n\x04Jpeg\x10\x02\x12\x08\n\x04ToiG\x10\x03BB\n#com.sat\ \x10\x01\x12\x08\n\x04Jpeg\x10\x02\x12\x08\n\x04ToiG\x10\x03*H\n\x0cReco\
oshilabs.trezor.lib.protobufB\x17TrezorMessageManagement\x80\xa6\x1d\x01\ veryType\x12\x12\n\x0eNormalRecovery\x10\0\x12\n\n\x06DryRun\x10\x01\x12\
\x18\n\x14UnlockRepeatedBackup\x10\x02BB\n#com.satoshilabs.trezor.lib.pr\
otobufB\x17TrezorMessageManagement\x80\xa6\x1d\x01\
"; ";
/// `FileDescriptorProto` object which was a source for this generated file /// `FileDescriptorProto` object which was a source for this generated file
@ -11215,15 +11323,16 @@ pub fn file_descriptor() -> &'static ::protobuf::reflect::FileDescriptor {
messages.push(UnlockBootloader::generated_message_descriptor_data()); messages.push(UnlockBootloader::generated_message_descriptor_data());
messages.push(SetBrightness::generated_message_descriptor_data()); messages.push(SetBrightness::generated_message_descriptor_data());
messages.push(backup_device::Slip39Group::generated_message_descriptor_data()); messages.push(backup_device::Slip39Group::generated_message_descriptor_data());
let mut enums = ::std::vec::Vec::with_capacity(10); let mut enums = ::std::vec::Vec::with_capacity(11);
enums.push(BackupType::generated_enum_descriptor_data()); enums.push(BackupType::generated_enum_descriptor_data());
enums.push(SafetyCheckLevel::generated_enum_descriptor_data()); enums.push(SafetyCheckLevel::generated_enum_descriptor_data());
enums.push(HomescreenFormat::generated_enum_descriptor_data()); enums.push(HomescreenFormat::generated_enum_descriptor_data());
enums.push(RecoveryType::generated_enum_descriptor_data());
enums.push(features::BackupAvailability::generated_enum_descriptor_data());
enums.push(features::RecoveryStatus::generated_enum_descriptor_data()); enums.push(features::RecoveryStatus::generated_enum_descriptor_data());
enums.push(features::Capability::generated_enum_descriptor_data()); enums.push(features::Capability::generated_enum_descriptor_data());
enums.push(sd_protect::SdProtectOperationType::generated_enum_descriptor_data()); enums.push(sd_protect::SdProtectOperationType::generated_enum_descriptor_data());
enums.push(recovery_device::RecoveryDeviceType::generated_enum_descriptor_data()); enums.push(recovery_device::RecoveryDeviceInputMethod::generated_enum_descriptor_data());
enums.push(recovery_device::RecoveryKind::generated_enum_descriptor_data());
enums.push(word_request::WordRequestType::generated_enum_descriptor_data()); enums.push(word_request::WordRequestType::generated_enum_descriptor_data());
enums.push(reboot_to_bootloader::BootCommand::generated_enum_descriptor_data()); enums.push(reboot_to_bootloader::BootCommand::generated_enum_descriptor_data());
::protobuf::reflect::GeneratedFileDescriptor::new_generated( ::protobuf::reflect::GeneratedFileDescriptor::new_generated(

View File

@ -106,7 +106,7 @@ def test_backup_slip39_custom(
assert device_handler.result() == "Seed successfully backed up" assert device_handler.result() == "Seed successfully backed up"
features = device_handler.features() features = device_handler.features()
assert features.initialized is True assert features.initialized is True
assert features.needs_backup is False assert features.backup_availability == messages.BackupAvailability.NotAvailable
assert features.pin_protection is False assert features.pin_protection is False
assert features.passphrase_protection is False assert features.passphrase_protection is False
assert features.backup_type is messages.BackupType.Slip39_Basic_Extendable assert features.backup_type is messages.BackupType.Slip39_Basic_Extendable

View File

@ -47,7 +47,7 @@ def prepare_recovery_and_evaluate(
assert isinstance(device_handler.result(), messages.Success) assert isinstance(device_handler.result(), messages.Success)
features = device_handler.features() features = device_handler.features()
assert features.initialized is True assert features.initialized is True
assert features.recovery_status == messages.RecoveryStatus.NoRecovery assert features.recovery_status == messages.RecoveryStatus.Nothing
@pytest.mark.setup_client(uninitialized=True) @pytest.mark.setup_client(uninitialized=True)

View File

@ -93,16 +93,16 @@ def test_repeated_backup(
# great ... device is initialized, backup done, and we are not in recovery mode! # great ... device is initialized, backup done, and we are not in recovery mode!
assert device_handler.result() == "Initialized" assert device_handler.result() == "Initialized"
features = device_handler.features() features = device_handler.features()
assert features.backup_type is messages.BackupType.Slip39_Basic assert features.backup_type is messages.BackupType.Slip39_Basic_Extendable
assert features.initialized is True assert features.initialized is True
assert features.needs_backup is False assert features.backup_availability == messages.BackupAvailability.NotAvailable
assert features.no_backup is False assert features.no_backup is False
assert features.recovery_status == messages.RecoveryStatus.NoRecovery assert features.recovery_status == messages.RecoveryStatus.Nothing
# run recovery to unlock backup # run recovery to unlock backup
device_handler.run( device_handler.run(
device.recover, device.recover,
recovery_kind=messages.RecoveryKind.UnlockRepeatedBackup, type=messages.RecoveryType.UnlockRepeatedBackup,
) )
recovery.confirm_recovery(debug, "recovery__title_unlock_repeated_backup") recovery.confirm_recovery(debug, "recovery__title_unlock_repeated_backup")
@ -123,14 +123,11 @@ def test_repeated_backup(
# we are now in recovery mode # we are now in recovery mode
features = device_handler.features() features = device_handler.features()
assert features.backup_type is messages.BackupType.Slip39_Basic assert features.backup_type is messages.BackupType.Slip39_Basic_Extendable
assert features.initialized is True assert features.initialized is True
assert features.needs_backup is False assert features.backup_availability == messages.BackupAvailability.Available
assert features.no_backup is False assert features.no_backup is False
assert ( assert features.recovery_status == messages.RecoveryStatus.Backup
features.recovery_status
== messages.RecoveryStatus.InUnlockRepeatedBackupRecovery
)
# at this point, the backup is unlocked... # at this point, the backup is unlocked...
@ -169,16 +166,16 @@ def test_repeated_backup(
# we are not in recovery mode anymore, because we finished the backup process! # we are not in recovery mode anymore, because we finished the backup process!
features = device_handler.features() features = device_handler.features()
assert features.backup_type is messages.BackupType.Slip39_Basic assert features.backup_type is messages.BackupType.Slip39_Basic_Extendable
assert features.initialized is True assert features.initialized is True
assert features.needs_backup is False assert features.backup_availability == messages.BackupAvailability.NotAvailable
assert features.no_backup is False assert features.no_backup is False
assert features.recovery_status == messages.RecoveryStatus.NoRecovery assert features.recovery_status == messages.RecoveryStatus.Nothing
# try to unlock backup again... # try to unlock backup again...
device_handler.run( device_handler.run(
device.recover, device.recover,
recovery_kind=messages.RecoveryKind.UnlockRepeatedBackup, type=messages.RecoveryType.UnlockRepeatedBackup,
) )
recovery.confirm_recovery(debug, "recovery__title_unlock_repeated_backup") recovery.confirm_recovery(debug, "recovery__title_unlock_repeated_backup")
@ -188,7 +185,7 @@ def test_repeated_backup(
recovery.enter_shares( recovery.enter_shares(
debug, debug,
second_backup_2_of_3[-2:], second_backup_2_of_3[-2:],
"recovery__title_unlock_repeated_backup", "recovery__title_dry_run",
"recovery__enter_backup", "recovery__enter_backup",
"recovery__unlock_repeated_backup", "recovery__unlock_repeated_backup",
) )
@ -197,22 +194,19 @@ def test_repeated_backup(
# we are now in recovery mode again! # we are now in recovery mode again!
features = device_handler.features() features = device_handler.features()
assert features.backup_type is messages.BackupType.Slip39_Basic assert features.backup_type is messages.BackupType.Slip39_Basic_Extendable
assert features.initialized is True assert features.initialized is True
assert features.needs_backup is False assert features.backup_availability == messages.BackupAvailability.Available
assert features.no_backup is False assert features.no_backup is False
assert ( assert features.recovery_status == messages.RecoveryStatus.Backup
features.recovery_status
== messages.RecoveryStatus.InUnlockRepeatedBackupRecovery
)
# but if we cancel the backup at this point... # but if we cancel the backup at this point...
reset.cancel_backup(debug) reset.cancel_backup(debug)
# ...we are out of recovery mode! # ...we are out of recovery mode!
features = device_handler.features() features = device_handler.features()
assert features.backup_type is messages.BackupType.Slip39_Basic assert features.backup_type is messages.BackupType.Slip39_Basic_Extendable
assert features.initialized is True assert features.initialized is True
assert features.needs_backup is False assert features.backup_availability == messages.BackupAvailability.NotAvailable
assert features.no_backup is False assert features.no_backup is False
assert features.recovery_status == messages.RecoveryStatus.NoRecovery assert features.recovery_status == messages.RecoveryStatus.Nothing

View File

@ -72,7 +72,7 @@ def test_reset_bip39(device_handler: "BackgroundDeviceHandler"):
assert device_handler.result() == "Initialized" assert device_handler.result() == "Initialized"
features = device_handler.features() features = device_handler.features()
assert features.initialized is True assert features.initialized is True
assert features.needs_backup is False assert features.backup_availability == messages.BackupAvailability.NotAvailable
assert features.pin_protection is False assert features.pin_protection is False
assert features.passphrase_protection is False assert features.passphrase_protection is False
assert features.backup_type is messages.BackupType.Bip39 assert features.backup_type is messages.BackupType.Bip39

View File

@ -139,7 +139,7 @@ def test_reset_slip39_advanced(
features = device_handler.features() features = device_handler.features()
assert features.initialized is True assert features.initialized is True
assert features.needs_backup is False assert features.backup_availability == messages.BackupAvailability.NotAvailable
assert features.pin_protection is False assert features.pin_protection is False
assert features.passphrase_protection is False assert features.passphrase_protection is False
assert features.backup_type is messages.BackupType.Slip39_Advanced_Extendable assert features.backup_type is messages.BackupType.Slip39_Advanced_Extendable

View File

@ -117,7 +117,7 @@ def test_reset_slip39_basic(
assert device_handler.result() == "Initialized" assert device_handler.result() == "Initialized"
features = device_handler.features() features = device_handler.features()
assert features.initialized is True assert features.initialized is True
assert features.needs_backup is False assert features.backup_availability == messages.BackupAvailability.NotAvailable
assert features.pin_protection is False assert features.pin_protection is False
assert features.passphrase_protection is False assert features.passphrase_protection is False
assert features.backup_type is messages.BackupType.Slip39_Basic_Extendable assert features.backup_type is messages.BackupType.Slip39_Basic_Extendable

View File

@ -28,7 +28,7 @@ from ...input_flows import (
) )
def do_recover_legacy(client: Client, mnemonic: list[str], **kwargs: Any): def do_recover_legacy(client: Client, mnemonic: list[str]):
def input_callback(_): def input_callback(_):
word, pos = client.debug.read_recovery_word() word, pos = client.debug.read_recovery_word()
if pos != 0 and pos is not None: if pos != 0 and pos is not None:
@ -40,11 +40,10 @@ def do_recover_legacy(client: Client, mnemonic: list[str], **kwargs: Any):
ret = device.recover( ret = device.recover(
client, client,
recovery_kind=messages.RecoveryKind.DryRun, type=messages.RecoveryType.DryRun,
word_count=len(mnemonic), word_count=len(mnemonic),
type=messages.RecoveryDeviceType.ScrambledWords, input_method=messages.RecoveryDeviceInputMethod.ScrambledWords,
input_callback=input_callback, input_callback=input_callback,
**kwargs
) )
# if the call succeeded, check that all words have been used # if the call succeeded, check that all words have been used
assert all(m is None for m in mnemonic) assert all(m is None for m in mnemonic)
@ -56,7 +55,7 @@ def do_recover_core(client: Client, mnemonic: list[str], mismatch: bool = False)
client.watch_layout() client.watch_layout()
IF = InputFlowBip39RecoveryDryRun(client, mnemonic, mismatch=mismatch) IF = InputFlowBip39RecoveryDryRun(client, mnemonic, mismatch=mismatch)
client.set_input_flow(IF.get()) client.set_input_flow(IF.get())
return device.recover(client, recovery_kind=messages.RecoveryKind.DryRun) return device.recover(client, type=messages.RecoveryType.DryRun)
def do_recover(client: Client, mnemonic: list[str], mismatch: bool = False): def do_recover(client: Client, mnemonic: list[str], mismatch: bool = False):
@ -105,10 +104,10 @@ def test_uninitialized(client: Client):
DRY_RUN_ALLOWED_FIELDS = ( DRY_RUN_ALLOWED_FIELDS = (
"kind", "type",
"word_count", "word_count",
"enforce_wordlist", "enforce_wordlist",
"type", "input_method",
"show_tutorial", "show_tutorial",
) )
@ -131,7 +130,7 @@ def _make_bad_params():
yield field.name, True yield field.name, True
elif field.type == "string": elif field.type == "string":
yield field.name, "test" yield field.name, "test"
elif field.type == "RecoveryKind": elif field.type == "RecoveryType":
yield field.name, 1 yield field.name, 1
else: else:
# Someone added a field to RecoveryDevice of a type that has no assigned # Someone added a field to RecoveryDevice of a type that has no assigned
@ -142,10 +141,10 @@ def _make_bad_params():
@pytest.mark.parametrize("field_name, field_value", _make_bad_params()) @pytest.mark.parametrize("field_name, field_value", _make_bad_params())
def test_bad_parameters(client: Client, field_name: str, field_value: Any): def test_bad_parameters(client: Client, field_name: str, field_value: Any):
msg = messages.RecoveryDevice( msg = messages.RecoveryDevice(
kind=messages.RecoveryKind.DryRun, type=messages.RecoveryType.DryRun,
word_count=12, word_count=12,
enforce_wordlist=True, enforce_wordlist=True,
type=messages.RecoveryDeviceType.ScrambledWords, input_method=messages.RecoveryDeviceInputMethod.ScrambledWords,
) )
setattr(msg, field_name, field_value) setattr(msg, field_name, field_value)
with pytest.raises( with pytest.raises(

View File

@ -211,7 +211,8 @@ def test_already_initialized(client: Client):
ret = client.call_raw( ret = client.call_raw(
messages.RecoveryDevice( messages.RecoveryDevice(
word_count=12, type=messages.RecoveryDeviceType.ScrambledWords word_count=12,
input_method=messages.RecoveryDeviceInputMethod.ScrambledWords,
) )
) )
assert isinstance(ret, messages.Failure) assert isinstance(ret, messages.Failure)

View File

@ -20,7 +20,7 @@ from shamir_mnemonic import shamir
from trezorlib import device from trezorlib import device
from trezorlib.debuglink import TrezorClientDebugLink as Client from trezorlib.debuglink import TrezorClientDebugLink as Client
from trezorlib.messages import BackupType from trezorlib.messages import BackupAvailability, BackupType
from ...common import WITH_MOCK_URANDOM from ...common import WITH_MOCK_URANDOM
from ...input_flows import ( from ...input_flows import (
@ -85,7 +85,7 @@ def test_skip_backup_msg(client: Client, backup_type, backup_flow):
) )
assert client.features.initialized is True assert client.features.initialized is True
assert client.features.needs_backup is True assert client.features.backup_availability == BackupAvailability.Required
assert client.features.unfinished_backup is False assert client.features.unfinished_backup is False
assert client.features.no_backup is False assert client.features.no_backup is False
assert client.features.backup_type is backup_type assert client.features.backup_type is backup_type
@ -94,7 +94,7 @@ def test_skip_backup_msg(client: Client, backup_type, backup_flow):
client.init_device() client.init_device()
assert client.features.initialized is True assert client.features.initialized is True
assert client.features.needs_backup is False assert client.features.backup_availability == BackupAvailability.NotAvailable
assert client.features.unfinished_backup is False assert client.features.unfinished_backup is False
assert client.features.backup_type is backup_type assert client.features.backup_type is backup_type
@ -119,7 +119,7 @@ def test_skip_backup_manual(client: Client, backup_type: BackupType, backup_flow
) )
assert client.features.initialized is True assert client.features.initialized is True
assert client.features.needs_backup is True assert client.features.backup_availability == BackupAvailability.Required
assert client.features.unfinished_backup is False assert client.features.unfinished_backup is False
assert client.features.no_backup is False assert client.features.no_backup is False
assert client.features.backup_type is backup_type assert client.features.backup_type is backup_type
@ -128,7 +128,7 @@ def test_skip_backup_manual(client: Client, backup_type: BackupType, backup_flow
client.init_device() client.init_device()
assert client.features.initialized is True assert client.features.initialized is True
assert client.features.needs_backup is False assert client.features.backup_availability == BackupAvailability.NotAvailable
assert client.features.unfinished_backup is False assert client.features.unfinished_backup is False
assert client.features.backup_type is backup_type assert client.features.backup_type is backup_type

View File

@ -53,7 +53,7 @@ def test_reset_device_skip_backup(client: Client):
# Check if device is properly initialized # Check if device is properly initialized
ret = client.call_raw(messages.Initialize()) ret = client.call_raw(messages.Initialize())
assert ret.initialized is True assert ret.initialized is True
assert ret.needs_backup is True assert ret.backup_availability == messages.BackupAvailability.Required
assert ret.unfinished_backup is False assert ret.unfinished_backup is False
assert ret.no_backup is False assert ret.no_backup is False
@ -120,7 +120,7 @@ def test_reset_device_skip_backup_break(client: Client):
# Check if device is properly initialized # Check if device is properly initialized
ret = client.call_raw(messages.Initialize()) ret = client.call_raw(messages.Initialize())
assert ret.initialized is True assert ret.initialized is True
assert ret.needs_backup is True assert ret.backup_availability == messages.BackupAvailability.Required
assert ret.unfinished_backup is False assert ret.unfinished_backup is False
assert ret.no_backup is False assert ret.no_backup is False
@ -131,7 +131,7 @@ def test_reset_device_skip_backup_break(client: Client):
ret = client.call_raw(messages.Initialize()) ret = client.call_raw(messages.Initialize())
assert isinstance(ret, messages.Features) assert isinstance(ret, messages.Features)
assert ret.initialized is True assert ret.initialized is True
assert ret.needs_backup is False assert ret.backup_availability == messages.BackupAvailability.NotAvailable
assert ret.unfinished_backup is True assert ret.unfinished_backup is True
assert ret.no_backup is False assert ret.no_backup is False
@ -143,7 +143,7 @@ def test_reset_device_skip_backup_break(client: Client):
ret = client.call_raw(messages.Initialize()) ret = client.call_raw(messages.Initialize())
assert isinstance(ret, messages.Features) assert isinstance(ret, messages.Features)
assert ret.initialized is True assert ret.initialized is True
assert ret.needs_backup is False assert ret.backup_availability == messages.BackupAvailability.NotAvailable
assert ret.unfinished_backup is True assert ret.unfinished_backup is True
assert ret.no_backup is False assert ret.no_backup is False

View File

@ -80,7 +80,7 @@ def reset_device(client: Client, strength: int):
# Check if device is properly initialized # Check if device is properly initialized
resp = client.call_raw(messages.Initialize()) resp = client.call_raw(messages.Initialize())
assert resp.initialized is True assert resp.initialized is True
assert resp.needs_backup is False assert resp.backup_availability == messages.BackupAvailability.NotAvailable
assert resp.pin_protection is False assert resp.pin_protection is False
assert resp.passphrase_protection is False assert resp.passphrase_protection is False
@ -177,7 +177,7 @@ def test_reset_device_256_pin(client: Client):
# Check if device is properly initialized # Check if device is properly initialized
resp = client.call_raw(messages.Initialize()) resp = client.call_raw(messages.Initialize())
assert resp.initialized is True assert resp.initialized is True
assert resp.needs_backup is False assert resp.backup_availability == messages.BackupAvailability.NotAvailable
assert resp.pin_protection is True assert resp.pin_protection is True
assert resp.passphrase_protection is True assert resp.passphrase_protection is True

View File

@ -57,7 +57,7 @@ def reset_device(client: Client, strength: int):
# Check if device is properly initialized # Check if device is properly initialized
resp = client.call_raw(messages.Initialize()) resp = client.call_raw(messages.Initialize())
assert resp.initialized is True assert resp.initialized is True
assert resp.needs_backup is False assert resp.backup_availability == messages.BackupAvailability.NotAvailable
assert resp.pin_protection is False assert resp.pin_protection is False
assert resp.passphrase_protection is False assert resp.passphrase_protection is False
assert resp.backup_type is messages.BackupType.Bip39 assert resp.backup_type is messages.BackupType.Bip39
@ -106,7 +106,7 @@ def test_reset_device_pin(client: Client):
# Check if device is properly initialized # Check if device is properly initialized
resp = client.call_raw(messages.Initialize()) resp = client.call_raw(messages.Initialize())
assert resp.initialized is True assert resp.initialized is True
assert resp.needs_backup is False assert resp.backup_availability == messages.BackupAvailability.NotAvailable
assert resp.pin_protection is True assert resp.pin_protection is True
assert resp.passphrase_protection is True assert resp.passphrase_protection is True
@ -140,7 +140,7 @@ def test_reset_failed_check(client: Client):
# Check if device is properly initialized # Check if device is properly initialized
resp = client.call_raw(messages.Initialize()) resp = client.call_raw(messages.Initialize())
assert resp.initialized is True assert resp.initialized is True
assert resp.needs_backup is False assert resp.backup_availability == messages.BackupAvailability.NotAvailable
assert resp.pin_protection is False assert resp.pin_protection is False
assert resp.passphrase_protection is False assert resp.passphrase_protection is False
assert resp.backup_type is messages.BackupType.Bip39 assert resp.backup_type is messages.BackupType.Bip39

View File

@ -55,7 +55,9 @@ def reset(client: Client, strength: int = 128, skip_backup: bool = False) -> str
# Check if device is properly initialized # Check if device is properly initialized
assert client.features.initialized is True assert client.features.initialized is True
assert client.features.needs_backup is False assert (
client.features.backup_availability == messages.BackupAvailability.NotAvailable
)
assert client.features.pin_protection is False assert client.features.pin_protection is False
assert client.features.passphrase_protection is False assert client.features.passphrase_protection is False

View File

@ -75,7 +75,9 @@ def reset(client: Client, strength: int = 128) -> list[str]:
# Check if device is properly initialized # Check if device is properly initialized
assert client.features.initialized is True assert client.features.initialized is True
assert client.features.needs_backup is False assert (
client.features.backup_availability == messages.BackupAvailability.NotAvailable
)
assert client.features.pin_protection is False assert client.features.pin_protection is False
assert client.features.passphrase_protection is False assert client.features.passphrase_protection is False
assert client.features.backup_type is BackupType.Slip39_Advanced_Extendable assert client.features.backup_type is BackupType.Slip39_Advanced_Extendable

View File

@ -65,7 +65,9 @@ def reset(client: Client, strength: int = 128) -> list[str]:
# Check if device is properly initialized # Check if device is properly initialized
assert client.features.initialized is True assert client.features.initialized is True
assert client.features.needs_backup is False assert (
client.features.backup_availability == messages.BackupAvailability.NotAvailable
)
assert client.features.pin_protection is False assert client.features.pin_protection is False
assert client.features.passphrase_protection is False assert client.features.passphrase_protection is False
assert client.features.backup_type is BackupType.Slip39_Basic_Extendable assert client.features.backup_type is BackupType.Slip39_Basic_Extendable

View File

@ -20,7 +20,7 @@ from shamir_mnemonic import shamir
from trezorlib import device from trezorlib import device
from trezorlib.debuglink import TrezorClientDebugLink as Client from trezorlib.debuglink import TrezorClientDebugLink as Client
from trezorlib.exceptions import TrezorFailure from trezorlib.exceptions import TrezorFailure
from trezorlib.messages import BackupType from trezorlib.messages import BackupAvailability, BackupType
from ...common import EXTERNAL_ENTROPY, WITH_MOCK_URANDOM, generate_entropy from ...common import EXTERNAL_ENTROPY, WITH_MOCK_URANDOM, generate_entropy
from ...input_flows import InputFlowSlip39AdvancedResetRecovery from ...input_flows import InputFlowSlip39AdvancedResetRecovery
@ -58,7 +58,7 @@ def test_reset_device_slip39_advanced(client: Client):
# Check if device is properly initialized # Check if device is properly initialized
assert client.features.initialized is True assert client.features.initialized is True
assert client.features.needs_backup is False assert client.features.backup_availability == BackupAvailability.NotAvailable
assert client.features.pin_protection is False assert client.features.pin_protection is False
assert client.features.passphrase_protection is False assert client.features.passphrase_protection is False
assert client.features.backup_type is BackupType.Slip39_Advanced_Extendable assert client.features.backup_type is BackupType.Slip39_Advanced_Extendable

View File

@ -22,7 +22,7 @@ from shamir_mnemonic import MnemonicError, shamir
from trezorlib import device from trezorlib import device
from trezorlib.debuglink import TrezorClientDebugLink as Client from trezorlib.debuglink import TrezorClientDebugLink as Client
from trezorlib.exceptions import TrezorFailure from trezorlib.exceptions import TrezorFailure
from trezorlib.messages import BackupType from trezorlib.messages import BackupAvailability, BackupType
from ...common import EXTERNAL_ENTROPY, WITH_MOCK_URANDOM, generate_entropy from ...common import EXTERNAL_ENTROPY, WITH_MOCK_URANDOM, generate_entropy
from ...input_flows import InputFlowSlip39BasicResetRecovery from ...input_flows import InputFlowSlip39BasicResetRecovery
@ -57,7 +57,7 @@ def reset_device(client: Client, strength: int):
# Check if device is properly initialized # Check if device is properly initialized
assert client.features.initialized is True assert client.features.initialized is True
assert client.features.needs_backup is False assert client.features.backup_availability == BackupAvailability.NotAvailable
assert client.features.pin_protection is False assert client.features.pin_protection is False
assert client.features.passphrase_protection is False assert client.features.passphrase_protection is False
assert client.features.backup_type is BackupType.Slip39_Basic_Extendable assert client.features.backup_type is BackupType.Slip39_Basic_Extendable

View File

@ -40,7 +40,7 @@ from ..input_flows import (
@pytest.mark.skip_t1b1 # TODO we want this for t1 too @pytest.mark.skip_t1b1 # TODO we want this for t1 too
@pytest.mark.setup_client(needs_backup=True, mnemonic=MNEMONIC12) @pytest.mark.setup_client(needs_backup=True, mnemonic=MNEMONIC12)
def test_backup_bip39(client: Client): def test_backup_bip39(client: Client):
assert client.features.needs_backup is True assert client.features.backup_availability == messages.BackupAvailability.Required
with client: with client:
IF = InputFlowBip39Backup(client) IF = InputFlowBip39Backup(client)
@ -50,7 +50,9 @@ def test_backup_bip39(client: Client):
assert IF.mnemonic == MNEMONIC12 assert IF.mnemonic == MNEMONIC12
client.init_device() client.init_device()
assert client.features.initialized is True assert client.features.initialized is True
assert client.features.needs_backup is False assert (
client.features.backup_availability == messages.BackupAvailability.NotAvailable
)
assert client.features.unfinished_backup is False assert client.features.unfinished_backup is False
assert client.features.no_backup is False assert client.features.no_backup is False
assert client.features.backup_type is messages.BackupType.Bip39 assert client.features.backup_type is messages.BackupType.Bip39
@ -65,7 +67,7 @@ def test_backup_slip39_basic(client: Client, click_info: bool):
if click_info and client.model is models.T2B1: if click_info and client.model is models.T2B1:
pytest.skip("click_info not implemented on T2B1") pytest.skip("click_info not implemented on T2B1")
assert client.features.needs_backup is True assert client.features.backup_availability == messages.BackupAvailability.Required
with client: with client:
IF = InputFlowSlip39BasicBackup(client, click_info) IF = InputFlowSlip39BasicBackup(client, click_info)
@ -74,7 +76,9 @@ def test_backup_slip39_basic(client: Client, click_info: bool):
client.init_device() client.init_device()
assert client.features.initialized is True assert client.features.initialized is True
assert client.features.needs_backup is False assert (
client.features.backup_availability == messages.BackupAvailability.NotAvailable
)
assert client.features.unfinished_backup is False assert client.features.unfinished_backup is False
assert client.features.no_backup is False assert client.features.no_backup is False
assert client.features.backup_type is messages.BackupType.Slip39_Basic assert client.features.backup_type is messages.BackupType.Slip39_Basic
@ -93,7 +97,7 @@ def test_backup_slip39_advanced(client: Client, click_info: bool):
if click_info and client.model is models.T2B1: if click_info and client.model is models.T2B1:
pytest.skip("click_info not implemented on T2B1") pytest.skip("click_info not implemented on T2B1")
assert client.features.needs_backup is True assert client.features.backup_availability == messages.BackupAvailability.Required
with client: with client:
IF = InputFlowSlip39AdvancedBackup(client, click_info) IF = InputFlowSlip39AdvancedBackup(client, click_info)
@ -102,7 +106,9 @@ def test_backup_slip39_advanced(client: Client, click_info: bool):
client.init_device() client.init_device()
assert client.features.initialized is True assert client.features.initialized is True
assert client.features.needs_backup is False assert (
client.features.backup_availability == messages.BackupAvailability.NotAvailable
)
assert client.features.unfinished_backup is False assert client.features.unfinished_backup is False
assert client.features.no_backup is False assert client.features.no_backup is False
assert client.features.backup_type is messages.BackupType.Slip39_Advanced assert client.features.backup_type is messages.BackupType.Slip39_Advanced
@ -122,7 +128,7 @@ def test_backup_slip39_advanced(client: Client, click_info: bool):
ids=["1_of_1", "2_of_2", "3_of_5"], ids=["1_of_1", "2_of_2", "3_of_5"],
) )
def test_backup_slip39_custom(client: Client, share_threshold, share_count): def test_backup_slip39_custom(client: Client, share_threshold, share_count):
assert client.features.needs_backup is True assert client.features.backup_availability == messages.BackupAvailability.Required
with client: with client:
IF = InputFlowSlip39CustomBackup(client, share_count) IF = InputFlowSlip39CustomBackup(client, share_count)
@ -133,7 +139,9 @@ def test_backup_slip39_custom(client: Client, share_threshold, share_count):
client.init_device() client.init_device()
assert client.features.initialized is True assert client.features.initialized is True
assert client.features.needs_backup is False assert (
client.features.backup_availability == messages.BackupAvailability.NotAvailable
)
assert client.features.unfinished_backup is False assert client.features.unfinished_backup is False
assert client.features.no_backup is False assert client.features.no_backup is False
@ -150,7 +158,9 @@ def test_no_backup_fails(client: Client):
client.ensure_unlocked() client.ensure_unlocked()
assert client.features.initialized is True assert client.features.initialized is True
assert client.features.no_backup is True assert client.features.no_backup is True
assert client.features.needs_backup is False assert (
client.features.backup_availability == messages.BackupAvailability.NotAvailable
)
# backup attempt should fail because no_backup=True # backup attempt should fail because no_backup=True
with pytest.raises(TrezorFailure, match=r".*Seed already backed up"): with pytest.raises(TrezorFailure, match=r".*Seed already backed up"):
@ -162,7 +172,7 @@ def test_no_backup_fails(client: Client):
def test_interrupt_backup_fails(client: Client): def test_interrupt_backup_fails(client: Client):
client.ensure_unlocked() client.ensure_unlocked()
assert client.features.initialized is True assert client.features.initialized is True
assert client.features.needs_backup is True assert client.features.backup_availability == messages.BackupAvailability.Required
assert client.features.unfinished_backup is False assert client.features.unfinished_backup is False
assert client.features.no_backup is False assert client.features.no_backup is False
@ -174,7 +184,9 @@ def test_interrupt_backup_fails(client: Client):
# check that device state is as expected # check that device state is as expected
assert client.features.initialized is True assert client.features.initialized is True
assert client.features.needs_backup is False assert (
client.features.backup_availability == messages.BackupAvailability.NotAvailable
)
assert client.features.unfinished_backup is True assert client.features.unfinished_backup is True
assert client.features.no_backup is False assert client.features.no_backup is False

View File

@ -29,7 +29,7 @@ from ..input_flows import InputFlowSlip39BasicBackup, InputFlowSlip39BasicRecove
@pytest.mark.skip_t1b1 @pytest.mark.skip_t1b1
@WITH_MOCK_URANDOM @WITH_MOCK_URANDOM
def test_repeated_backup(client: Client): def test_repeated_backup(client: Client):
assert client.features.needs_backup is True assert client.features.backup_availability == messages.BackupAvailability.Required
# initial device backup # initial device backup
mnemonics = [] mnemonics = []
@ -51,9 +51,7 @@ def test_repeated_backup(client: Client):
client, mnemonics[:3], unlock_repeated_backup=True client, mnemonics[:3], unlock_repeated_backup=True
) )
client.set_input_flow(IF.get()) client.set_input_flow(IF.get())
ret = device.recover( ret = device.recover(client, type=messages.RecoveryType.UnlockRepeatedBackup)
client, recovery_kind=messages.RecoveryKind.UnlockRepeatedBackup
)
assert ret == messages.Success(message="Backup unlocked") assert ret == messages.Success(message="Backup unlocked")
# we can now perform another backup # we can now perform another backup
@ -71,7 +69,7 @@ def test_repeated_backup(client: Client):
@pytest.mark.skip_t1b1 @pytest.mark.skip_t1b1
@WITH_MOCK_URANDOM @WITH_MOCK_URANDOM
def test_repeated_backup_cancel(client: Client): def test_repeated_backup_cancel(client: Client):
assert client.features.needs_backup is True assert client.features.backup_availability == messages.BackupAvailability.Required
# initial device backup # initial device backup
mnemonics = [] mnemonics = []
@ -93,9 +91,7 @@ def test_repeated_backup_cancel(client: Client):
client, mnemonics[:3], unlock_repeated_backup=True client, mnemonics[:3], unlock_repeated_backup=True
) )
client.set_input_flow(IF.get()) client.set_input_flow(IF.get())
ret = device.recover( ret = device.recover(client, type=messages.RecoveryType.UnlockRepeatedBackup)
client, recovery_kind=messages.RecoveryKind.UnlockRepeatedBackup
)
assert ret == messages.Success(message="Backup unlocked") assert ret == messages.Success(message="Backup unlocked")
client.debug.wait_layout() client.debug.wait_layout()

View File

@ -44,7 +44,7 @@ def test_abort(core_emulator: Emulator):
if debug.model is models.T3T1: if debug.model is models.T3T1:
pytest.skip("abort not supported on T3T1") pytest.skip("abort not supported on T3T1")
assert features.recovery_status == RecoveryStatus.NoRecovery assert features.recovery_status == RecoveryStatus.Nothing
device_handler.run(device.recover, pin_protection=False) device_handler.run(device.recover, pin_protection=False)
@ -56,7 +56,7 @@ def test_abort(core_emulator: Emulator):
debug = _restart(device_handler, core_emulator) debug = _restart(device_handler, core_emulator)
features = device_handler.features() features = device_handler.features()
assert features.recovery_status == RecoveryStatus.InNormalRecovery assert features.recovery_status == RecoveryStatus.Recovery
# no waiting for layout because layout doesn't change # no waiting for layout because layout doesn't change
assert "number of words" in debug.read_layout().text_content() assert "number of words" in debug.read_layout().text_content()
@ -72,7 +72,7 @@ def test_abort(core_emulator: Emulator):
assert layout.main_component() == "Homescreen" assert layout.main_component() == "Homescreen"
features = device_handler.features() features = device_handler.features()
assert features.recovery_status == RecoveryStatus.NoRecovery assert features.recovery_status == RecoveryStatus.Nothing
@core_only @core_only
@ -82,7 +82,7 @@ def test_recovery_single_reset(core_emulator: Emulator):
features = device_handler.features() features = device_handler.features()
assert features.initialized is False assert features.initialized is False
assert features.recovery_status == RecoveryStatus.NoRecovery assert features.recovery_status == RecoveryStatus.Nothing
device_handler.run(device.recover, pin_protection=False) device_handler.run(device.recover, pin_protection=False)
@ -92,7 +92,7 @@ def test_recovery_single_reset(core_emulator: Emulator):
debug = _restart(device_handler, core_emulator) debug = _restart(device_handler, core_emulator)
features = device_handler.features() features = device_handler.features()
assert features.recovery_status == RecoveryStatus.InNormalRecovery assert features.recovery_status == RecoveryStatus.Recovery
# we need to enter the number of words again, that's a feature # we need to enter the number of words again, that's a feature
recovery.select_number_of_words(debug, wait=False) recovery.select_number_of_words(debug, wait=False)
@ -101,7 +101,7 @@ def test_recovery_single_reset(core_emulator: Emulator):
features = device_handler.features() features = device_handler.features()
assert features.initialized is True assert features.initialized is True
assert features.recovery_status == RecoveryStatus.NoRecovery assert features.recovery_status == RecoveryStatus.Nothing
@core_only @core_only
@ -119,7 +119,7 @@ def test_recovery_on_old_wallet(core_emulator: Emulator):
features = device_handler.features() features = device_handler.features()
assert features.initialized is False assert features.initialized is False
assert features.recovery_status == RecoveryStatus.NoRecovery assert features.recovery_status == RecoveryStatus.Nothing
# enter recovery mode # enter recovery mode
device_handler.run(device.recover, pin_protection=False) device_handler.run(device.recover, pin_protection=False)
@ -129,7 +129,7 @@ def test_recovery_on_old_wallet(core_emulator: Emulator):
# restart to get into stand-alone recovery # restart to get into stand-alone recovery
debug = _restart(device_handler, core_emulator) debug = _restart(device_handler, core_emulator)
features = device_handler.features() features = device_handler.features()
assert features.recovery_status == RecoveryStatus.InNormalRecovery assert features.recovery_status == RecoveryStatus.Recovery
# enter number of words # enter number of words
recovery.select_number_of_words(debug, wait=False) recovery.select_number_of_words(debug, wait=False)
@ -168,7 +168,7 @@ def test_recovery_on_old_wallet(core_emulator: Emulator):
# check that the recovery succeeded # check that the recovery succeeded
features = device_handler.features() features = device_handler.features()
assert features.initialized is True assert features.initialized is True
assert features.recovery_status == RecoveryStatus.NoRecovery assert features.recovery_status == RecoveryStatus.Nothing
@core_only @core_only
@ -192,7 +192,7 @@ def test_recovery_multiple_resets(core_emulator: Emulator):
features = device_handler.features() features = device_handler.features()
assert features.initialized is False assert features.initialized is False
assert features.recovery_status == RecoveryStatus.NoRecovery assert features.recovery_status == RecoveryStatus.Nothing
# start device and recovery # start device and recovery
device_handler.run(device.recover, pin_protection=False) device_handler.run(device.recover, pin_protection=False)
@ -205,7 +205,7 @@ def test_recovery_multiple_resets(core_emulator: Emulator):
# restart # restart
debug = _restart(device_handler, core_emulator) debug = _restart(device_handler, core_emulator)
features = device_handler.features() features = device_handler.features()
assert features.recovery_status == RecoveryStatus.InNormalRecovery assert features.recovery_status == RecoveryStatus.Recovery
# enter the number of words again, that's a feature! # enter the number of words again, that's a feature!
recovery.select_number_of_words(debug, wait=False) recovery.select_number_of_words(debug, wait=False)
@ -217,4 +217,4 @@ def test_recovery_multiple_resets(core_emulator: Emulator):
features = device_handler.features() features = device_handler.features()
assert features.initialized is True assert features.initialized is True
assert features.recovery_status == RecoveryStatus.NoRecovery assert features.recovery_status == RecoveryStatus.Nothing

View File

@ -21,7 +21,13 @@ import pytest
from shamir_mnemonic import shamir from shamir_mnemonic import shamir
from trezorlib import btc, debuglink, device, exceptions, fido, models from trezorlib import btc, debuglink, device, exceptions, fido, models
from trezorlib.messages import ApplySettings, BackupType, RecoveryStatus, Success from trezorlib.messages import (
ApplySettings,
BackupAvailability,
BackupType,
RecoveryStatus,
Success,
)
from trezorlib.tools import H_ from trezorlib.tools import H_
from ..common import MNEMONIC_SLIP39_BASIC_20_3of6, MNEMONIC_SLIP39_BASIC_20_3of6_SECRET from ..common import MNEMONIC_SLIP39_BASIC_20_3of6, MNEMONIC_SLIP39_BASIC_20_3of6_SECRET
@ -197,7 +203,7 @@ def test_upgrade_reset(gen: str, tag: str):
assert not client.features.passphrase_protection assert not client.features.passphrase_protection
assert client.features.initialized assert client.features.initialized
assert client.features.label == LABEL assert client.features.label == LABEL
assert not client.features.needs_backup assert client.features.backup_availability == BackupAvailability.NotAvailable
assert not client.features.unfinished_backup assert not client.features.unfinished_backup
assert not client.features.no_backup assert not client.features.no_backup
@ -228,7 +234,7 @@ def test_upgrade_reset_skip_backup(gen: str, tag: str):
assert not client.features.passphrase_protection assert not client.features.passphrase_protection
assert client.features.initialized assert client.features.initialized
assert client.features.label == LABEL assert client.features.label == LABEL
assert client.features.needs_backup assert client.features.backup_availability == BackupAvailability.Required
assert not client.features.unfinished_backup assert not client.features.unfinished_backup
assert not client.features.no_backup assert not client.features.no_backup
@ -260,7 +266,7 @@ def test_upgrade_reset_no_backup(gen: str, tag: str):
assert not client.features.passphrase_protection assert not client.features.passphrase_protection
assert client.features.initialized assert client.features.initialized
assert client.features.label == LABEL assert client.features.label == LABEL
assert not client.features.needs_backup assert client.features.backup_availability == BackupAvailability.NotAvailable
assert not client.features.unfinished_backup assert not client.features.unfinished_backup
assert client.features.no_backup assert client.features.no_backup
@ -291,7 +297,7 @@ def test_upgrade_shamir_recovery(gen: str, tag: Optional[str]):
with EmulatorWrapper(gen, tag) as emu, BackgroundDeviceHandler( with EmulatorWrapper(gen, tag) as emu, BackgroundDeviceHandler(
emu.client emu.client
) as device_handler: ) as device_handler:
assert emu.client.features.recovery_status == RecoveryStatus.NoRecovery assert emu.client.features.recovery_status == RecoveryStatus.Nothing
emu.client.watch_layout(True) emu.client.watch_layout(True)
debug = device_handler.debuglink() debug = device_handler.debuglink()
@ -312,7 +318,7 @@ def test_upgrade_shamir_recovery(gen: str, tag: Optional[str]):
with EmulatorWrapper(gen, storage=storage) as emu: with EmulatorWrapper(gen, storage=storage) as emu:
assert device_id == emu.client.features.device_id assert device_id == emu.client.features.device_id
assert emu.client.features.recovery_status == RecoveryStatus.InNormalRecovery assert emu.client.features.recovery_status == RecoveryStatus.Recovery
debug = emu.client.debug debug = emu.client.debug
emu.client.watch_layout(True) emu.client.watch_layout(True)
@ -361,19 +367,21 @@ def test_upgrade_shamir_backup(gen: str, tag: Optional[str]):
emu.client.use_passphrase("TREZOR") emu.client.use_passphrase("TREZOR")
address_passphrase = btc.get_address(emu.client, "Bitcoin", PATH) address_passphrase = btc.get_address(emu.client, "Bitcoin", PATH)
assert emu.client.features.needs_backup assert emu.client.features.backup_availability == BackupAvailability.Required
storage = emu.get_storage() storage = emu.get_storage()
with EmulatorWrapper(gen, storage=storage) as emu: with EmulatorWrapper(gen, storage=storage) as emu:
assert emu.client.features.device_id == device_id assert emu.client.features.device_id == device_id
# Create a backup of the encrypted master secret. # Create a backup of the encrypted master secret.
assert emu.client.features.needs_backup assert emu.client.features.backup_availability == BackupAvailability.Required
with emu.client: with emu.client:
IF = InputFlowSlip39BasicBackup(emu.client, False) IF = InputFlowSlip39BasicBackup(emu.client, False)
emu.client.set_input_flow(IF.get()) emu.client.set_input_flow(IF.get())
device.backup(emu.client) device.backup(emu.client)
assert not emu.client.features.needs_backup assert (
emu.client.features.backup_availability == BackupAvailability.NotAvailable
)
# Check the backup type. # Check the backup type.
assert emu.client.features.backup_type == backup_type assert emu.client.features.backup_type == backup_type