2023-05-04 12:20:24 +00:00
|
|
|
"""
|
|
|
|
Central place for defining all input flows for the device tests.
|
|
|
|
|
|
|
|
Each model has potentially its own input flow, and in most cases
|
|
|
|
we need to distinguish between them. Doing it at one place
|
|
|
|
offers a better overview of the differences and makes it easier
|
|
|
|
to maintain. The whole `device_tests` folder can then focus
|
|
|
|
only on the actual tests and data-assertions, not on the lower-level
|
|
|
|
input flow details.
|
|
|
|
"""
|
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
from __future__ import annotations
|
|
|
|
|
2023-05-04 12:20:24 +00:00
|
|
|
import time
|
2023-07-21 09:38:28 +00:00
|
|
|
from typing import Callable, Generator
|
2023-05-04 12:20:24 +00:00
|
|
|
|
2024-09-02 11:01:16 +00:00
|
|
|
from trezorlib import messages
|
|
|
|
from trezorlib.debuglink import DebugLink, LayoutContent, LayoutType
|
2023-08-15 15:58:32 +00:00
|
|
|
from trezorlib.debuglink import TrezorClientDebugLink as Client
|
|
|
|
from trezorlib.debuglink import multipage_content
|
2023-05-04 12:20:24 +00:00
|
|
|
|
|
|
|
from . import buttons
|
2023-08-11 15:57:32 +00:00
|
|
|
from . import translations as TR
|
2023-05-04 12:20:24 +00:00
|
|
|
from .common import (
|
2023-07-21 09:38:28 +00:00
|
|
|
BRGeneratorType,
|
2023-05-04 12:20:24 +00:00
|
|
|
check_pin_backoff_time,
|
2024-05-27 22:19:01 +00:00
|
|
|
click_info_button_mercury,
|
2023-06-29 15:26:51 +00:00
|
|
|
click_info_button_tt,
|
2023-05-04 12:20:24 +00:00
|
|
|
click_through,
|
2023-08-11 15:57:32 +00:00
|
|
|
get_text_possible_pagination,
|
2023-05-04 12:20:24 +00:00
|
|
|
read_and_confirm_mnemonic,
|
2023-08-11 15:57:32 +00:00
|
|
|
swipe_if_necessary,
|
2023-05-04 12:20:24 +00:00
|
|
|
)
|
2023-08-02 10:48:06 +00:00
|
|
|
from .input_flows_helpers import BackupFlow, EthereumFlow, PinFlow, RecoveryFlow
|
2023-05-04 12:20:24 +00:00
|
|
|
|
|
|
|
B = messages.ButtonRequestType
|
|
|
|
|
|
|
|
|
|
|
|
class InputFlowBase:
|
|
|
|
def __init__(self, client: Client):
|
|
|
|
self.client = client
|
|
|
|
self.debug: DebugLink = client.debug
|
2023-07-21 09:38:28 +00:00
|
|
|
self.PIN = PinFlow(self.client)
|
|
|
|
self.REC = RecoveryFlow(self.client)
|
|
|
|
self.BAK = BackupFlow(self.client)
|
2023-08-02 10:48:06 +00:00
|
|
|
self.ETH = EthereumFlow(self.client)
|
2023-05-04 12:20:24 +00:00
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def get(self) -> Callable[[], BRGeneratorType]:
|
2023-05-04 12:20:24 +00:00
|
|
|
self.client.watch_layout(True)
|
|
|
|
|
|
|
|
# There could be one common input flow for all models
|
|
|
|
if hasattr(self, "input_flow_common"):
|
|
|
|
return getattr(self, "input_flow_common")
|
2024-09-02 11:01:16 +00:00
|
|
|
elif self.client.layout_type is LayoutType.TT:
|
2023-05-04 12:20:24 +00:00
|
|
|
return self.input_flow_tt
|
2024-09-02 11:01:16 +00:00
|
|
|
elif self.client.layout_type is LayoutType.TR:
|
2023-05-04 12:20:24 +00:00
|
|
|
return self.input_flow_tr
|
2024-09-02 11:01:16 +00:00
|
|
|
elif self.client.layout_type is LayoutType.Mercury:
|
2024-03-09 21:05:05 +00:00
|
|
|
return self.input_flow_t3t1
|
2023-05-04 12:20:24 +00:00
|
|
|
else:
|
|
|
|
raise ValueError("Unknown model")
|
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def input_flow_tt(self) -> BRGeneratorType:
|
2023-05-04 12:20:24 +00:00
|
|
|
"""Special for TT"""
|
|
|
|
raise NotImplementedError
|
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def input_flow_tr(self) -> BRGeneratorType:
|
2023-05-04 12:20:24 +00:00
|
|
|
"""Special for TR"""
|
|
|
|
raise NotImplementedError
|
|
|
|
|
2024-03-09 21:05:05 +00:00
|
|
|
def input_flow_t3t1(self) -> BRGeneratorType:
|
|
|
|
"""Special for T3T1"""
|
|
|
|
raise NotImplementedError
|
|
|
|
|
2023-07-21 09:12:14 +00:00
|
|
|
def text_content(self) -> str:
|
2023-11-21 12:51:59 +00:00
|
|
|
return self.debug.read_layout().text_content()
|
2023-07-21 09:12:14 +00:00
|
|
|
|
|
|
|
def main_component(self) -> str:
|
2023-11-21 12:51:59 +00:00
|
|
|
return self.debug.read_layout().main_component()
|
2023-07-21 09:12:14 +00:00
|
|
|
|
|
|
|
def all_components(self) -> list[str]:
|
2023-11-21 12:51:59 +00:00
|
|
|
return self.debug.read_layout().all_components()
|
2023-07-21 09:12:14 +00:00
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def title(self) -> str:
|
2023-11-21 12:51:59 +00:00
|
|
|
return self.debug.read_layout().title()
|
2023-07-21 09:12:14 +00:00
|
|
|
|
2023-05-04 12:20:24 +00:00
|
|
|
|
|
|
|
class InputFlowSetupDevicePINWIpeCode(InputFlowBase):
|
|
|
|
def __init__(self, client: Client, pin: str, wipe_code: str):
|
|
|
|
super().__init__(client)
|
|
|
|
self.pin = pin
|
|
|
|
self.wipe_code = wipe_code
|
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def input_flow_common(self) -> BRGeneratorType:
|
2023-05-04 12:20:24 +00:00
|
|
|
yield # do you want to set/change the wipe code?
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
2024-09-02 11:01:16 +00:00
|
|
|
if self.client.layout_type is LayoutType.TR:
|
2024-04-07 12:15:53 +00:00
|
|
|
layout = self.debug.read_layout()
|
|
|
|
if "PinKeyboard" not in layout.all_components():
|
|
|
|
yield from swipe_if_necessary(self.debug) # wipe code info
|
|
|
|
self.debug.press_yes()
|
2023-05-12 09:19:35 +00:00
|
|
|
|
2023-05-04 12:20:24 +00:00
|
|
|
yield # enter current pin
|
|
|
|
self.debug.input(self.pin)
|
|
|
|
yield # enter new wipe code
|
|
|
|
self.debug.input(self.wipe_code)
|
|
|
|
yield # enter new wipe code again
|
|
|
|
self.debug.input(self.wipe_code)
|
|
|
|
yield # success
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
|
|
|
|
|
|
|
class InputFlowNewCodeMismatch(InputFlowBase):
|
|
|
|
def __init__(
|
|
|
|
self,
|
|
|
|
client: Client,
|
|
|
|
first_code: str,
|
|
|
|
second_code: str,
|
2023-11-21 15:55:46 +00:00
|
|
|
what: str,
|
2023-05-04 12:20:24 +00:00
|
|
|
):
|
|
|
|
super().__init__(client)
|
|
|
|
self.first_code = first_code
|
|
|
|
self.second_code = second_code
|
2023-11-21 15:55:46 +00:00
|
|
|
self.what = what
|
2023-05-04 12:20:24 +00:00
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def input_flow_common(self) -> BRGeneratorType:
|
2023-11-21 15:55:46 +00:00
|
|
|
assert (yield).name == f"set_{self.what}"
|
2023-05-04 12:20:24 +00:00
|
|
|
self.debug.press_yes()
|
|
|
|
|
2024-09-02 11:01:16 +00:00
|
|
|
if self.client.layout_type is LayoutType.TR:
|
2024-04-07 12:15:53 +00:00
|
|
|
layout = self.debug.read_layout()
|
|
|
|
if "PinKeyboard" not in layout.all_components():
|
|
|
|
yield from swipe_if_necessary(self.debug) # code info
|
|
|
|
self.debug.press_yes()
|
2023-05-12 09:19:35 +00:00
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def input_two_different_pins() -> BRGeneratorType:
|
2023-11-21 15:55:46 +00:00
|
|
|
yield from self.PIN.setup_new_pin(
|
|
|
|
self.first_code, self.second_code, what=self.what
|
|
|
|
)
|
2023-05-04 12:20:24 +00:00
|
|
|
|
|
|
|
yield from input_two_different_pins()
|
|
|
|
|
2023-11-21 15:55:46 +00:00
|
|
|
assert (yield).name == f"{self.what}_mismatch" # PIN mismatch
|
2023-05-04 12:20:24 +00:00
|
|
|
self.debug.press_yes() # try again
|
|
|
|
|
|
|
|
yield from input_two_different_pins()
|
|
|
|
|
2023-11-21 15:55:46 +00:00
|
|
|
assert (yield).name == f"{self.what}_mismatch" # PIN mismatch
|
2023-05-10 13:59:17 +00:00
|
|
|
self.debug.press_yes() # try again
|
|
|
|
|
2023-11-21 15:55:46 +00:00
|
|
|
assert (yield).name == "pin_device" # PIN entry again
|
2023-05-10 13:59:17 +00:00
|
|
|
|
2023-05-04 12:20:24 +00:00
|
|
|
self.debug.press_no() # cancel
|
|
|
|
|
|
|
|
|
|
|
|
class InputFlowCodeChangeFail(InputFlowBase):
|
|
|
|
def __init__(
|
|
|
|
self, client: Client, current_pin: str, new_pin_1: str, new_pin_2: str
|
|
|
|
):
|
|
|
|
super().__init__(client)
|
|
|
|
self.current_pin = current_pin
|
|
|
|
self.new_pin_1 = new_pin_1
|
|
|
|
self.new_pin_2 = new_pin_2
|
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def input_flow_common(self) -> BRGeneratorType:
|
2023-05-04 12:20:24 +00:00
|
|
|
yield # do you want to change pin?
|
|
|
|
self.debug.press_yes()
|
|
|
|
yield # enter current pin
|
|
|
|
self.debug.input(self.current_pin)
|
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
yield from self.PIN.setup_new_pin(self.new_pin_1, self.new_pin_2)
|
2023-05-04 12:20:24 +00:00
|
|
|
|
|
|
|
yield # PIN mismatch
|
|
|
|
self.debug.press_yes() # try again
|
|
|
|
|
|
|
|
# failed retry
|
|
|
|
yield # enter current pin again
|
|
|
|
self.client.cancel()
|
|
|
|
|
|
|
|
|
|
|
|
class InputFlowWrongPIN(InputFlowBase):
|
|
|
|
def __init__(self, client: Client, wrong_pin: str):
|
|
|
|
super().__init__(client)
|
|
|
|
self.wrong_pin = wrong_pin
|
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def input_flow_common(self) -> BRGeneratorType:
|
2023-05-04 12:20:24 +00:00
|
|
|
yield # do you want to change pin?
|
|
|
|
self.debug.press_yes()
|
|
|
|
yield # enter wrong current pin
|
|
|
|
self.debug.input(self.wrong_pin)
|
|
|
|
yield
|
|
|
|
self.debug.press_no()
|
|
|
|
|
|
|
|
|
|
|
|
class InputFlowPINBackoff(InputFlowBase):
|
|
|
|
def __init__(self, client: Client, wrong_pin: str, good_pin: str):
|
|
|
|
super().__init__(client)
|
|
|
|
self.wrong_pin = wrong_pin
|
|
|
|
self.good_pin = good_pin
|
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def input_flow_common(self) -> BRGeneratorType:
|
2023-05-04 12:20:24 +00:00
|
|
|
"""Inputting some bad PINs and finally the correct one"""
|
|
|
|
yield # PIN entry
|
|
|
|
for attempt in range(3):
|
|
|
|
start = time.time()
|
|
|
|
self.debug.input(self.wrong_pin)
|
|
|
|
yield # PIN entry
|
|
|
|
check_pin_backoff_time(attempt, start)
|
|
|
|
self.debug.input(self.good_pin)
|
|
|
|
|
|
|
|
|
|
|
|
class InputFlowSignMessagePagination(InputFlowBase):
|
|
|
|
def __init__(self, client: Client):
|
|
|
|
super().__init__(client)
|
|
|
|
self.message_read = ""
|
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def input_flow_tt(self) -> BRGeneratorType:
|
2023-05-04 12:20:24 +00:00
|
|
|
# collect screen contents into `message_read`.
|
|
|
|
# Using a helper debuglink function to assemble the final text.
|
|
|
|
layouts: list[LayoutContent] = []
|
|
|
|
|
|
|
|
br = yield # confirm address
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.read_layout()
|
2023-05-04 12:20:24 +00:00
|
|
|
self.debug.press_yes()
|
|
|
|
|
|
|
|
br = yield
|
|
|
|
assert br.pages is not None
|
|
|
|
for i in range(br.pages):
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = self.debug.read_layout()
|
2023-05-04 12:20:24 +00:00
|
|
|
layouts.append(layout)
|
|
|
|
|
|
|
|
if i < br.pages - 1:
|
|
|
|
self.debug.swipe_up()
|
|
|
|
|
|
|
|
self.message_read = multipage_content(layouts)
|
|
|
|
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def input_flow_tr(self) -> BRGeneratorType:
|
2023-05-12 09:19:35 +00:00
|
|
|
# confirm address
|
|
|
|
yield
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
2023-08-08 10:35:28 +00:00
|
|
|
# press info
|
|
|
|
yield
|
|
|
|
self.debug.press_right()
|
|
|
|
|
|
|
|
# paginate through the whole message
|
2023-05-12 09:19:35 +00:00
|
|
|
br = yield
|
|
|
|
# TODO: try load the message_read the same way as in model T
|
|
|
|
if br.pages is not None:
|
|
|
|
for i in range(br.pages):
|
|
|
|
if i < br.pages - 1:
|
|
|
|
self.debug.swipe_up()
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
2023-08-08 10:35:28 +00:00
|
|
|
# confirm message
|
|
|
|
yield
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
2024-03-09 21:05:05 +00:00
|
|
|
def input_flow_t3t1(self) -> BRGeneratorType:
|
|
|
|
# collect screen contents into `message_read`.
|
|
|
|
# Using a helper debuglink function to assemble the final text.
|
|
|
|
layouts: list[LayoutContent] = []
|
|
|
|
|
|
|
|
br = yield # confirm address
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.read_layout()
|
2024-03-09 21:05:05 +00:00
|
|
|
self.debug.press_yes()
|
|
|
|
|
|
|
|
br = yield
|
2024-05-31 00:39:13 +00:00
|
|
|
# assert br.pages is not None
|
|
|
|
for i in range(br.pages or 1):
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = self.debug.read_layout()
|
2024-03-09 21:05:05 +00:00
|
|
|
layouts.append(layout)
|
|
|
|
|
2024-05-31 00:39:13 +00:00
|
|
|
if br.pages and i < br.pages - 1:
|
2024-03-09 21:05:05 +00:00
|
|
|
self.debug.swipe_up()
|
|
|
|
|
|
|
|
self.message_read = multipage_content(layouts)
|
|
|
|
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
2023-05-04 12:20:24 +00:00
|
|
|
|
2023-10-19 15:29:29 +00:00
|
|
|
class InputFlowSignMessageInfo(InputFlowBase):
|
|
|
|
def __init__(self, client: Client):
|
|
|
|
super().__init__(client)
|
|
|
|
|
|
|
|
def input_flow_tt(self) -> BRGeneratorType:
|
|
|
|
yield
|
|
|
|
# show address/message info
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.click(buttons.CORNER_BUTTON)
|
|
|
|
self.debug.click(buttons.CORNER_BUTTON)
|
|
|
|
self.debug.press_no()
|
2023-08-11 15:57:32 +00:00
|
|
|
self.debug.synchronize_at("IconDialog")
|
2023-10-19 15:29:29 +00:00
|
|
|
# address mismatch?
|
|
|
|
self.debug.press_no()
|
|
|
|
yield
|
|
|
|
self.debug.press_yes()
|
|
|
|
yield
|
|
|
|
self.debug.press_no()
|
|
|
|
yield
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.press_no()
|
|
|
|
self.debug.press_yes()
|
2023-10-19 15:29:29 +00:00
|
|
|
|
2024-03-09 21:05:05 +00:00
|
|
|
def input_flow_t3t1(self) -> BRGeneratorType:
|
|
|
|
yield
|
|
|
|
# show address/message info
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.click(buttons.CORNER_BUTTON)
|
|
|
|
self.debug.click(buttons.CORNER_BUTTON)
|
|
|
|
self.debug.press_no()
|
2024-03-09 21:05:05 +00:00
|
|
|
self.debug.synchronize_at("IconDialog")
|
|
|
|
# address mismatch?
|
|
|
|
self.debug.press_no()
|
|
|
|
yield
|
|
|
|
self.debug.press_yes()
|
|
|
|
yield
|
|
|
|
self.debug.press_no()
|
|
|
|
yield
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.press_no()
|
|
|
|
self.debug.press_yes()
|
2024-03-09 21:05:05 +00:00
|
|
|
|
2023-10-19 15:29:29 +00:00
|
|
|
|
2023-05-04 12:20:24 +00:00
|
|
|
class InputFlowShowAddressQRCode(InputFlowBase):
|
|
|
|
def __init__(self, client: Client):
|
|
|
|
super().__init__(client)
|
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def input_flow_tt(self) -> BRGeneratorType:
|
2023-05-04 12:20:24 +00:00
|
|
|
yield
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.click(buttons.CORNER_BUTTON)
|
2023-05-04 12:20:24 +00:00
|
|
|
# synchronize; TODO get rid of this once we have single-global-layout
|
2023-09-26 22:17:38 +00:00
|
|
|
self.debug.synchronize_at("SimplePage")
|
2023-05-04 12:20:24 +00:00
|
|
|
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.swipe_left()
|
|
|
|
self.debug.swipe_right()
|
|
|
|
self.debug.swipe_left()
|
|
|
|
self.debug.click(buttons.CORNER_BUTTON)
|
|
|
|
self.debug.press_no()
|
|
|
|
self.debug.press_no()
|
2023-05-04 12:20:24 +00:00
|
|
|
self.debug.press_yes()
|
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def input_flow_tr(self) -> BRGeneratorType:
|
2023-09-22 09:49:40 +00:00
|
|
|
# Find out the page-length of the address
|
|
|
|
br = yield
|
|
|
|
if br.pages is not None:
|
|
|
|
address_swipes = br.pages - 1
|
|
|
|
else:
|
|
|
|
address_swipes = 0
|
|
|
|
for _ in range(address_swipes):
|
|
|
|
self.debug.press_right()
|
|
|
|
|
2023-05-12 09:19:35 +00:00
|
|
|
# Go into details
|
|
|
|
self.debug.press_right()
|
|
|
|
# Go through details and back
|
|
|
|
self.debug.press_right()
|
|
|
|
self.debug.press_left()
|
|
|
|
self.debug.press_left()
|
|
|
|
# Confirm
|
2023-09-22 09:49:40 +00:00
|
|
|
for _ in range(address_swipes):
|
|
|
|
self.debug.press_right()
|
2023-05-12 09:19:35 +00:00
|
|
|
self.debug.press_middle()
|
|
|
|
|
2024-03-09 21:05:05 +00:00
|
|
|
def input_flow_t3t1(self) -> BRGeneratorType:
|
|
|
|
yield
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.click(buttons.CORNER_BUTTON)
|
2024-03-09 21:05:05 +00:00
|
|
|
# synchronize; TODO get rid of this once we have single-global-layout
|
2024-05-06 22:06:32 +00:00
|
|
|
self.debug.synchronize_at("VerticalMenu")
|
|
|
|
# menu
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.click(buttons.VERTICAL_MENU[0])
|
2024-05-06 22:06:32 +00:00
|
|
|
self.debug.synchronize_at("Qr")
|
|
|
|
# qr code
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.click(buttons.CORNER_BUTTON)
|
2024-05-06 22:06:32 +00:00
|
|
|
# menu
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.click(buttons.VERTICAL_MENU[1])
|
2024-05-06 22:06:32 +00:00
|
|
|
# address details
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.click(buttons.CORNER_BUTTON)
|
2024-05-06 22:06:32 +00:00
|
|
|
# menu
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.click(buttons.VERTICAL_MENU[2])
|
2024-05-06 22:06:32 +00:00
|
|
|
# cancel
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.swipe_up()
|
2024-05-06 22:06:32 +00:00
|
|
|
# really cancel
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.click(buttons.CORNER_BUTTON)
|
2024-05-06 22:06:32 +00:00
|
|
|
# menu
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = self.debug.click(buttons.CORNER_BUTTON)
|
2024-05-06 22:06:32 +00:00
|
|
|
|
|
|
|
while "PromptScreen" not in layout.all_components():
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = self.debug.swipe_up()
|
2024-05-06 22:06:32 +00:00
|
|
|
self.debug.synchronize_at("PromptScreen")
|
|
|
|
# tap to confirm
|
|
|
|
self.debug.click(buttons.TAP_TO_CONFIRM)
|
2024-03-09 21:05:05 +00:00
|
|
|
|
2023-05-04 12:20:24 +00:00
|
|
|
|
|
|
|
class InputFlowShowAddressQRCodeCancel(InputFlowBase):
|
|
|
|
def __init__(self, client: Client):
|
|
|
|
super().__init__(client)
|
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def input_flow_tt(self) -> BRGeneratorType:
|
2023-05-04 12:20:24 +00:00
|
|
|
yield
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.click(buttons.CORNER_BUTTON)
|
2023-05-04 12:20:24 +00:00
|
|
|
# synchronize; TODO get rid of this once we have single-global-layout
|
2023-09-26 22:17:38 +00:00
|
|
|
self.debug.synchronize_at("SimplePage")
|
2023-05-04 12:20:24 +00:00
|
|
|
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.swipe_left()
|
|
|
|
self.debug.click(buttons.CORNER_BUTTON)
|
|
|
|
self.debug.press_no()
|
2023-05-04 12:20:24 +00:00
|
|
|
self.debug.press_yes()
|
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def input_flow_tr(self) -> BRGeneratorType:
|
2023-05-12 09:19:35 +00:00
|
|
|
yield
|
|
|
|
# Go into details
|
|
|
|
self.debug.press_right()
|
|
|
|
# Go through details and back
|
|
|
|
self.debug.press_right()
|
|
|
|
self.debug.press_left()
|
|
|
|
self.debug.press_left()
|
|
|
|
# Cancel
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.press_left()
|
2023-05-12 09:19:35 +00:00
|
|
|
# Confirm address mismatch
|
2023-08-11 15:57:32 +00:00
|
|
|
# Clicking right twice, as some languages can have two pages
|
|
|
|
self.debug.press_right()
|
2023-05-12 09:19:35 +00:00
|
|
|
self.debug.press_right()
|
|
|
|
|
2024-03-09 21:05:05 +00:00
|
|
|
def input_flow_t3t1(self) -> BRGeneratorType:
|
|
|
|
yield
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.click(buttons.CORNER_BUTTON)
|
2024-03-09 21:05:05 +00:00
|
|
|
# synchronize; TODO get rid of this once we have single-global-layout
|
2024-05-06 22:06:32 +00:00
|
|
|
self.debug.synchronize_at("VerticalMenu")
|
|
|
|
# menu
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.click(buttons.VERTICAL_MENU[0])
|
2024-05-06 22:06:32 +00:00
|
|
|
self.debug.synchronize_at("Qr")
|
|
|
|
# qr code
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.click(buttons.CORNER_BUTTON)
|
2024-05-06 22:06:32 +00:00
|
|
|
# menu
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.click(buttons.VERTICAL_MENU[1])
|
2024-05-06 22:06:32 +00:00
|
|
|
# address details
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.click(buttons.CORNER_BUTTON)
|
2024-05-06 22:06:32 +00:00
|
|
|
# menu
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.click(buttons.VERTICAL_MENU[2])
|
2024-05-06 22:06:32 +00:00
|
|
|
# cancel
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.swipe_up()
|
2024-05-06 22:06:32 +00:00
|
|
|
self.debug.synchronize_at("PromptScreen")
|
|
|
|
# really cancel
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.click(buttons.TAP_TO_CONFIRM)
|
2024-03-09 21:05:05 +00:00
|
|
|
|
2023-05-04 12:20:24 +00:00
|
|
|
|
|
|
|
class InputFlowShowMultisigXPUBs(InputFlowBase):
|
|
|
|
def __init__(self, client: Client, address: str, xpubs: list[str], index: int):
|
|
|
|
super().__init__(client)
|
|
|
|
self.address = address
|
|
|
|
self.xpubs = xpubs
|
|
|
|
self.index = index
|
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def input_flow_tt(self) -> BRGeneratorType:
|
2023-09-07 11:51:26 +00:00
|
|
|
yield # multisig address warning
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
2023-05-04 12:20:24 +00:00
|
|
|
yield # show address
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = self.debug.read_layout()
|
2023-08-11 15:57:32 +00:00
|
|
|
TR.assert_in(layout.title(), "address__title_receive_address")
|
|
|
|
assert "(MULTISIG)" in layout.title()
|
2023-05-04 12:20:24 +00:00
|
|
|
assert layout.text_content().replace(" ", "") == self.address
|
|
|
|
|
|
|
|
self.debug.click(buttons.CORNER_BUTTON)
|
2023-07-21 09:12:14 +00:00
|
|
|
assert "Qr" in self.all_components()
|
2023-05-04 12:20:24 +00:00
|
|
|
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = self.debug.swipe_left()
|
2023-05-04 12:20:24 +00:00
|
|
|
# address details
|
|
|
|
assert "Multisig 2 of 3" in layout.screen_content()
|
2024-08-22 11:16:38 +00:00
|
|
|
TR.assert_in(layout.screen_content(), "address_details__derivation_path")
|
2023-05-04 12:20:24 +00:00
|
|
|
|
|
|
|
# Three xpub pages with the same testing logic
|
|
|
|
for xpub_num in range(3):
|
2023-11-21 12:51:59 +00:00
|
|
|
expected_title = f"MULTISIG XPUB #{xpub_num + 1}\n" + (
|
2023-11-21 15:55:46 +00:00
|
|
|
"(Yours)" if self.index == xpub_num else "(Cosigner)"
|
2023-11-21 12:51:59 +00:00
|
|
|
)
|
|
|
|
layout = self.debug.swipe_left()
|
|
|
|
assert expected_title == layout.title()
|
2023-05-04 12:20:24 +00:00
|
|
|
content = layout.text_content().replace(" ", "")
|
|
|
|
assert self.xpubs[xpub_num] in content
|
|
|
|
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.click(buttons.CORNER_BUTTON)
|
2023-05-04 12:20:24 +00:00
|
|
|
# show address
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.press_no()
|
2023-05-04 12:20:24 +00:00
|
|
|
# address mismatch
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.press_no()
|
2023-05-04 12:20:24 +00:00
|
|
|
# show address
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def input_flow_tr(self) -> BRGeneratorType:
|
2023-09-07 11:51:26 +00:00
|
|
|
yield # multisig address warning
|
|
|
|
self.debug.press_middle()
|
|
|
|
|
2023-05-12 09:19:35 +00:00
|
|
|
yield # show address
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = self.debug.read_layout()
|
2023-08-11 15:57:32 +00:00
|
|
|
TR.assert_in(layout.title(), "address__title_receive_address")
|
|
|
|
assert "(MULTISIG)" in layout.title()
|
2023-05-12 09:19:35 +00:00
|
|
|
assert layout.text_content().replace(" ", "") == self.address
|
|
|
|
|
|
|
|
self.debug.press_right()
|
2023-07-21 09:12:14 +00:00
|
|
|
assert "Qr" in self.all_components()
|
2023-05-12 09:19:35 +00:00
|
|
|
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = self.debug.press_right()
|
2023-05-12 09:19:35 +00:00
|
|
|
# address details
|
|
|
|
# TODO: locate it more precisely
|
|
|
|
assert "Multisig 2 of 3" in layout.json_str
|
|
|
|
|
|
|
|
# Three xpub pages with the same testing logic
|
|
|
|
for xpub_num in range(3):
|
2023-11-21 12:51:59 +00:00
|
|
|
expected_title = f"MULTISIG XPUB #{xpub_num + 1} " + (
|
2023-11-21 15:55:46 +00:00
|
|
|
"(Yours)" if self.index == xpub_num else "(Cosigner)"
|
2023-11-21 12:51:59 +00:00
|
|
|
)
|
|
|
|
layout = self.debug.press_right()
|
2023-05-12 09:19:35 +00:00
|
|
|
assert expected_title in layout.title()
|
|
|
|
xpub_part_1 = layout.text_content().replace(" ", "")
|
|
|
|
# Press "SHOW MORE"
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = self.debug.press_middle()
|
2023-05-12 09:19:35 +00:00
|
|
|
xpub_part_2 = layout.text_content().replace(" ", "")
|
|
|
|
# Go back
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.press_left()
|
2023-05-12 09:19:35 +00:00
|
|
|
assert self.xpubs[xpub_num] == xpub_part_1 + xpub_part_2
|
|
|
|
|
|
|
|
for _ in range(5):
|
|
|
|
self.debug.press_left()
|
|
|
|
# show address
|
|
|
|
self.debug.press_left()
|
|
|
|
# address mismatch
|
|
|
|
self.debug.press_left()
|
|
|
|
# show address
|
|
|
|
self.debug.press_middle()
|
|
|
|
|
2024-03-09 21:05:05 +00:00
|
|
|
def input_flow_t3t1(self) -> BRGeneratorType:
|
|
|
|
yield # multisig address warning
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.click(buttons.CORNER_BUTTON)
|
2024-05-06 22:06:32 +00:00
|
|
|
self.debug.synchronize_at("VerticalMenu")
|
|
|
|
self.debug.click(buttons.VERTICAL_MENU[1])
|
2024-03-09 21:05:05 +00:00
|
|
|
|
|
|
|
yield # show address
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = self.debug.read_layout()
|
2024-03-09 21:05:05 +00:00
|
|
|
TR.assert_in(layout.title(), "address__title_receive_address")
|
|
|
|
assert layout.text_content().replace(" ", "") == self.address
|
|
|
|
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.click(buttons.CORNER_BUTTON)
|
2024-05-06 22:06:32 +00:00
|
|
|
assert "VerticalMenu" in self.all_components()
|
|
|
|
# menu
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.click(buttons.VERTICAL_MENU[0])
|
2024-05-06 22:06:32 +00:00
|
|
|
self.debug.synchronize_at("Qr")
|
|
|
|
# qr code
|
2024-03-09 21:05:05 +00:00
|
|
|
assert "Qr" in self.all_components()
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.click(buttons.CORNER_BUTTON)
|
2024-05-06 22:06:32 +00:00
|
|
|
# menu
|
|
|
|
assert "VerticalMenu" in self.all_components()
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.click(buttons.VERTICAL_MENU[1])
|
2024-05-06 22:06:32 +00:00
|
|
|
layout = self.debug.synchronize_at("AddressDetails")
|
2024-03-09 21:05:05 +00:00
|
|
|
# address details
|
|
|
|
assert "Multisig 2 of 3" in layout.screen_content()
|
2024-05-06 22:06:32 +00:00
|
|
|
TR.assert_in(layout.screen_content(), "address_details__derivation_path")
|
2024-03-09 21:05:05 +00:00
|
|
|
|
2024-05-06 22:06:32 +00:00
|
|
|
# three xpub pages with the same testing logic
|
|
|
|
for _xpub_num in range(3):
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = self.debug.swipe_left()
|
|
|
|
layout = self.debug.swipe_left()
|
2024-03-09 21:05:05 +00:00
|
|
|
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.click(buttons.CORNER_BUTTON)
|
2024-05-06 22:06:32 +00:00
|
|
|
layout = self.debug.synchronize_at("VerticalMenu")
|
|
|
|
# menu
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.click(buttons.VERTICAL_MENU[2])
|
2024-05-06 22:06:32 +00:00
|
|
|
# cancel
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.swipe_up()
|
2024-05-06 22:06:32 +00:00
|
|
|
# really cancel
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.click(buttons.CORNER_BUTTON)
|
2024-05-06 22:06:32 +00:00
|
|
|
layout = self.debug.synchronize_at("VerticalMenu")
|
|
|
|
# menu
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.click(buttons.CORNER_BUTTON)
|
2024-05-06 22:06:32 +00:00
|
|
|
layout = self.debug.synchronize_at("Paragraphs")
|
|
|
|
# address
|
|
|
|
while "PromptScreen" not in layout.all_components():
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = self.debug.swipe_up()
|
2024-05-06 22:06:32 +00:00
|
|
|
self.debug.synchronize_at("PromptScreen")
|
|
|
|
# tap to confirm
|
2024-03-09 21:05:05 +00:00
|
|
|
self.debug.press_yes()
|
|
|
|
|
2023-05-04 12:20:24 +00:00
|
|
|
|
2023-07-26 14:45:10 +00:00
|
|
|
class InputFlowShowXpubQRCode(InputFlowBase):
|
2023-07-26 14:47:01 +00:00
|
|
|
def __init__(self, client: Client, passphrase: bool = False):
|
2023-07-26 14:45:10 +00:00
|
|
|
super().__init__(client)
|
2023-07-26 14:47:01 +00:00
|
|
|
self.passphrase = passphrase
|
|
|
|
|
|
|
|
def input_flow_tt(self) -> BRGeneratorType:
|
|
|
|
if self.passphrase:
|
2023-09-07 11:51:26 +00:00
|
|
|
yield
|
2023-07-26 14:47:01 +00:00
|
|
|
self.debug.press_yes()
|
2023-09-07 11:51:26 +00:00
|
|
|
yield
|
2023-07-26 14:47:01 +00:00
|
|
|
self.debug.press_yes()
|
2023-07-26 14:45:10 +00:00
|
|
|
|
|
|
|
br = yield
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = self.debug.read_layout()
|
2023-09-07 11:51:26 +00:00
|
|
|
if "coinjoin" in layout.title().lower() or br.code == B.UnknownDerivationPath:
|
2023-07-26 14:45:10 +00:00
|
|
|
self.debug.press_yes()
|
|
|
|
br = yield
|
|
|
|
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.click(buttons.CORNER_BUTTON)
|
2023-07-26 14:45:10 +00:00
|
|
|
# synchronize; TODO get rid of this once we have single-global-layout
|
2023-09-26 22:17:38 +00:00
|
|
|
self.debug.synchronize_at("SimplePage")
|
2023-07-26 14:45:10 +00:00
|
|
|
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.swipe_left()
|
|
|
|
self.debug.swipe_right()
|
|
|
|
self.debug.swipe_left()
|
|
|
|
self.debug.click(buttons.CORNER_BUTTON)
|
|
|
|
self.debug.press_no()
|
|
|
|
self.debug.press_no()
|
2023-07-26 14:45:10 +00:00
|
|
|
for _ in range(br.pages - 1):
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.swipe_up()
|
2023-07-26 14:45:10 +00:00
|
|
|
self.debug.press_yes()
|
|
|
|
|
|
|
|
def input_flow_tr(self) -> BRGeneratorType:
|
|
|
|
if self.passphrase:
|
2023-09-07 11:51:26 +00:00
|
|
|
yield
|
2023-07-26 14:45:10 +00:00
|
|
|
self.debug.press_right()
|
2023-09-07 11:51:26 +00:00
|
|
|
yield
|
2023-07-26 14:45:10 +00:00
|
|
|
self.debug.press_right()
|
|
|
|
|
|
|
|
br = yield
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = self.debug.read_layout()
|
2023-09-07 11:51:26 +00:00
|
|
|
if "coinjoin" in layout.title().lower() or br.code == B.UnknownDerivationPath:
|
|
|
|
self.debug.press_yes()
|
2023-07-26 14:45:10 +00:00
|
|
|
br = yield
|
|
|
|
|
|
|
|
# Go into details
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.press_right()
|
2023-07-26 14:45:10 +00:00
|
|
|
# Go through details and back
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.press_right()
|
|
|
|
self.debug.press_right()
|
|
|
|
self.debug.press_right()
|
|
|
|
self.debug.press_left()
|
|
|
|
self.debug.press_left()
|
2023-07-26 14:45:10 +00:00
|
|
|
assert br.pages is not None
|
|
|
|
for _ in range(br.pages - 1):
|
|
|
|
self.debug.press_right()
|
|
|
|
# Confirm
|
|
|
|
self.debug.press_middle()
|
|
|
|
|
2024-03-09 21:05:05 +00:00
|
|
|
def input_flow_t3t1(self) -> BRGeneratorType:
|
|
|
|
if self.passphrase:
|
|
|
|
yield
|
|
|
|
self.debug.press_yes()
|
|
|
|
yield
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
|
|
|
br = yield
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = self.debug.read_layout()
|
2024-03-09 21:05:05 +00:00
|
|
|
if "coinjoin" in layout.title().lower() or br.code == B.UnknownDerivationPath:
|
|
|
|
self.debug.press_yes()
|
|
|
|
br = yield
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = self.debug.read_layout()
|
2024-05-06 22:06:32 +00:00
|
|
|
|
2024-06-06 12:48:56 +00:00
|
|
|
assert layout.title() in TR.translate("address__public_key") + ["XPUB"]
|
2024-03-09 21:05:05 +00:00
|
|
|
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.click(buttons.CORNER_BUTTON)
|
2024-05-06 22:06:32 +00:00
|
|
|
assert "VerticalMenu" in self.all_components()
|
|
|
|
# menu
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.click(buttons.VERTICAL_MENU[0])
|
2024-05-06 22:06:32 +00:00
|
|
|
self.debug.synchronize_at("Qr")
|
|
|
|
# qr code
|
|
|
|
assert "Qr" in self.all_components()
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.click(buttons.CORNER_BUTTON)
|
2024-05-06 22:06:32 +00:00
|
|
|
# menu
|
|
|
|
assert "VerticalMenu" in self.all_components()
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.click(buttons.VERTICAL_MENU[1])
|
2024-05-06 22:06:32 +00:00
|
|
|
layout = self.debug.synchronize_at("AddressDetails")
|
|
|
|
# address details
|
|
|
|
TR.assert_in(layout.screen_content(), "address_details__derivation_path")
|
2024-03-09 21:05:05 +00:00
|
|
|
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.click(buttons.CORNER_BUTTON)
|
2024-05-06 22:06:32 +00:00
|
|
|
layout = self.debug.synchronize_at("VerticalMenu")
|
|
|
|
# menu
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.click(buttons.VERTICAL_MENU[2])
|
2024-05-06 22:06:32 +00:00
|
|
|
# cancel
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.swipe_up()
|
2024-05-06 22:06:32 +00:00
|
|
|
# really cancel
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.click(buttons.CORNER_BUTTON)
|
2024-05-06 22:06:32 +00:00
|
|
|
layout = self.debug.synchronize_at("VerticalMenu")
|
|
|
|
# menu
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.click(buttons.CORNER_BUTTON)
|
2024-05-06 22:06:32 +00:00
|
|
|
layout = self.debug.synchronize_at("Paragraphs")
|
|
|
|
# address
|
|
|
|
while "PromptScreen" not in layout.all_components():
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = self.debug.swipe_up()
|
2024-05-06 22:06:32 +00:00
|
|
|
self.debug.synchronize_at("PromptScreen")
|
|
|
|
# tap to confirm
|
2024-03-09 21:05:05 +00:00
|
|
|
self.debug.press_yes()
|
|
|
|
|
2023-07-26 14:45:10 +00:00
|
|
|
|
2023-05-04 12:20:24 +00:00
|
|
|
class InputFlowPaymentRequestDetails(InputFlowBase):
|
|
|
|
def __init__(self, client: Client, outputs: list[messages.TxOutputType]):
|
|
|
|
super().__init__(client)
|
|
|
|
self.outputs = outputs
|
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def input_flow_tt(self) -> BRGeneratorType:
|
2023-05-04 12:20:24 +00:00
|
|
|
yield # request to see details
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.read_layout()
|
2023-05-04 12:20:24 +00:00
|
|
|
self.debug.press_info()
|
|
|
|
|
|
|
|
yield # confirm first output
|
2023-07-21 09:12:14 +00:00
|
|
|
assert self.outputs[0].address[:16] in self.text_content() # type: ignore
|
2023-05-04 12:20:24 +00:00
|
|
|
self.debug.press_yes()
|
|
|
|
yield # confirm first output
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.read_layout()
|
2023-05-04 12:20:24 +00:00
|
|
|
self.debug.press_yes()
|
|
|
|
|
|
|
|
yield # confirm second output
|
2023-07-21 09:12:14 +00:00
|
|
|
assert self.outputs[1].address[:16] in self.text_content() # type: ignore
|
2023-05-04 12:20:24 +00:00
|
|
|
self.debug.press_yes()
|
|
|
|
yield # confirm second output
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.read_layout()
|
2023-05-04 12:20:24 +00:00
|
|
|
self.debug.press_yes()
|
|
|
|
|
|
|
|
yield # confirm transaction
|
|
|
|
self.debug.press_yes()
|
|
|
|
yield # confirm transaction
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
2024-03-09 21:05:05 +00:00
|
|
|
def input_flow_t3t1(self) -> BRGeneratorType:
|
|
|
|
yield # request to see details
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.read_layout()
|
2024-03-09 21:05:05 +00:00
|
|
|
self.debug.press_info()
|
|
|
|
|
|
|
|
yield # confirm first output
|
|
|
|
assert self.outputs[0].address[:16] in self.text_content() # type: ignore
|
2024-05-21 21:49:08 +00:00
|
|
|
self.debug.swipe_up()
|
2024-03-09 21:05:05 +00:00
|
|
|
yield # confirm first output
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.read_layout()
|
2024-05-21 21:49:08 +00:00
|
|
|
self.debug.swipe_up()
|
2024-03-09 21:05:05 +00:00
|
|
|
|
|
|
|
yield # confirm second output
|
|
|
|
assert self.outputs[1].address[:16] in self.text_content() # type: ignore
|
2024-05-21 21:49:08 +00:00
|
|
|
self.debug.swipe_up()
|
2024-03-09 21:05:05 +00:00
|
|
|
yield # confirm second output
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.read_layout()
|
2024-05-21 21:49:08 +00:00
|
|
|
self.debug.swipe_up()
|
2024-03-09 21:05:05 +00:00
|
|
|
|
|
|
|
yield # confirm transaction
|
2024-05-21 21:49:08 +00:00
|
|
|
self.debug.swipe_up()
|
2024-03-09 21:05:05 +00:00
|
|
|
self.debug.press_yes()
|
|
|
|
|
2023-05-04 12:20:24 +00:00
|
|
|
|
|
|
|
class InputFlowSignTxHighFee(InputFlowBase):
|
|
|
|
def __init__(self, client: Client):
|
|
|
|
super().__init__(client)
|
|
|
|
self.finished = False
|
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def go_through_all_screens(self, screens: list[B]) -> BRGeneratorType:
|
2023-05-04 12:20:24 +00:00
|
|
|
for expected in screens:
|
|
|
|
br = yield
|
|
|
|
assert br.code == expected
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
|
|
|
self.finished = True
|
|
|
|
|
2024-05-21 21:49:08 +00:00
|
|
|
def input_flow_tt(self) -> BRGeneratorType:
|
2023-05-04 12:20:24 +00:00
|
|
|
screens = [
|
|
|
|
B.ConfirmOutput,
|
|
|
|
B.ConfirmOutput,
|
|
|
|
B.FeeOverThreshold,
|
|
|
|
B.SignTx,
|
|
|
|
]
|
|
|
|
yield from self.go_through_all_screens(screens)
|
|
|
|
|
2024-05-21 21:49:08 +00:00
|
|
|
def input_flow_tr(self) -> BRGeneratorType:
|
|
|
|
screens = [
|
|
|
|
B.ConfirmOutput,
|
|
|
|
B.ConfirmOutput,
|
|
|
|
B.FeeOverThreshold,
|
|
|
|
B.SignTx,
|
|
|
|
]
|
|
|
|
yield from self.go_through_all_screens(screens)
|
|
|
|
|
|
|
|
def input_flow_t3t1(self) -> BRGeneratorType:
|
|
|
|
screens = [
|
|
|
|
B.ConfirmOutput,
|
|
|
|
B.ConfirmOutput,
|
|
|
|
B.FeeOverThreshold,
|
|
|
|
B.SignTx,
|
|
|
|
]
|
|
|
|
for expected in screens:
|
|
|
|
br = yield
|
|
|
|
assert br.code == expected
|
|
|
|
self.debug.swipe_up()
|
|
|
|
if br.code == B.SignTx:
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
|
|
|
self.finished = True
|
|
|
|
|
2023-05-04 12:20:24 +00:00
|
|
|
|
2023-11-21 12:51:59 +00:00
|
|
|
def sign_tx_go_to_info(client: Client) -> Generator[None, messages.ButtonRequest, str]:
|
2023-06-20 15:19:56 +00:00
|
|
|
yield # confirm output
|
2023-11-21 12:51:59 +00:00
|
|
|
client.debug.read_layout()
|
2023-06-20 15:19:56 +00:00
|
|
|
client.debug.press_yes()
|
|
|
|
yield # confirm output
|
2023-11-21 12:51:59 +00:00
|
|
|
client.debug.read_layout()
|
2023-06-20 15:19:56 +00:00
|
|
|
client.debug.press_yes()
|
|
|
|
|
|
|
|
yield # confirm transaction
|
2023-11-21 12:51:59 +00:00
|
|
|
client.debug.read_layout()
|
2023-06-20 15:19:56 +00:00
|
|
|
client.debug.press_info()
|
|
|
|
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = client.debug.read_layout()
|
2023-08-11 15:57:32 +00:00
|
|
|
content = layout.text_content()
|
2023-06-20 15:19:56 +00:00
|
|
|
|
2023-11-21 12:51:59 +00:00
|
|
|
client.debug.click(buttons.CORNER_BUTTON)
|
2023-06-20 15:19:56 +00:00
|
|
|
|
|
|
|
return content
|
|
|
|
|
|
|
|
|
2024-05-21 21:49:08 +00:00
|
|
|
def sign_tx_go_to_info_t3t1(
|
|
|
|
client: Client, multi_account: bool = False
|
2023-11-21 12:51:59 +00:00
|
|
|
) -> Generator[None, messages.ButtonRequest, str]:
|
2024-05-21 21:49:08 +00:00
|
|
|
yield # confirm output
|
2023-11-21 12:51:59 +00:00
|
|
|
client.debug.read_layout()
|
2024-05-21 21:49:08 +00:00
|
|
|
client.debug.swipe_up()
|
|
|
|
yield # confirm output
|
2023-11-21 12:51:59 +00:00
|
|
|
client.debug.read_layout()
|
2024-05-21 21:49:08 +00:00
|
|
|
client.debug.swipe_up()
|
|
|
|
|
|
|
|
if multi_account:
|
|
|
|
yield
|
2023-11-21 12:51:59 +00:00
|
|
|
client.debug.read_layout()
|
2024-05-21 21:49:08 +00:00
|
|
|
client.debug.swipe_up()
|
|
|
|
|
|
|
|
yield # confirm transaction
|
2023-11-21 12:51:59 +00:00
|
|
|
client.debug.read_layout()
|
2024-05-21 21:49:08 +00:00
|
|
|
client.debug.click(buttons.CORNER_BUTTON)
|
|
|
|
client.debug.synchronize_at("VerticalMenu")
|
|
|
|
client.debug.click(buttons.VERTICAL_MENU[0])
|
|
|
|
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = client.debug.read_layout()
|
2024-05-21 21:49:08 +00:00
|
|
|
content = layout.text_content()
|
|
|
|
|
|
|
|
client.debug.click(buttons.CORNER_BUTTON)
|
|
|
|
client.debug.synchronize_at("VerticalMenu")
|
|
|
|
client.debug.click(buttons.VERTICAL_MENU[1])
|
|
|
|
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = client.debug.read_layout()
|
2024-05-21 21:49:08 +00:00
|
|
|
content += " " + layout.text_content()
|
|
|
|
|
|
|
|
client.debug.click(buttons.CORNER_BUTTON)
|
2023-11-21 12:51:59 +00:00
|
|
|
client.debug.click(buttons.CORNER_BUTTON)
|
2024-05-21 21:49:08 +00:00
|
|
|
|
|
|
|
return content
|
|
|
|
|
|
|
|
|
2023-06-20 15:19:56 +00:00
|
|
|
def sign_tx_go_to_info_tr(
|
|
|
|
client: Client,
|
2023-11-21 12:51:59 +00:00
|
|
|
) -> Generator[None, messages.ButtonRequest, str]:
|
2023-09-14 15:43:08 +00:00
|
|
|
yield # confirm address
|
2023-11-21 12:51:59 +00:00
|
|
|
client.debug.read_layout()
|
2023-09-14 15:43:08 +00:00
|
|
|
client.debug.press_yes() # CONTINUE
|
|
|
|
yield # confirm amount
|
2023-11-21 12:51:59 +00:00
|
|
|
client.debug.read_layout()
|
2023-09-14 15:43:08 +00:00
|
|
|
client.debug.press_yes() # CONFIRM
|
2023-06-20 15:19:56 +00:00
|
|
|
|
|
|
|
screen_texts: list[str] = []
|
|
|
|
|
|
|
|
yield # confirm total
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = client.debug.read_layout()
|
2023-09-07 11:51:26 +00:00
|
|
|
if "multiple accounts" in layout.text_content().lower():
|
|
|
|
client.debug.press_middle()
|
|
|
|
yield
|
|
|
|
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = client.debug.press_right()
|
2023-06-20 15:19:56 +00:00
|
|
|
screen_texts.append(layout.text_content())
|
|
|
|
|
2023-11-21 12:51:59 +00:00
|
|
|
layout = client.debug.press_right()
|
2023-06-20 15:19:56 +00:00
|
|
|
screen_texts.append(layout.text_content())
|
|
|
|
|
|
|
|
client.debug.press_left()
|
|
|
|
client.debug.press_left()
|
|
|
|
|
|
|
|
return "\n".join(screen_texts)
|
|
|
|
|
|
|
|
|
|
|
|
class InputFlowSignTxInformation(InputFlowBase):
|
|
|
|
def __init__(self, client: Client):
|
|
|
|
super().__init__(client)
|
|
|
|
|
2023-08-11 15:57:32 +00:00
|
|
|
def assert_content(self, content: str, title_path: str) -> None:
|
|
|
|
TR.assert_in(content, title_path)
|
|
|
|
assert "Legacy #6" in content
|
|
|
|
TR.assert_in(content, "confirm_total__fee_rate")
|
2023-06-20 15:19:56 +00:00
|
|
|
assert "71.56 sat" in content
|
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def input_flow_tt(self) -> BRGeneratorType:
|
2023-06-20 15:19:56 +00:00
|
|
|
content = yield from sign_tx_go_to_info(self.client)
|
2023-08-11 15:57:32 +00:00
|
|
|
self.assert_content(content, "confirm_total__sending_from_account")
|
2023-06-29 15:26:51 +00:00
|
|
|
self.debug.press_yes()
|
2023-06-20 15:19:56 +00:00
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def input_flow_tr(self) -> BRGeneratorType:
|
2023-06-20 15:19:56 +00:00
|
|
|
content = yield from sign_tx_go_to_info_tr(self.client)
|
2023-08-11 15:57:32 +00:00
|
|
|
print("content", content)
|
|
|
|
self.assert_content(content, "confirm_total__title_sending_from")
|
2023-06-29 15:26:51 +00:00
|
|
|
self.debug.press_yes()
|
2023-06-20 15:19:56 +00:00
|
|
|
|
2024-03-09 21:05:05 +00:00
|
|
|
def input_flow_t3t1(self) -> BRGeneratorType:
|
2024-05-21 21:49:08 +00:00
|
|
|
content = yield from sign_tx_go_to_info_t3t1(self.client)
|
2024-03-09 21:05:05 +00:00
|
|
|
self.assert_content(content, "confirm_total__sending_from_account")
|
2024-05-21 21:49:08 +00:00
|
|
|
self.debug.swipe_up()
|
2024-03-09 21:05:05 +00:00
|
|
|
self.debug.press_yes()
|
|
|
|
|
2023-06-20 15:19:56 +00:00
|
|
|
|
|
|
|
class InputFlowSignTxInformationMixed(InputFlowBase):
|
|
|
|
def __init__(self, client: Client):
|
|
|
|
super().__init__(client)
|
|
|
|
|
2023-08-11 15:57:32 +00:00
|
|
|
def assert_content(self, content: str, title_path: str) -> None:
|
|
|
|
TR.assert_in(content, title_path)
|
|
|
|
TR.assert_in(content, "bitcoin__multiple_accounts")
|
|
|
|
TR.assert_in(content, "confirm_total__fee_rate")
|
2023-06-20 15:19:56 +00:00
|
|
|
assert "18.33 sat" in content
|
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def input_flow_tt(self) -> BRGeneratorType:
|
2023-09-07 11:51:26 +00:00
|
|
|
# multiple accounts warning
|
|
|
|
yield
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
2023-06-20 15:19:56 +00:00
|
|
|
content = yield from sign_tx_go_to_info(self.client)
|
2023-08-11 15:57:32 +00:00
|
|
|
self.assert_content(content, "confirm_total__sending_from_account")
|
2023-06-29 15:26:51 +00:00
|
|
|
self.debug.press_yes()
|
2023-06-20 15:19:56 +00:00
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def input_flow_tr(self) -> BRGeneratorType:
|
2023-08-11 15:57:32 +00:00
|
|
|
# multiple accounts warning
|
|
|
|
yield
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
2023-06-20 15:19:56 +00:00
|
|
|
content = yield from sign_tx_go_to_info_tr(self.client)
|
2023-08-11 15:57:32 +00:00
|
|
|
self.assert_content(content, "confirm_total__title_sending_from")
|
2023-06-29 15:26:51 +00:00
|
|
|
self.debug.press_yes()
|
2023-06-20 15:19:56 +00:00
|
|
|
|
2024-03-09 21:05:05 +00:00
|
|
|
def input_flow_t3t1(self) -> BRGeneratorType:
|
2024-05-21 21:49:08 +00:00
|
|
|
content = yield from sign_tx_go_to_info_t3t1(self.client, multi_account=True)
|
2024-03-09 21:05:05 +00:00
|
|
|
self.assert_content(content, "confirm_total__sending_from_account")
|
2024-05-21 21:49:08 +00:00
|
|
|
self.debug.swipe_up()
|
2024-03-09 21:05:05 +00:00
|
|
|
self.debug.press_yes()
|
|
|
|
|
2023-06-20 15:19:56 +00:00
|
|
|
|
|
|
|
class InputFlowSignTxInformationCancel(InputFlowBase):
|
|
|
|
def __init__(self, client: Client):
|
|
|
|
super().__init__(client)
|
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def input_flow_tt(self) -> BRGeneratorType:
|
2023-06-20 15:19:56 +00:00
|
|
|
yield from sign_tx_go_to_info(self.client)
|
2023-06-29 15:26:51 +00:00
|
|
|
self.debug.press_no()
|
2023-06-20 15:19:56 +00:00
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def input_flow_tr(self) -> BRGeneratorType:
|
2023-06-20 15:19:56 +00:00
|
|
|
yield from sign_tx_go_to_info_tr(self.client)
|
2023-06-29 15:26:51 +00:00
|
|
|
self.debug.press_left()
|
2023-06-20 15:19:56 +00:00
|
|
|
|
2024-03-09 21:05:05 +00:00
|
|
|
def input_flow_t3t1(self) -> BRGeneratorType:
|
2024-05-21 21:49:08 +00:00
|
|
|
yield from sign_tx_go_to_info_t3t1(self.client)
|
|
|
|
self.debug.click(buttons.CORNER_BUTTON)
|
|
|
|
self.debug.click(buttons.VERTICAL_MENU[2])
|
|
|
|
self.debug.synchronize_at("PromptScreen")
|
|
|
|
self.debug.click(buttons.TAP_TO_CONFIRM)
|
2024-03-09 21:05:05 +00:00
|
|
|
|
2023-06-20 15:19:56 +00:00
|
|
|
|
|
|
|
class InputFlowSignTxInformationReplacement(InputFlowBase):
|
|
|
|
def __init__(self, client: Client):
|
|
|
|
super().__init__(client)
|
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def input_flow_tt(self) -> BRGeneratorType:
|
2023-06-20 15:19:56 +00:00
|
|
|
yield # confirm txid
|
2023-06-29 15:26:51 +00:00
|
|
|
self.debug.press_yes()
|
2023-06-20 15:19:56 +00:00
|
|
|
yield # confirm address
|
2023-06-29 15:26:51 +00:00
|
|
|
self.debug.press_yes()
|
2023-06-20 15:19:56 +00:00
|
|
|
# go back to address
|
2023-11-21 12:51:59 +00:00
|
|
|
yield
|
2023-06-29 15:26:51 +00:00
|
|
|
self.debug.press_no()
|
2023-06-20 15:19:56 +00:00
|
|
|
# confirm address
|
2023-06-29 15:26:51 +00:00
|
|
|
self.debug.press_yes()
|
2023-11-21 12:51:59 +00:00
|
|
|
# confirm amount
|
2023-06-29 15:26:51 +00:00
|
|
|
self.debug.press_yes()
|
2023-06-20 15:19:56 +00:00
|
|
|
|
|
|
|
yield # transaction summary, press info
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.click(buttons.CORNER_BUTTON)
|
|
|
|
self.debug.click(buttons.CORNER_BUTTON)
|
2023-07-10 11:47:04 +00:00
|
|
|
self.debug.press_yes()
|
2023-06-20 15:19:56 +00:00
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def input_flow_tr(self) -> BRGeneratorType:
|
2023-06-20 15:19:56 +00:00
|
|
|
yield # confirm txid
|
2023-06-29 15:26:51 +00:00
|
|
|
self.debug.press_right()
|
|
|
|
self.debug.press_right()
|
2023-11-21 15:55:46 +00:00
|
|
|
yield # modify amount - address
|
2023-06-29 15:26:51 +00:00
|
|
|
self.debug.press_right()
|
|
|
|
self.debug.press_right()
|
2023-11-21 15:55:46 +00:00
|
|
|
yield # modify amount - amount
|
2023-06-29 15:26:51 +00:00
|
|
|
self.debug.press_right()
|
2023-11-21 15:55:46 +00:00
|
|
|
yield # modify fee
|
2023-06-29 15:26:51 +00:00
|
|
|
self.debug.press_right()
|
|
|
|
self.debug.press_right()
|
|
|
|
self.debug.press_right()
|
2024-03-09 21:05:05 +00:00
|
|
|
|
2023-11-21 15:55:46 +00:00
|
|
|
input_flow_t3t1 = input_flow_tt
|
2024-03-09 21:05:05 +00:00
|
|
|
|
2023-06-20 15:19:56 +00:00
|
|
|
|
2023-05-04 12:20:24 +00:00
|
|
|
def lock_time_input_flow_tt(
|
|
|
|
debug: DebugLink,
|
2023-08-11 15:57:32 +00:00
|
|
|
layout_assert_func: Callable[[DebugLink, messages.ButtonRequest], None],
|
2023-05-04 12:20:24 +00:00
|
|
|
double_confirm: bool = False,
|
2023-07-21 09:38:28 +00:00
|
|
|
) -> BRGeneratorType:
|
2023-05-04 12:20:24 +00:00
|
|
|
yield # confirm output
|
2023-11-21 12:51:59 +00:00
|
|
|
debug.read_layout()
|
2023-05-04 12:20:24 +00:00
|
|
|
debug.press_yes()
|
|
|
|
yield # confirm output
|
2023-11-21 12:51:59 +00:00
|
|
|
debug.read_layout()
|
2023-05-04 12:20:24 +00:00
|
|
|
debug.press_yes()
|
|
|
|
|
2023-08-11 15:57:32 +00:00
|
|
|
br = yield # confirm locktime
|
|
|
|
layout_assert_func(debug, br)
|
2023-05-04 12:20:24 +00:00
|
|
|
debug.press_yes()
|
|
|
|
|
|
|
|
yield # confirm transaction
|
|
|
|
debug.press_yes()
|
|
|
|
if double_confirm:
|
|
|
|
yield # confirm transaction
|
|
|
|
debug.press_yes()
|
|
|
|
|
|
|
|
|
2023-05-12 09:19:35 +00:00
|
|
|
def lock_time_input_flow_tr(
|
2023-08-11 15:57:32 +00:00
|
|
|
debug: DebugLink,
|
|
|
|
layout_assert_func: Callable[[DebugLink, messages.ButtonRequest], None],
|
2023-07-21 09:38:28 +00:00
|
|
|
) -> BRGeneratorType:
|
2023-09-14 15:43:08 +00:00
|
|
|
yield # confirm address
|
2023-11-21 12:51:59 +00:00
|
|
|
debug.read_layout()
|
2023-09-14 15:43:08 +00:00
|
|
|
debug.press_yes()
|
|
|
|
yield # confirm amount
|
2023-11-21 12:51:59 +00:00
|
|
|
debug.read_layout()
|
2023-05-12 09:19:35 +00:00
|
|
|
debug.press_yes()
|
|
|
|
|
2023-08-11 15:57:32 +00:00
|
|
|
br = yield # confirm locktime
|
|
|
|
layout_assert_func(debug, br)
|
2023-05-12 09:19:35 +00:00
|
|
|
debug.press_yes()
|
|
|
|
|
|
|
|
yield # confirm transaction
|
|
|
|
debug.press_yes()
|
|
|
|
|
|
|
|
|
2024-05-21 21:49:08 +00:00
|
|
|
def lock_time_input_flow_t3t1(
|
|
|
|
debug: DebugLink,
|
|
|
|
layout_assert_func: Callable[[DebugLink, messages.ButtonRequest], None],
|
|
|
|
double_confirm: bool = False,
|
|
|
|
) -> BRGeneratorType:
|
|
|
|
yield # confirm output
|
2023-11-21 12:51:59 +00:00
|
|
|
debug.read_layout()
|
2024-05-21 21:49:08 +00:00
|
|
|
debug.swipe_up()
|
|
|
|
yield # confirm output
|
2023-11-21 12:51:59 +00:00
|
|
|
debug.read_layout()
|
2024-05-21 21:49:08 +00:00
|
|
|
debug.swipe_up()
|
|
|
|
|
|
|
|
br = yield # confirm locktime
|
|
|
|
layout_assert_func(debug, br)
|
|
|
|
debug.press_yes()
|
|
|
|
|
|
|
|
yield # confirm transaction
|
|
|
|
debug.swipe_up()
|
|
|
|
debug.press_yes()
|
|
|
|
if double_confirm:
|
|
|
|
yield # confirm transaction
|
|
|
|
debug.press_yes()
|
|
|
|
|
|
|
|
|
2023-05-04 12:20:24 +00:00
|
|
|
class InputFlowLockTimeBlockHeight(InputFlowBase):
|
|
|
|
def __init__(self, client: Client, block_height: str):
|
|
|
|
super().__init__(client)
|
|
|
|
self.block_height = block_height
|
|
|
|
|
2023-08-11 15:57:32 +00:00
|
|
|
def assert_func(self, debug: DebugLink, br: messages.ButtonRequest) -> None:
|
|
|
|
layout_text = get_text_possible_pagination(debug, br)
|
|
|
|
TR.assert_in(layout_text, "bitcoin__locktime_set_to_blockheight")
|
2023-08-07 11:07:36 +00:00
|
|
|
assert self.block_height in layout_text
|
2023-05-12 09:19:35 +00:00
|
|
|
|
2023-08-07 11:07:36 +00:00
|
|
|
def input_flow_tt(self) -> BRGeneratorType:
|
|
|
|
yield from lock_time_input_flow_tt(
|
|
|
|
self.debug, self.assert_func, double_confirm=True
|
|
|
|
)
|
2023-05-12 09:19:35 +00:00
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def input_flow_tr(self) -> BRGeneratorType:
|
2023-08-07 11:07:36 +00:00
|
|
|
yield from lock_time_input_flow_tr(self.debug, self.assert_func)
|
2023-05-04 12:20:24 +00:00
|
|
|
|
2024-03-09 21:05:05 +00:00
|
|
|
def input_flow_t3t1(self) -> BRGeneratorType:
|
2024-05-21 21:49:08 +00:00
|
|
|
yield from lock_time_input_flow_t3t1(
|
2024-03-09 21:05:05 +00:00
|
|
|
self.debug, self.assert_func, double_confirm=True
|
|
|
|
)
|
|
|
|
|
2023-05-04 12:20:24 +00:00
|
|
|
|
|
|
|
class InputFlowLockTimeDatetime(InputFlowBase):
|
|
|
|
def __init__(self, client: Client, lock_time_str: str):
|
|
|
|
super().__init__(client)
|
|
|
|
self.lock_time_str = lock_time_str
|
|
|
|
|
2023-08-11 15:57:32 +00:00
|
|
|
def assert_func(self, debug: DebugLink, br: messages.ButtonRequest) -> None:
|
|
|
|
layout_text = get_text_possible_pagination(debug, br)
|
|
|
|
TR.assert_in(layout_text, "bitcoin__locktime_set_to")
|
2024-03-30 18:31:47 +00:00
|
|
|
assert self.lock_time_str.replace(" ", "") in layout_text.replace(" ", "")
|
2023-05-12 09:19:35 +00:00
|
|
|
|
2023-08-07 11:07:36 +00:00
|
|
|
def input_flow_tt(self) -> BRGeneratorType:
|
|
|
|
yield from lock_time_input_flow_tt(self.debug, self.assert_func)
|
2023-05-12 09:19:35 +00:00
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def input_flow_tr(self) -> BRGeneratorType:
|
2023-08-07 11:07:36 +00:00
|
|
|
yield from lock_time_input_flow_tr(self.debug, self.assert_func)
|
2023-05-04 12:20:24 +00:00
|
|
|
|
2024-03-09 21:05:05 +00:00
|
|
|
def input_flow_t3t1(self) -> BRGeneratorType:
|
2024-05-21 21:49:08 +00:00
|
|
|
yield from lock_time_input_flow_t3t1(self.debug, self.assert_func)
|
2024-03-09 21:05:05 +00:00
|
|
|
|
2023-05-04 12:20:24 +00:00
|
|
|
|
|
|
|
class InputFlowEIP712ShowMore(InputFlowBase):
|
|
|
|
SHOW_MORE = (143, 167)
|
|
|
|
|
|
|
|
def __init__(self, client: Client):
|
|
|
|
super().__init__(client)
|
|
|
|
self.same_for_all_models = True
|
|
|
|
|
|
|
|
def _confirm_show_more(self) -> None:
|
|
|
|
"""Model-specific, either clicks a screen or presses a button."""
|
2024-09-02 11:01:16 +00:00
|
|
|
if self.client.layout_type in (LayoutType.TT, LayoutType.Mercury):
|
2023-05-12 09:19:35 +00:00
|
|
|
self.debug.click(self.SHOW_MORE)
|
2024-09-02 11:01:16 +00:00
|
|
|
elif self.client.layout_type is LayoutType.TR:
|
2023-05-12 09:19:35 +00:00
|
|
|
self.debug.press_right()
|
2024-09-02 11:01:16 +00:00
|
|
|
else:
|
|
|
|
raise NotImplementedError
|
2023-05-04 12:20:24 +00:00
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def input_flow_common(self) -> BRGeneratorType:
|
2023-05-04 12:20:24 +00:00
|
|
|
"""Triggers show more wherever possible"""
|
|
|
|
yield # confirm address
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
|
|
|
yield # confirm domain
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.read_layout()
|
2023-05-04 12:20:24 +00:00
|
|
|
self._confirm_show_more()
|
|
|
|
|
|
|
|
# confirm domain properties
|
|
|
|
for _ in range(4):
|
|
|
|
yield from swipe_if_necessary(self.debug) # EIP712 DOMAIN
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
|
|
|
yield # confirm message
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.read_layout()
|
2023-05-04 12:20:24 +00:00
|
|
|
self._confirm_show_more()
|
|
|
|
|
|
|
|
yield # confirm message.from
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.read_layout()
|
2023-05-04 12:20:24 +00:00
|
|
|
self._confirm_show_more()
|
|
|
|
|
|
|
|
# confirm message.from properties
|
|
|
|
for _ in range(2):
|
|
|
|
yield from swipe_if_necessary(self.debug)
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
|
|
|
yield # confirm message.to
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.read_layout()
|
2023-05-04 12:20:24 +00:00
|
|
|
self._confirm_show_more()
|
|
|
|
|
|
|
|
# confirm message.to properties
|
|
|
|
for _ in range(2):
|
|
|
|
yield from swipe_if_necessary(self.debug)
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
|
|
|
yield # confirm message.contents
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
|
|
|
yield # confirm final hash
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
|
|
|
|
|
|
|
class InputFlowEIP712Cancel(InputFlowBase):
|
|
|
|
def __init__(self, client: Client):
|
|
|
|
super().__init__(client)
|
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def input_flow_common(self) -> BRGeneratorType:
|
2023-05-04 12:20:24 +00:00
|
|
|
"""Clicks cancelling button"""
|
|
|
|
yield # confirm address
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
|
|
|
yield # confirm domain
|
|
|
|
self.debug.press_no()
|
|
|
|
|
|
|
|
|
2023-08-01 14:54:01 +00:00
|
|
|
class InputFlowEthereumSignTxShowFeeInfo(InputFlowBase):
|
2023-12-05 10:50:13 +00:00
|
|
|
def __init__(self, client: Client):
|
2023-08-01 14:54:01 +00:00
|
|
|
super().__init__(client)
|
|
|
|
|
2023-08-02 10:48:06 +00:00
|
|
|
def input_flow_common(self) -> BRGeneratorType:
|
|
|
|
yield from self.ETH.confirm_tx(info=True)
|
2023-08-01 14:54:01 +00:00
|
|
|
|
|
|
|
|
2023-12-05 10:50:13 +00:00
|
|
|
class InputFlowEthereumSignTxGoBackFromSummary(InputFlowBase):
|
|
|
|
def __init__(self, client: Client):
|
|
|
|
super().__init__(client)
|
|
|
|
|
|
|
|
def input_flow_common(self) -> BRGeneratorType:
|
|
|
|
yield from self.ETH.confirm_tx(go_back_from_summary=True)
|
|
|
|
|
|
|
|
|
2023-08-01 14:54:01 +00:00
|
|
|
class InputFlowEthereumSignTxDataSkip(InputFlowBase):
|
2023-05-04 12:20:24 +00:00
|
|
|
def __init__(self, client: Client, cancel: bool = False):
|
|
|
|
super().__init__(client)
|
|
|
|
self.cancel = cancel
|
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def input_flow_common(self) -> BRGeneratorType:
|
2023-08-02 10:48:06 +00:00
|
|
|
yield from self.ETH.confirm_data()
|
|
|
|
yield from self.ETH.confirm_tx(cancel=self.cancel)
|
2023-05-04 12:20:24 +00:00
|
|
|
|
|
|
|
|
2023-08-01 14:54:01 +00:00
|
|
|
class InputFlowEthereumSignTxDataScrollDown(InputFlowBase):
|
2023-05-04 12:20:24 +00:00
|
|
|
def __init__(self, client: Client, cancel: bool = False):
|
|
|
|
super().__init__(client)
|
|
|
|
self.cancel = cancel
|
|
|
|
|
2023-08-02 10:48:06 +00:00
|
|
|
def input_flow_common(self) -> BRGeneratorType:
|
2024-10-18 10:25:56 +00:00
|
|
|
# this flow will not test for the cancel case,
|
|
|
|
# because once we enter the "view all data",
|
|
|
|
# the only way to cancel is by going back to the 1st page view
|
|
|
|
# but that case would be covered by InputFlowEthereumSignTxDataGoBack
|
|
|
|
assert not self.cancel
|
|
|
|
|
2023-08-02 10:48:06 +00:00
|
|
|
yield from self.ETH.confirm_data(info=True)
|
|
|
|
yield from self.ETH.paginate_data()
|
2024-10-18 10:25:56 +00:00
|
|
|
|
|
|
|
if self.debug.layout_type is LayoutType.TR:
|
|
|
|
self.debug.press_right()
|
2023-05-12 09:19:35 +00:00
|
|
|
else:
|
2024-10-18 10:25:56 +00:00
|
|
|
self.debug.click(buttons.OK)
|
|
|
|
|
|
|
|
yield from self.ETH.confirm_tx()
|
2023-05-12 09:19:35 +00:00
|
|
|
|
2023-05-04 12:20:24 +00:00
|
|
|
|
2023-08-01 14:54:01 +00:00
|
|
|
class InputFlowEthereumSignTxDataGoBack(InputFlowBase):
|
2023-05-04 12:20:24 +00:00
|
|
|
def __init__(self, client: Client, cancel: bool = False):
|
|
|
|
super().__init__(client)
|
|
|
|
self.cancel = cancel
|
|
|
|
|
2023-08-02 10:48:06 +00:00
|
|
|
def input_flow_common(self) -> BRGeneratorType:
|
|
|
|
yield from self.ETH.confirm_data(info=True)
|
|
|
|
yield from self.ETH.paginate_data_go_back()
|
|
|
|
if self.cancel:
|
|
|
|
yield from self.ETH.confirm_data(cancel=True)
|
|
|
|
else:
|
|
|
|
yield from self.ETH.confirm_data()
|
|
|
|
yield from self.ETH.confirm_tx()
|
2023-08-01 14:54:01 +00:00
|
|
|
|
2023-05-04 12:20:24 +00:00
|
|
|
|
2024-02-21 15:03:48 +00:00
|
|
|
class InputFlowEthereumSignTxStaking(InputFlowBase):
|
|
|
|
def __init__(self, client: Client):
|
|
|
|
super().__init__(client)
|
|
|
|
|
|
|
|
def input_flow_common(self) -> BRGeneratorType:
|
|
|
|
yield from self.ETH.confirm_tx_staking(info=True)
|
|
|
|
|
|
|
|
|
2023-05-04 12:20:24 +00:00
|
|
|
def get_mnemonic_and_confirm_success(
|
|
|
|
debug: DebugLink,
|
|
|
|
) -> Generator[None, "messages.ButtonRequest", str]:
|
|
|
|
# mnemonic phrases
|
|
|
|
mnemonic = yield from read_and_confirm_mnemonic(debug)
|
|
|
|
|
2024-06-02 10:47:24 +00:00
|
|
|
is_slip39 = len(mnemonic.split()) in (20, 33)
|
2024-09-02 11:01:16 +00:00
|
|
|
if debug.layout_type in (LayoutType.TT, LayoutType.TR) or is_slip39:
|
2024-06-02 10:47:24 +00:00
|
|
|
br = yield # confirm recovery share check
|
|
|
|
assert br.code == B.Success
|
|
|
|
debug.press_yes()
|
2023-05-04 12:20:24 +00:00
|
|
|
|
|
|
|
br = yield # confirm success
|
|
|
|
assert br.code == B.Success
|
|
|
|
debug.press_yes()
|
|
|
|
|
|
|
|
assert mnemonic is not None
|
|
|
|
return mnemonic
|
|
|
|
|
|
|
|
|
|
|
|
class InputFlowBip39Backup(InputFlowBase):
|
|
|
|
def __init__(self, client: Client):
|
|
|
|
super().__init__(client)
|
|
|
|
self.mnemonic = None
|
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def input_flow_common(self) -> BRGeneratorType:
|
2024-06-04 13:40:42 +00:00
|
|
|
# 1. Backup intro
|
|
|
|
# 2. Backup warning
|
|
|
|
yield from click_through(self.debug, screens=2, code=B.ResetDevice)
|
2023-05-04 12:20:24 +00:00
|
|
|
|
|
|
|
# mnemonic phrases and rest
|
|
|
|
self.mnemonic = yield from get_mnemonic_and_confirm_success(self.debug)
|
|
|
|
|
|
|
|
|
|
|
|
class InputFlowBip39ResetBackup(InputFlowBase):
|
|
|
|
def __init__(self, client: Client):
|
|
|
|
super().__init__(client)
|
|
|
|
self.mnemonic = None
|
|
|
|
|
|
|
|
# NOTE: same as above, just two more YES
|
2024-05-06 22:06:32 +00:00
|
|
|
def input_flow_tt(self) -> BRGeneratorType:
|
2023-05-04 12:20:24 +00:00
|
|
|
# 1. Confirm Reset
|
|
|
|
# 2. Backup your seed
|
2024-06-04 13:40:42 +00:00
|
|
|
# 3. Backup intro
|
|
|
|
# 4. Confirm warning
|
|
|
|
yield from click_through(self.debug, screens=4, code=B.ResetDevice)
|
2023-05-04 12:20:24 +00:00
|
|
|
|
|
|
|
# mnemonic phrases and rest
|
|
|
|
self.mnemonic = yield from get_mnemonic_and_confirm_success(self.debug)
|
|
|
|
|
2024-05-06 22:06:32 +00:00
|
|
|
def input_flow_tr(self) -> BRGeneratorType:
|
|
|
|
# 1. Confirm Reset
|
|
|
|
# 2. Backup your seed
|
2024-06-04 13:40:42 +00:00
|
|
|
# 3. Backup intro
|
|
|
|
# 4. Confirm warning
|
|
|
|
yield from click_through(self.debug, screens=4, code=B.ResetDevice)
|
2024-05-06 22:06:32 +00:00
|
|
|
|
|
|
|
# mnemonic phrases and rest
|
|
|
|
self.mnemonic = yield from get_mnemonic_and_confirm_success(self.debug)
|
|
|
|
|
|
|
|
def input_flow_t3t1(self) -> BRGeneratorType:
|
2024-06-04 13:40:42 +00:00
|
|
|
# 1. Confirm Reset
|
|
|
|
# 2. Wallet created
|
|
|
|
# 3. Backup your seed
|
|
|
|
# 4. Backup intro
|
|
|
|
# 5. Confirm warning
|
2024-06-03 23:24:09 +00:00
|
|
|
yield from click_through(self.debug, screens=5, code=B.ResetDevice)
|
2024-05-06 22:06:32 +00:00
|
|
|
|
|
|
|
# mnemonic phrases and rest
|
|
|
|
self.mnemonic = yield from get_mnemonic_and_confirm_success(self.debug)
|
|
|
|
|
2023-05-04 12:20:24 +00:00
|
|
|
|
|
|
|
class InputFlowBip39ResetPIN(InputFlowBase):
|
|
|
|
def __init__(self, client: Client):
|
|
|
|
super().__init__(client)
|
|
|
|
self.mnemonic = None
|
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def input_flow_common(self) -> BRGeneratorType:
|
2023-05-04 12:20:24 +00:00
|
|
|
br = yield # Confirm Reset
|
|
|
|
assert br.code == B.ResetDevice
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
yield from self.PIN.setup_new_pin("654")
|
2023-05-04 12:20:24 +00:00
|
|
|
|
2024-09-02 11:01:16 +00:00
|
|
|
if self.debug.layout_type is LayoutType.Mercury:
|
2024-05-27 22:19:01 +00:00
|
|
|
br = yield # Wallet created
|
|
|
|
assert br.code == B.ResetDevice
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
2023-05-04 12:20:24 +00:00
|
|
|
br = yield # Backup your seed
|
|
|
|
assert br.code == B.ResetDevice
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
|
|
|
br = yield # Confirm warning
|
|
|
|
assert br.code == B.ResetDevice
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
2024-06-04 13:40:42 +00:00
|
|
|
br = yield # Backup intro
|
|
|
|
assert br.code == B.ResetDevice
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
2023-05-04 12:20:24 +00:00
|
|
|
# mnemonic phrases
|
|
|
|
self.mnemonic = yield from read_and_confirm_mnemonic(self.debug)
|
|
|
|
|
|
|
|
br = yield # confirm recovery seed check
|
|
|
|
assert br.code == B.Success
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
|
|
|
br = yield # confirm success
|
|
|
|
assert br.code == B.Success
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
|
|
|
|
|
|
|
class InputFlowBip39ResetFailedCheck(InputFlowBase):
|
|
|
|
def __init__(self, client: Client):
|
|
|
|
super().__init__(client)
|
|
|
|
self.mnemonic = None
|
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def input_flow_common(self) -> BRGeneratorType:
|
2024-09-02 11:01:16 +00:00
|
|
|
screens = 5 if self.debug.layout_type is LayoutType.Mercury else 4
|
2023-05-04 12:20:24 +00:00
|
|
|
# 1. Confirm Reset
|
2024-06-04 13:40:42 +00:00
|
|
|
# 1a. (T3T1) Walet Creation done
|
|
|
|
# 2. Confirm backup prompt
|
|
|
|
# 3. Backup your seed
|
|
|
|
# 4. Confirm warning
|
2024-05-27 22:19:01 +00:00
|
|
|
yield from click_through(self.debug, screens=screens, code=B.ResetDevice)
|
2023-05-04 12:20:24 +00:00
|
|
|
|
|
|
|
# mnemonic phrases, wrong answer
|
|
|
|
self.mnemonic = yield from read_and_confirm_mnemonic(
|
|
|
|
self.debug, choose_wrong=True
|
|
|
|
)
|
|
|
|
|
|
|
|
br = yield # warning screen
|
|
|
|
assert br.code == B.ResetDevice
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
|
|
|
# mnemonic phrases
|
|
|
|
self.mnemonic = yield from read_and_confirm_mnemonic(self.debug)
|
|
|
|
|
|
|
|
br = yield # confirm recovery seed check
|
|
|
|
assert br.code == B.Success
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
|
|
|
br = yield # confirm success
|
|
|
|
assert br.code == B.Success
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
|
|
|
|
2024-04-11 14:21:17 +00:00
|
|
|
def load_N_shares(
|
2023-05-04 12:20:24 +00:00
|
|
|
debug: DebugLink,
|
2024-04-11 14:21:17 +00:00
|
|
|
n: int,
|
2023-05-04 12:20:24 +00:00
|
|
|
) -> Generator[None, "messages.ButtonRequest", list[str]]:
|
|
|
|
mnemonics: list[str] = []
|
|
|
|
|
2024-04-11 14:21:17 +00:00
|
|
|
for _ in range(n):
|
2023-05-04 12:20:24 +00:00
|
|
|
# Phrase screen
|
|
|
|
mnemonic = yield from read_and_confirm_mnemonic(debug)
|
|
|
|
assert mnemonic is not None
|
|
|
|
mnemonics.append(mnemonic)
|
|
|
|
|
|
|
|
br = yield # Confirm continue to next
|
|
|
|
assert br.code == B.Success
|
|
|
|
debug.press_yes()
|
|
|
|
|
|
|
|
return mnemonics
|
|
|
|
|
|
|
|
|
|
|
|
class InputFlowSlip39BasicBackup(InputFlowBase):
|
2024-06-05 15:41:40 +00:00
|
|
|
def __init__(self, client: Client, click_info: bool, repeated: bool = False):
|
2023-05-04 12:20:24 +00:00
|
|
|
super().__init__(client)
|
|
|
|
self.mnemonics: list[str] = []
|
|
|
|
self.click_info = click_info
|
2024-06-05 15:41:40 +00:00
|
|
|
self.repeated = repeated
|
2023-05-04 12:20:24 +00:00
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def input_flow_tt(self) -> BRGeneratorType:
|
2023-11-21 15:55:46 +00:00
|
|
|
if self.repeated:
|
|
|
|
assert (yield).name == "confirm_repeated_backup"
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
|
|
|
assert (yield).name == "backup_intro"
|
2023-05-04 12:20:24 +00:00
|
|
|
self.debug.press_yes()
|
2023-11-21 15:55:46 +00:00
|
|
|
assert (yield).name == "slip39_checklist"
|
|
|
|
self.debug.press_yes()
|
|
|
|
assert (yield).name == "slip39_shares"
|
2023-05-04 12:20:24 +00:00
|
|
|
if self.click_info:
|
2023-11-21 15:55:46 +00:00
|
|
|
br = yield from click_info_button_tt(self.debug)
|
|
|
|
assert br.name == "slip39_shares"
|
2023-05-04 12:20:24 +00:00
|
|
|
self.debug.press_yes()
|
2023-11-21 15:55:46 +00:00
|
|
|
assert (yield).name == "slip39_checklist"
|
2023-05-04 12:20:24 +00:00
|
|
|
self.debug.press_yes()
|
2023-11-21 15:55:46 +00:00
|
|
|
assert (yield).name == "slip39_threshold"
|
2023-05-04 12:20:24 +00:00
|
|
|
if self.click_info:
|
2023-11-21 15:55:46 +00:00
|
|
|
br = yield from click_info_button_tt(self.debug)
|
|
|
|
assert br.name == "slip39_threshold"
|
2023-05-04 12:20:24 +00:00
|
|
|
self.debug.press_yes()
|
2023-11-21 15:55:46 +00:00
|
|
|
assert (yield).name == "slip39_checklist"
|
2023-05-04 12:20:24 +00:00
|
|
|
self.debug.press_yes()
|
2023-11-21 15:55:46 +00:00
|
|
|
assert (yield).name == "backup_warning"
|
2023-05-04 12:20:24 +00:00
|
|
|
self.debug.press_yes()
|
|
|
|
|
|
|
|
# Mnemonic phrases
|
2024-04-11 14:21:17 +00:00
|
|
|
self.mnemonics = yield from load_N_shares(self.debug, 5)
|
2023-05-04 12:20:24 +00:00
|
|
|
|
|
|
|
br = yield # Confirm backup
|
|
|
|
assert br.code == B.Success
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def input_flow_tr(self) -> BRGeneratorType:
|
2024-06-05 15:41:40 +00:00
|
|
|
if self.repeated:
|
|
|
|
# intro confirmation screen
|
|
|
|
yield
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
2024-06-04 13:40:42 +00:00
|
|
|
yield # 1. Backup intro
|
|
|
|
self.debug.press_yes()
|
|
|
|
yield # 2. Checklist
|
2023-05-12 09:19:35 +00:00
|
|
|
self.debug.press_yes()
|
2024-06-04 13:40:42 +00:00
|
|
|
yield # 2.5 Number of shares info
|
2023-05-12 09:19:35 +00:00
|
|
|
self.debug.press_yes()
|
2024-06-04 13:40:42 +00:00
|
|
|
yield # 3. Number of shares (5)
|
2023-05-12 09:19:35 +00:00
|
|
|
self.debug.input("5")
|
2024-06-04 13:40:42 +00:00
|
|
|
yield # 4. Checklist
|
2023-05-12 09:19:35 +00:00
|
|
|
self.debug.press_yes()
|
2024-06-04 13:40:42 +00:00
|
|
|
yield # 4.5 Threshold info
|
2023-05-12 09:19:35 +00:00
|
|
|
self.debug.press_yes()
|
2024-06-04 13:40:42 +00:00
|
|
|
yield # 5. Threshold (3)
|
2023-05-12 09:19:35 +00:00
|
|
|
self.debug.input("3")
|
2024-06-04 13:40:42 +00:00
|
|
|
yield # 6. Checklist
|
2023-05-12 09:19:35 +00:00
|
|
|
self.debug.press_yes()
|
2024-06-04 13:40:42 +00:00
|
|
|
yield # 7. Confirm show seeds
|
2023-05-12 09:19:35 +00:00
|
|
|
self.debug.press_yes()
|
|
|
|
|
|
|
|
# Mnemonic phrases
|
2024-04-11 14:21:17 +00:00
|
|
|
self.mnemonics = yield from load_N_shares(self.debug, 5)
|
2023-05-12 09:19:35 +00:00
|
|
|
|
|
|
|
br = yield # Confirm backup
|
|
|
|
assert br.code == B.Success
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
2024-03-09 21:05:05 +00:00
|
|
|
def input_flow_t3t1(self) -> BRGeneratorType:
|
2024-06-05 15:41:40 +00:00
|
|
|
if self.repeated:
|
|
|
|
# intro confirmation screen
|
2023-11-21 15:55:46 +00:00
|
|
|
assert (yield).name == "confirm_repeated_backup"
|
2024-06-05 15:41:40 +00:00
|
|
|
self.debug.press_yes()
|
|
|
|
|
2023-11-21 15:55:46 +00:00
|
|
|
assert (yield).name == "backup_intro"
|
2024-06-04 13:40:42 +00:00
|
|
|
self.debug.swipe_up()
|
2023-11-21 15:55:46 +00:00
|
|
|
assert (yield).name == "slip39_checklist"
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.swipe_up()
|
2023-11-21 15:55:46 +00:00
|
|
|
assert (yield).name == "slip39_shares"
|
2024-03-09 21:05:05 +00:00
|
|
|
if self.click_info:
|
2024-05-27 22:19:01 +00:00
|
|
|
click_info_button_mercury(self.debug)
|
|
|
|
self.debug.swipe_up()
|
2023-11-21 15:55:46 +00:00
|
|
|
assert (yield).name == "slip39_checklist"
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.swipe_up()
|
2023-11-21 15:55:46 +00:00
|
|
|
assert (yield).name == "slip39_threshold"
|
2024-03-09 21:05:05 +00:00
|
|
|
if self.click_info:
|
2024-05-27 22:19:01 +00:00
|
|
|
click_info_button_mercury(self.debug)
|
|
|
|
self.debug.swipe_up()
|
2023-11-21 15:55:46 +00:00
|
|
|
assert (yield).name == "slip39_checklist"
|
2024-05-27 22:19:01 +00:00
|
|
|
self.debug.swipe_up()
|
2023-11-21 15:55:46 +00:00
|
|
|
assert (yield).name == "backup_warning"
|
2024-05-27 22:19:01 +00:00
|
|
|
self.debug.swipe_up()
|
2024-03-09 21:05:05 +00:00
|
|
|
|
|
|
|
# Mnemonic phrases
|
2024-04-11 14:21:17 +00:00
|
|
|
self.mnemonics = yield from load_N_shares(self.debug, 5)
|
2024-03-09 21:05:05 +00:00
|
|
|
|
|
|
|
br = yield # Confirm backup
|
|
|
|
assert br.code == B.Success
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
2023-05-04 12:20:24 +00:00
|
|
|
|
|
|
|
class InputFlowSlip39BasicResetRecovery(InputFlowBase):
|
|
|
|
def __init__(self, client: Client):
|
|
|
|
super().__init__(client)
|
|
|
|
self.mnemonics: list[str] = []
|
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def input_flow_tt(self) -> BRGeneratorType:
|
2023-05-04 12:20:24 +00:00
|
|
|
# 1. Confirm Reset
|
|
|
|
# 2. Backup your seed
|
2024-06-04 13:40:42 +00:00
|
|
|
# 3. Backup intro
|
|
|
|
# 4. Confirm warning
|
|
|
|
# 5. shares info
|
|
|
|
# 6. Set & Confirm number of shares
|
|
|
|
# 7. threshold info
|
|
|
|
# 8. Set & confirm threshold value
|
|
|
|
# 9. Confirm show seeds
|
|
|
|
yield from click_through(self.debug, screens=9, code=B.ResetDevice)
|
2023-05-04 12:20:24 +00:00
|
|
|
|
|
|
|
# Mnemonic phrases
|
2024-04-11 14:21:17 +00:00
|
|
|
self.mnemonics = yield from load_N_shares(self.debug, 5)
|
2023-05-04 12:20:24 +00:00
|
|
|
|
|
|
|
br = yield # safety warning
|
|
|
|
assert br.code == B.Success
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def input_flow_tr(self) -> BRGeneratorType:
|
2023-05-12 09:19:35 +00:00
|
|
|
yield # Confirm Reset
|
|
|
|
self.debug.press_yes()
|
|
|
|
yield # Backup your seed
|
|
|
|
self.debug.press_yes()
|
2024-06-04 13:40:42 +00:00
|
|
|
yield # Backup intro
|
|
|
|
self.debug.press_yes()
|
2023-05-12 09:19:35 +00:00
|
|
|
yield # Checklist
|
|
|
|
self.debug.press_yes()
|
|
|
|
yield # Number of shares info
|
|
|
|
self.debug.press_yes()
|
|
|
|
yield # Number of shares (5)
|
|
|
|
self.debug.input("5")
|
|
|
|
yield # Checklist
|
|
|
|
self.debug.press_yes()
|
|
|
|
yield # Threshold info
|
|
|
|
self.debug.press_yes()
|
|
|
|
yield # Threshold (3)
|
|
|
|
self.debug.input("3")
|
|
|
|
yield # Checklist
|
|
|
|
self.debug.press_yes()
|
|
|
|
yield # Confirm show seeds
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
|
|
|
# Mnemonic phrases
|
2024-04-11 14:21:17 +00:00
|
|
|
self.mnemonics = yield from load_N_shares(self.debug, 5)
|
2023-05-12 09:19:35 +00:00
|
|
|
|
|
|
|
br = yield # Confirm backup
|
|
|
|
assert br.code == B.Success
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
2024-03-09 21:05:05 +00:00
|
|
|
def input_flow_t3t1(self) -> BRGeneratorType:
|
|
|
|
# 1. Confirm Reset
|
2024-06-04 13:40:42 +00:00
|
|
|
# 2. Wallet Created
|
|
|
|
# 3. Backup your seed
|
|
|
|
# 4. Backup intro
|
2024-03-09 21:05:05 +00:00
|
|
|
# 5. Set & Confirm number of shares
|
|
|
|
# 6. threshold info
|
|
|
|
# 7. Set & confirm threshold value
|
|
|
|
# 8. Confirm show seeds
|
2024-06-03 12:36:45 +00:00
|
|
|
# 9. Warning
|
|
|
|
# 10. Instructions
|
|
|
|
yield from click_through(self.debug, screens=10, code=B.ResetDevice)
|
2024-03-09 21:05:05 +00:00
|
|
|
|
|
|
|
# Mnemonic phrases
|
2024-04-11 14:21:17 +00:00
|
|
|
self.mnemonics = yield from load_N_shares(self.debug, 5)
|
2024-03-09 21:05:05 +00:00
|
|
|
|
2024-08-02 09:52:45 +00:00
|
|
|
br = yield # success screen
|
2024-03-09 21:05:05 +00:00
|
|
|
assert br.code == B.Success
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
2023-05-04 12:20:24 +00:00
|
|
|
|
2024-04-11 14:21:17 +00:00
|
|
|
class InputFlowSlip39CustomBackup(InputFlowBase):
|
2024-06-05 15:41:40 +00:00
|
|
|
def __init__(self, client: Client, share_count: int, repeated: bool = False):
|
2024-04-11 14:21:17 +00:00
|
|
|
super().__init__(client)
|
|
|
|
self.mnemonics: list[str] = []
|
|
|
|
self.share_count = share_count
|
2024-06-05 15:41:40 +00:00
|
|
|
self.repeated = repeated
|
2024-04-11 14:21:17 +00:00
|
|
|
|
|
|
|
def input_flow_tt(self) -> BRGeneratorType:
|
2024-06-05 15:41:40 +00:00
|
|
|
if self.repeated:
|
|
|
|
yield
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
2024-04-24 16:03:24 +00:00
|
|
|
if self.share_count > 1:
|
|
|
|
yield # Checklist
|
|
|
|
self.debug.press_yes()
|
2024-06-04 13:40:42 +00:00
|
|
|
else:
|
|
|
|
yield # Backup intro
|
|
|
|
self.debug.press_yes()
|
2024-04-24 16:03:24 +00:00
|
|
|
|
2024-04-11 14:21:17 +00:00
|
|
|
yield # Confirm show seeds
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
|
|
|
# Mnemonic phrases
|
|
|
|
self.mnemonics = yield from load_N_shares(self.debug, self.share_count)
|
|
|
|
|
|
|
|
br = yield # Confirm backup
|
|
|
|
assert br.code == B.Success
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
|
|
|
def input_flow_tr(self) -> BRGeneratorType:
|
2024-06-05 15:41:40 +00:00
|
|
|
if self.repeated:
|
|
|
|
yield
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
2024-04-24 16:03:24 +00:00
|
|
|
if self.share_count > 1:
|
|
|
|
yield # Checklist
|
|
|
|
self.debug.press_yes()
|
2024-06-04 13:40:42 +00:00
|
|
|
else:
|
|
|
|
yield # Backup intro
|
|
|
|
self.debug.press_yes()
|
2024-04-24 16:03:24 +00:00
|
|
|
|
2024-04-11 14:21:17 +00:00
|
|
|
yield # Confirm show seeds
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
|
|
|
# Mnemonic phrases
|
|
|
|
self.mnemonics = yield from load_N_shares(self.debug, self.share_count)
|
|
|
|
|
|
|
|
br = yield # Confirm backup
|
|
|
|
assert br.code == B.Success
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
|
|
|
def input_flow_t3t1(self) -> BRGeneratorType:
|
2024-06-05 15:41:40 +00:00
|
|
|
if self.repeated:
|
|
|
|
yield
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
2024-04-24 16:03:24 +00:00
|
|
|
if self.share_count > 1:
|
|
|
|
yield # Checklist
|
|
|
|
self.debug.press_yes()
|
2024-06-04 13:40:42 +00:00
|
|
|
else:
|
|
|
|
yield # Backup intro
|
|
|
|
self.debug.press_yes()
|
2024-04-24 16:03:24 +00:00
|
|
|
|
2024-04-11 14:21:17 +00:00
|
|
|
yield # Confirm show seeds
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
|
|
|
# Mnemonic phrases
|
|
|
|
self.mnemonics = yield from load_N_shares(self.debug, self.share_count)
|
|
|
|
|
|
|
|
br = yield # Confirm backup
|
|
|
|
assert br.code == B.Success
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
|
|
|
|
2023-05-04 12:20:24 +00:00
|
|
|
def load_5_groups_5_shares(
|
|
|
|
debug: DebugLink,
|
|
|
|
) -> Generator[None, "messages.ButtonRequest", list[str]]:
|
|
|
|
mnemonics: list[str] = []
|
|
|
|
|
|
|
|
for _g in range(5):
|
|
|
|
for _s in range(5):
|
|
|
|
# Phrase screen
|
|
|
|
mnemonic = yield from read_and_confirm_mnemonic(debug)
|
|
|
|
assert mnemonic is not None
|
|
|
|
mnemonics.append(mnemonic)
|
|
|
|
# Confirm continue to next
|
|
|
|
yield from swipe_if_necessary(debug, B.Success)
|
|
|
|
debug.press_yes()
|
|
|
|
|
|
|
|
return mnemonics
|
|
|
|
|
|
|
|
|
|
|
|
class InputFlowSlip39AdvancedBackup(InputFlowBase):
|
|
|
|
def __init__(self, client: Client, click_info: bool):
|
|
|
|
super().__init__(client)
|
|
|
|
self.mnemonics: list[str] = []
|
|
|
|
self.click_info = click_info
|
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def input_flow_tt(self) -> BRGeneratorType:
|
2023-11-21 15:55:46 +00:00
|
|
|
assert (yield).name == "backup_intro"
|
2024-06-04 13:40:42 +00:00
|
|
|
self.debug.press_yes()
|
2023-11-21 15:55:46 +00:00
|
|
|
assert (yield).name == "slip39_checklist"
|
2023-05-04 12:20:24 +00:00
|
|
|
self.debug.press_yes()
|
2023-11-21 15:55:46 +00:00
|
|
|
assert (yield).name == "slip39_groups"
|
2023-05-04 12:20:24 +00:00
|
|
|
if self.click_info:
|
2023-11-21 15:55:46 +00:00
|
|
|
br = yield from click_info_button_tt(self.debug)
|
|
|
|
assert br.name == "slip39_groups"
|
2023-05-04 12:20:24 +00:00
|
|
|
self.debug.press_yes()
|
2023-11-21 15:55:46 +00:00
|
|
|
assert (yield).name == "slip39_checklist"
|
2023-05-04 12:20:24 +00:00
|
|
|
self.debug.press_yes()
|
2023-11-21 15:55:46 +00:00
|
|
|
assert (yield).name == "slip39_group_threshold"
|
2023-05-04 12:20:24 +00:00
|
|
|
if self.click_info:
|
2023-11-21 15:55:46 +00:00
|
|
|
br = yield from click_info_button_tt(self.debug)
|
|
|
|
assert br.name == "slip39_group_threshold"
|
2023-05-04 12:20:24 +00:00
|
|
|
self.debug.press_yes()
|
2023-11-21 15:55:46 +00:00
|
|
|
assert (yield).name == "slip39_checklist"
|
2023-05-04 12:20:24 +00:00
|
|
|
self.debug.press_yes()
|
|
|
|
for _ in range(5): # for each of 5 groups
|
2023-11-21 15:55:46 +00:00
|
|
|
assert (yield).name == "slip39_shares"
|
2023-05-04 12:20:24 +00:00
|
|
|
if self.click_info:
|
2023-11-21 15:55:46 +00:00
|
|
|
br = yield from click_info_button_tt(self.debug)
|
|
|
|
assert br.name == "slip39_shares"
|
2023-05-04 12:20:24 +00:00
|
|
|
self.debug.press_yes()
|
2023-11-21 15:55:46 +00:00
|
|
|
assert (yield).name == "slip39_threshold"
|
2023-05-04 12:20:24 +00:00
|
|
|
if self.click_info:
|
2023-11-21 15:55:46 +00:00
|
|
|
br = yield from click_info_button_tt(self.debug)
|
|
|
|
assert br.name == "slip39_threshold"
|
2023-05-04 12:20:24 +00:00
|
|
|
self.debug.press_yes()
|
2023-11-21 15:55:46 +00:00
|
|
|
assert (yield).name == "backup_warning"
|
2023-05-04 12:20:24 +00:00
|
|
|
self.debug.press_yes()
|
|
|
|
|
|
|
|
# Mnemonic phrases - show & confirm shares for all groups
|
|
|
|
self.mnemonics = yield from load_5_groups_5_shares(self.debug)
|
|
|
|
|
|
|
|
br = yield # Confirm backup
|
|
|
|
assert br.code == B.Success
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def input_flow_tr(self) -> BRGeneratorType:
|
2024-06-04 13:40:42 +00:00
|
|
|
yield # 1. Backup intro
|
|
|
|
self.debug.press_yes()
|
|
|
|
yield # 2. Checklist
|
2023-05-12 09:19:35 +00:00
|
|
|
self.debug.press_yes()
|
2024-06-04 13:40:42 +00:00
|
|
|
yield # 3. Set and confirm group count
|
2023-05-12 09:19:35 +00:00
|
|
|
self.debug.input("5")
|
2024-06-04 13:40:42 +00:00
|
|
|
yield # 4. Checklist
|
2023-05-12 09:19:35 +00:00
|
|
|
self.debug.press_yes()
|
2024-06-04 13:40:42 +00:00
|
|
|
yield # 5. Set and confirm group threshold
|
2023-05-12 09:19:35 +00:00
|
|
|
self.debug.input("3")
|
2024-06-04 13:40:42 +00:00
|
|
|
yield # 6. Checklist
|
2023-05-12 09:19:35 +00:00
|
|
|
self.debug.press_yes()
|
|
|
|
for _ in range(5): # for each of 5 groups
|
|
|
|
yield # Number of shares info
|
|
|
|
self.debug.press_yes()
|
|
|
|
yield # Number of shares (5)
|
|
|
|
self.debug.input("5")
|
|
|
|
yield # Threshold info
|
|
|
|
self.debug.press_yes()
|
|
|
|
yield # Threshold (3)
|
|
|
|
self.debug.input("3")
|
|
|
|
yield # Confirm show seeds
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
|
|
|
# Mnemonic phrases - show & confirm shares for all groups
|
|
|
|
self.mnemonics = yield from load_5_groups_5_shares(self.debug)
|
|
|
|
|
|
|
|
br = yield # Confirm backup
|
|
|
|
assert br.code == B.Success
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
2024-03-09 21:05:05 +00:00
|
|
|
def input_flow_t3t1(self) -> BRGeneratorType:
|
2023-11-21 12:51:59 +00:00
|
|
|
assert (yield).name == "backup_intro"
|
2024-06-04 13:40:42 +00:00
|
|
|
self.debug.swipe_up()
|
2023-11-21 12:51:59 +00:00
|
|
|
assert (yield).name == "slip39_checklist"
|
|
|
|
self.debug.swipe_up()
|
|
|
|
assert (yield).name == "slip39_groups"
|
2024-03-09 21:05:05 +00:00
|
|
|
if self.click_info:
|
2024-05-27 22:19:01 +00:00
|
|
|
click_info_button_mercury(self.debug)
|
|
|
|
self.debug.swipe_up()
|
2023-11-21 12:51:59 +00:00
|
|
|
assert (yield).name == "slip39_checklist"
|
|
|
|
self.debug.swipe_up()
|
|
|
|
assert (yield).name == "slip39_group_threshold"
|
2024-03-09 21:05:05 +00:00
|
|
|
if self.click_info:
|
2024-05-27 22:19:01 +00:00
|
|
|
click_info_button_mercury(self.debug)
|
|
|
|
self.debug.swipe_up()
|
2023-11-21 12:51:59 +00:00
|
|
|
assert (yield).name == "slip39_checklist"
|
|
|
|
self.debug.swipe_up()
|
2024-05-27 22:19:01 +00:00
|
|
|
for _i in range(5): # for each of 5 groups
|
2023-11-21 12:51:59 +00:00
|
|
|
assert (yield).name == "slip39_shares"
|
2024-03-09 21:05:05 +00:00
|
|
|
if self.click_info:
|
2024-05-27 22:19:01 +00:00
|
|
|
click_info_button_mercury(self.debug)
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.swipe_up()
|
|
|
|
assert (yield).name == "slip39_threshold"
|
2024-03-09 21:05:05 +00:00
|
|
|
if self.click_info:
|
2024-05-27 22:19:01 +00:00
|
|
|
click_info_button_mercury(self.debug)
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.swipe_up()
|
|
|
|
assert (yield).name == "backup_warning"
|
2024-03-09 21:05:05 +00:00
|
|
|
self.debug.press_yes()
|
|
|
|
|
|
|
|
# Mnemonic phrases - show & confirm shares for all groups
|
|
|
|
self.mnemonics = yield from load_5_groups_5_shares(self.debug)
|
|
|
|
|
|
|
|
br = yield # Confirm backup
|
|
|
|
assert br.code == B.Success
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
2023-05-04 12:20:24 +00:00
|
|
|
|
|
|
|
class InputFlowSlip39AdvancedResetRecovery(InputFlowBase):
|
|
|
|
def __init__(self, client: Client, click_info: bool):
|
|
|
|
super().__init__(client)
|
|
|
|
self.mnemonics: list[str] = []
|
|
|
|
self.click_info = click_info
|
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def input_flow_tt(self) -> BRGeneratorType:
|
2023-05-04 12:20:24 +00:00
|
|
|
# 1. Confirm Reset
|
|
|
|
# 2. Backup your seed
|
2024-06-04 13:40:42 +00:00
|
|
|
# 3. Backup intro
|
|
|
|
# 4. Confirm warning
|
|
|
|
# 5. shares info
|
|
|
|
# 6. Set & Confirm number of groups
|
|
|
|
# 7. threshold info
|
|
|
|
# 8. Set & confirm group threshold value
|
|
|
|
# 9-18: for each of 5 groups:
|
2023-05-04 12:20:24 +00:00
|
|
|
# 1. Set & Confirm number of shares
|
|
|
|
# 2. Set & confirm share threshold value
|
2024-06-04 13:40:42 +00:00
|
|
|
# 19. Confirm show seeds
|
|
|
|
yield from click_through(self.debug, screens=19, code=B.ResetDevice)
|
2023-05-04 12:20:24 +00:00
|
|
|
|
|
|
|
# Mnemonic phrases - show & confirm shares for all groups
|
|
|
|
self.mnemonics = yield from load_5_groups_5_shares(self.debug)
|
|
|
|
|
|
|
|
br = yield # safety warning
|
|
|
|
assert br.code == B.Success
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def input_flow_tr(self) -> BRGeneratorType:
|
2023-05-12 09:19:35 +00:00
|
|
|
yield # Wallet backup
|
|
|
|
self.debug.press_yes()
|
|
|
|
yield # Wallet creation
|
|
|
|
self.debug.press_yes()
|
2024-06-04 13:40:42 +00:00
|
|
|
yield # Backup intro
|
|
|
|
self.debug.press_yes()
|
2023-05-12 09:19:35 +00:00
|
|
|
yield # Checklist
|
|
|
|
self.debug.press_yes()
|
|
|
|
yield # Set and confirm group count
|
|
|
|
self.debug.input("5")
|
|
|
|
yield # Checklist
|
|
|
|
self.debug.press_yes()
|
|
|
|
yield # Set and confirm group threshold
|
|
|
|
self.debug.input("3")
|
|
|
|
yield # Checklist
|
|
|
|
self.debug.press_yes()
|
|
|
|
for _ in range(5): # for each of 5 groups
|
|
|
|
yield # Number of shares info
|
|
|
|
self.debug.press_yes()
|
|
|
|
yield # Number of shares (5)
|
|
|
|
self.debug.input("5")
|
|
|
|
yield # Threshold info
|
|
|
|
self.debug.press_yes()
|
|
|
|
yield # Threshold (3)
|
|
|
|
self.debug.input("3")
|
|
|
|
yield # Confirm show seeds
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
|
|
|
# Mnemonic phrases - show & confirm shares for all groups
|
|
|
|
self.mnemonics = yield from load_5_groups_5_shares(self.debug)
|
|
|
|
|
|
|
|
br = yield # safety warning
|
|
|
|
assert br.code == B.Success
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
2024-03-09 21:05:05 +00:00
|
|
|
def input_flow_t3t1(self) -> BRGeneratorType:
|
|
|
|
# 1. Confirm Reset
|
2024-06-04 13:40:42 +00:00
|
|
|
# 2. Wallet Created
|
|
|
|
# 3. Prompt Backup
|
|
|
|
# 4. Backup intro
|
|
|
|
# 5. Confirm warning
|
|
|
|
# 6. shares info
|
|
|
|
# 7. Set & Confirm number of groups
|
|
|
|
# 8. threshold info
|
|
|
|
# 9. Set & confirm group threshold value
|
|
|
|
# 10-19: for each of 5 groups:
|
2024-03-09 21:05:05 +00:00
|
|
|
# 1. Set & Confirm number of shares
|
|
|
|
# 2. Set & confirm share threshold value
|
2024-06-04 13:40:42 +00:00
|
|
|
# 20. Confirm show seeds
|
|
|
|
yield from click_through(self.debug, screens=20, code=B.ResetDevice)
|
2024-03-09 21:05:05 +00:00
|
|
|
|
|
|
|
# Mnemonic phrases - show & confirm shares for all groups
|
|
|
|
self.mnemonics = yield from load_5_groups_5_shares(self.debug)
|
|
|
|
|
|
|
|
br = yield # safety warning
|
|
|
|
assert br.code == B.Success
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
2023-05-04 12:20:24 +00:00
|
|
|
|
|
|
|
class InputFlowBip39RecoveryDryRun(InputFlowBase):
|
2023-07-21 09:38:28 +00:00
|
|
|
def __init__(self, client: Client, mnemonic: list[str], mismatch: bool = False):
|
2023-05-04 12:20:24 +00:00
|
|
|
super().__init__(client)
|
|
|
|
self.mnemonic = mnemonic
|
2023-07-21 09:38:28 +00:00
|
|
|
self.mismatch = mismatch
|
|
|
|
|
|
|
|
def input_flow_common(self) -> BRGeneratorType:
|
|
|
|
yield from self.REC.confirm_dry_run()
|
|
|
|
yield from self.REC.setup_bip39_recovery(len(self.mnemonic))
|
|
|
|
yield from self.REC.input_mnemonic(self.mnemonic)
|
|
|
|
if self.mismatch:
|
|
|
|
yield from self.REC.warning_bip39_dryrun_mismatch()
|
|
|
|
else:
|
|
|
|
yield from self.REC.success_bip39_dry_run_valid()
|
2023-05-12 09:19:35 +00:00
|
|
|
|
2023-05-04 12:20:24 +00:00
|
|
|
|
|
|
|
class InputFlowBip39RecoveryDryRunInvalid(InputFlowBase):
|
|
|
|
def __init__(self, client: Client):
|
|
|
|
super().__init__(client)
|
2023-07-21 09:38:28 +00:00
|
|
|
self.invalid_mnemonic = ["stick"] * 12
|
2023-05-04 12:20:24 +00:00
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def input_flow_common(self) -> BRGeneratorType:
|
|
|
|
yield from self.REC.confirm_dry_run()
|
|
|
|
yield from self.REC.setup_bip39_recovery(len(self.invalid_mnemonic))
|
|
|
|
yield from self.REC.input_mnemonic(self.invalid_mnemonic)
|
|
|
|
yield from self.REC.warning_invalid_recovery_seed()
|
2023-05-04 12:20:24 +00:00
|
|
|
|
|
|
|
yield
|
2023-07-21 09:12:14 +00:00
|
|
|
self.client.cancel()
|
2023-05-04 12:20:24 +00:00
|
|
|
|
2023-05-12 09:19:35 +00:00
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
class InputFlowBip39Recovery(InputFlowBase):
|
|
|
|
def __init__(self, client: Client, mnemonic: list[str], pin: str | None = None):
|
2023-06-29 15:26:51 +00:00
|
|
|
super().__init__(client)
|
|
|
|
self.mnemonic = mnemonic
|
2023-07-21 09:38:28 +00:00
|
|
|
self.pin = pin
|
2023-05-12 09:19:35 +00:00
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def input_flow_common(self) -> BRGeneratorType:
|
|
|
|
yield from self.REC.confirm_recovery()
|
|
|
|
if self.pin is not None:
|
|
|
|
yield from self.PIN.setup_new_pin(self.pin)
|
|
|
|
yield from self.REC.setup_bip39_recovery(len(self.mnemonic))
|
|
|
|
yield from self.REC.input_mnemonic(self.mnemonic)
|
|
|
|
yield from self.REC.success_wallet_recovered()
|
2023-05-12 09:19:35 +00:00
|
|
|
|
2023-05-04 12:20:24 +00:00
|
|
|
|
|
|
|
class InputFlowSlip39AdvancedRecoveryDryRun(InputFlowBase):
|
2023-07-21 09:38:28 +00:00
|
|
|
def __init__(self, client: Client, shares: list[str], mismatch: bool = False):
|
2023-05-04 12:20:24 +00:00
|
|
|
super().__init__(client)
|
|
|
|
self.shares = shares
|
2023-07-21 09:38:28 +00:00
|
|
|
self.mismatch = mismatch
|
|
|
|
self.word_count = len(shares[0].split(" "))
|
|
|
|
|
|
|
|
def input_flow_common(self) -> BRGeneratorType:
|
|
|
|
yield from self.REC.confirm_dry_run()
|
|
|
|
yield from self.REC.setup_slip39_recovery(self.word_count)
|
|
|
|
yield from self.REC.input_all_slip39_shares(self.shares, has_groups=True)
|
|
|
|
if self.mismatch:
|
|
|
|
yield from self.REC.warning_slip39_dryrun_mismatch()
|
|
|
|
else:
|
|
|
|
yield from self.REC.success_slip39_dryrun_valid()
|
2023-06-29 15:26:51 +00:00
|
|
|
|
|
|
|
|
2023-05-04 12:20:24 +00:00
|
|
|
class InputFlowSlip39AdvancedRecovery(InputFlowBase):
|
|
|
|
def __init__(self, client: Client, shares: list[str], click_info: bool):
|
|
|
|
super().__init__(client)
|
|
|
|
self.shares = shares
|
|
|
|
self.click_info = click_info
|
2023-07-21 09:38:28 +00:00
|
|
|
self.word_count = len(shares[0].split(" "))
|
2023-05-04 12:20:24 +00:00
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def input_flow_common(self) -> BRGeneratorType:
|
|
|
|
yield from self.REC.confirm_recovery()
|
|
|
|
yield from self.REC.setup_slip39_recovery(self.word_count)
|
|
|
|
yield from self.REC.input_all_slip39_shares(
|
|
|
|
self.shares, has_groups=True, click_info=self.click_info
|
2023-05-04 12:20:24 +00:00
|
|
|
)
|
2023-07-21 09:38:28 +00:00
|
|
|
yield from self.REC.success_wallet_recovered()
|
2023-05-04 12:20:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
class InputFlowSlip39AdvancedRecoveryAbort(InputFlowBase):
|
|
|
|
def __init__(self, client: Client):
|
|
|
|
super().__init__(client)
|
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def input_flow_common(self) -> BRGeneratorType:
|
|
|
|
yield from self.REC.confirm_recovery()
|
2024-09-02 11:01:16 +00:00
|
|
|
if self.client.layout_type in (LayoutType.TT, LayoutType.Mercury):
|
2023-07-21 09:38:28 +00:00
|
|
|
yield from self.REC.input_number_of_words(20)
|
|
|
|
yield from self.REC.abort_recovery(True)
|
2023-05-04 12:20:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
class InputFlowSlip39AdvancedRecoveryNoAbort(InputFlowBase):
|
|
|
|
def __init__(self, client: Client, shares: list[str]):
|
|
|
|
super().__init__(client)
|
|
|
|
self.shares = shares
|
2023-07-21 09:38:28 +00:00
|
|
|
self.word_count = len(shares[0].split(" "))
|
2023-05-04 12:20:24 +00:00
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def input_flow_common(self) -> BRGeneratorType:
|
|
|
|
yield from self.REC.confirm_recovery()
|
2024-09-02 11:01:16 +00:00
|
|
|
if self.client.layout_type in (LayoutType.TT, LayoutType.Mercury):
|
2023-07-21 09:38:28 +00:00
|
|
|
yield from self.REC.input_number_of_words(self.word_count)
|
|
|
|
yield from self.REC.abort_recovery(False)
|
|
|
|
else:
|
|
|
|
yield from self.REC.abort_recovery(False)
|
|
|
|
yield from self.REC.tr_recovery_homescreen()
|
|
|
|
yield from self.REC.input_number_of_words(self.word_count)
|
|
|
|
yield from self.REC.enter_any_share()
|
|
|
|
yield from self.REC.input_all_slip39_shares(self.shares, has_groups=True)
|
|
|
|
yield from self.REC.success_wallet_recovered()
|
2023-05-04 12:20:24 +00:00
|
|
|
|
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
class InputFlowSlip39AdvancedRecoveryThresholdReached(InputFlowBase):
|
|
|
|
def __init__(
|
|
|
|
self,
|
|
|
|
client: Client,
|
|
|
|
first_share: list[str],
|
|
|
|
second_share: list[str],
|
|
|
|
):
|
2023-05-04 12:20:24 +00:00
|
|
|
super().__init__(client)
|
|
|
|
self.first_share = first_share
|
|
|
|
self.second_share = second_share
|
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def input_flow_common(self) -> BRGeneratorType:
|
|
|
|
yield from self.REC.confirm_recovery()
|
|
|
|
yield from self.REC.setup_slip39_recovery(len(self.first_share))
|
|
|
|
yield from self.REC.input_mnemonic(self.first_share)
|
|
|
|
yield from self.REC.success_share_group_entered()
|
|
|
|
yield from self.REC.success_more_shares_needed()
|
|
|
|
yield from self.REC.input_mnemonic(self.second_share)
|
|
|
|
yield from self.REC.warning_group_threshold_reached()
|
2023-05-12 09:19:35 +00:00
|
|
|
|
|
|
|
yield
|
|
|
|
self.client.cancel()
|
|
|
|
|
2023-05-04 12:20:24 +00:00
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
class InputFlowSlip39AdvancedRecoveryShareAlreadyEntered(InputFlowBase):
|
|
|
|
def __init__(
|
|
|
|
self,
|
|
|
|
client: Client,
|
|
|
|
first_share: list[str],
|
|
|
|
second_share: list[str],
|
|
|
|
):
|
|
|
|
super().__init__(client)
|
|
|
|
self.first_share = first_share
|
|
|
|
self.second_share = second_share
|
2023-05-04 12:20:24 +00:00
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def input_flow_common(self) -> BRGeneratorType:
|
|
|
|
yield from self.REC.confirm_recovery()
|
|
|
|
yield from self.REC.setup_slip39_recovery(len(self.first_share))
|
|
|
|
yield from self.REC.input_mnemonic(self.first_share)
|
|
|
|
yield from self.REC.success_share_group_entered()
|
|
|
|
yield from self.REC.success_more_shares_needed()
|
|
|
|
yield from self.REC.input_mnemonic(self.second_share)
|
|
|
|
yield from self.REC.warning_share_already_entered()
|
2023-05-04 12:20:24 +00:00
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
yield
|
|
|
|
self.client.cancel()
|
2023-05-04 12:20:24 +00:00
|
|
|
|
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
class InputFlowSlip39BasicRecoveryDryRun(InputFlowBase):
|
2024-04-23 10:26:46 +00:00
|
|
|
def __init__(
|
|
|
|
self,
|
|
|
|
client: Client,
|
|
|
|
shares: list[str],
|
|
|
|
mismatch: bool = False,
|
|
|
|
unlock_repeated_backup=False,
|
|
|
|
):
|
2023-05-04 12:20:24 +00:00
|
|
|
super().__init__(client)
|
|
|
|
self.shares = shares
|
2023-07-21 09:38:28 +00:00
|
|
|
self.mismatch = mismatch
|
2024-04-23 10:26:46 +00:00
|
|
|
self.unlock_repeated_backup = unlock_repeated_backup
|
2023-07-21 09:38:28 +00:00
|
|
|
self.word_count = len(shares[0].split(" "))
|
|
|
|
|
|
|
|
def input_flow_common(self) -> BRGeneratorType:
|
|
|
|
yield from self.REC.confirm_dry_run()
|
2024-04-23 10:26:46 +00:00
|
|
|
if self.unlock_repeated_backup:
|
|
|
|
yield from self.REC.setup_repeated_backup_recovery(self.word_count)
|
|
|
|
else:
|
|
|
|
yield from self.REC.setup_slip39_recovery(self.word_count)
|
2023-07-21 09:38:28 +00:00
|
|
|
yield from self.REC.input_all_slip39_shares(self.shares)
|
|
|
|
if self.mismatch:
|
|
|
|
yield from self.REC.warning_slip39_dryrun_mismatch()
|
2023-11-21 15:55:46 +00:00
|
|
|
elif not self.unlock_repeated_backup:
|
2023-07-21 09:38:28 +00:00
|
|
|
yield from self.REC.success_slip39_dryrun_valid()
|
2023-05-04 12:20:24 +00:00
|
|
|
|
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
class InputFlowSlip39BasicRecovery(InputFlowBase):
|
|
|
|
def __init__(self, client: Client, shares: list[str], pin: str | None = None):
|
2023-05-04 12:20:24 +00:00
|
|
|
super().__init__(client)
|
|
|
|
self.shares = shares
|
|
|
|
self.pin = pin
|
2023-07-21 09:38:28 +00:00
|
|
|
self.word_count = len(shares[0].split(" "))
|
2023-05-04 12:20:24 +00:00
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def input_flow_common(self) -> BRGeneratorType:
|
|
|
|
yield from self.REC.confirm_recovery()
|
|
|
|
if self.pin is not None:
|
|
|
|
yield from self.PIN.setup_new_pin(self.pin)
|
|
|
|
yield from self.REC.setup_slip39_recovery(self.word_count)
|
|
|
|
yield from self.REC.input_all_slip39_shares(self.shares)
|
|
|
|
yield from self.REC.success_wallet_recovered()
|
2023-05-04 12:20:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
class InputFlowSlip39BasicRecoveryAbort(InputFlowBase):
|
|
|
|
def __init__(self, client: Client):
|
|
|
|
super().__init__(client)
|
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def input_flow_common(self) -> BRGeneratorType:
|
|
|
|
yield from self.REC.confirm_recovery()
|
2024-09-02 11:01:16 +00:00
|
|
|
if self.client.layout_type in (LayoutType.TT, LayoutType.Mercury):
|
2023-07-21 09:38:28 +00:00
|
|
|
yield from self.REC.input_number_of_words(20)
|
|
|
|
yield from self.REC.abort_recovery(True)
|
2023-05-04 12:20:24 +00:00
|
|
|
|
|
|
|
|
2024-07-30 14:54:40 +00:00
|
|
|
class InputFlowSlip39BasicRecoveryAbortBetweenShares(InputFlowBase):
|
|
|
|
def __init__(self, client: Client, shares: list[str]):
|
|
|
|
super().__init__(client)
|
|
|
|
self.first_share = shares[0].split(" ")
|
|
|
|
self.word_count = len(self.first_share)
|
|
|
|
|
|
|
|
def input_flow_common(self) -> BRGeneratorType:
|
|
|
|
yield from self.REC.confirm_recovery()
|
2024-09-02 11:01:16 +00:00
|
|
|
if self.client.layout_type in (LayoutType.TT, LayoutType.Mercury):
|
2024-07-30 14:54:40 +00:00
|
|
|
yield from self.REC.input_number_of_words(20)
|
|
|
|
else:
|
|
|
|
yield from self.REC.tr_recovery_homescreen()
|
|
|
|
yield from self.REC.input_number_of_words(self.word_count)
|
|
|
|
|
|
|
|
yield from self.REC.enter_any_share()
|
|
|
|
yield from self.REC.input_mnemonic(self.first_share)
|
|
|
|
yield from self.REC.abort_recovery_between_shares()
|
|
|
|
|
|
|
|
|
2023-05-04 12:20:24 +00:00
|
|
|
class InputFlowSlip39BasicRecoveryNoAbort(InputFlowBase):
|
|
|
|
def __init__(self, client: Client, shares: list[str]):
|
|
|
|
super().__init__(client)
|
|
|
|
self.shares = shares
|
2023-07-21 09:38:28 +00:00
|
|
|
self.word_count = len(shares[0].split(" "))
|
2023-05-04 12:20:24 +00:00
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def input_flow_common(self) -> BRGeneratorType:
|
|
|
|
yield from self.REC.confirm_recovery()
|
2023-05-04 12:20:24 +00:00
|
|
|
|
2024-09-02 11:01:16 +00:00
|
|
|
if self.client.layout_type in (LayoutType.TT, LayoutType.Mercury):
|
2023-07-21 09:38:28 +00:00
|
|
|
yield from self.REC.input_number_of_words(self.word_count)
|
|
|
|
yield from self.REC.abort_recovery(False)
|
|
|
|
else:
|
|
|
|
yield from self.REC.abort_recovery(False)
|
|
|
|
yield from self.REC.tr_recovery_homescreen()
|
|
|
|
yield from self.REC.input_number_of_words(self.word_count)
|
2023-05-04 12:20:24 +00:00
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
yield from self.REC.enter_any_share()
|
|
|
|
yield from self.REC.input_all_slip39_shares(self.shares)
|
|
|
|
yield from self.REC.success_wallet_recovered()
|
2023-05-04 12:20:24 +00:00
|
|
|
|
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
class InputFlowSlip39BasicRecoveryInvalidFirstShare(InputFlowBase):
|
2023-05-04 12:20:24 +00:00
|
|
|
def __init__(self, client: Client):
|
|
|
|
super().__init__(client)
|
2023-07-21 09:38:28 +00:00
|
|
|
self.first_invalid = ["slush"] * 20
|
|
|
|
self.second_invalid = ["slush"] * 33
|
|
|
|
|
|
|
|
def input_flow_common(self) -> BRGeneratorType:
|
|
|
|
yield from self.REC.confirm_recovery()
|
|
|
|
yield from self.REC.setup_slip39_recovery(len(self.first_invalid))
|
|
|
|
yield from self.REC.input_mnemonic(self.first_invalid)
|
|
|
|
yield from self.REC.warning_invalid_recovery_share()
|
|
|
|
yield from self.REC.setup_slip39_recovery(len(self.second_invalid))
|
|
|
|
yield from self.REC.input_mnemonic(self.second_invalid)
|
|
|
|
yield from self.REC.warning_invalid_recovery_share()
|
2023-05-04 12:20:24 +00:00
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
yield
|
|
|
|
self.client.cancel()
|
2023-05-12 09:19:35 +00:00
|
|
|
|
2023-05-04 12:20:24 +00:00
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
class InputFlowSlip39BasicRecoveryInvalidSecondShare(InputFlowBase):
|
2023-05-04 12:20:24 +00:00
|
|
|
def __init__(self, client: Client, shares: list[str]):
|
|
|
|
super().__init__(client)
|
|
|
|
self.shares = shares
|
2023-07-21 09:38:28 +00:00
|
|
|
self.first_share = shares[0].split(" ")
|
|
|
|
self.invalid_share = self.first_share[:3] + ["slush"] * 17
|
|
|
|
self.second_share = shares[1].split(" ")
|
|
|
|
|
|
|
|
def input_flow_common(self) -> BRGeneratorType:
|
|
|
|
yield from self.REC.confirm_recovery()
|
|
|
|
yield from self.REC.setup_slip39_recovery(len(self.first_share))
|
|
|
|
yield from self.REC.input_mnemonic(self.first_share)
|
|
|
|
yield from self.REC.success_more_shares_needed(2)
|
|
|
|
yield from self.REC.input_mnemonic(self.invalid_share)
|
|
|
|
yield from self.REC.warning_invalid_recovery_share()
|
|
|
|
yield from self.REC.input_mnemonic(self.second_share)
|
|
|
|
yield from self.REC.success_more_shares_needed(1)
|
2023-05-04 12:20:24 +00:00
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
yield
|
2023-07-21 09:12:14 +00:00
|
|
|
self.client.cancel()
|
2023-05-12 09:19:35 +00:00
|
|
|
|
2023-05-04 12:20:24 +00:00
|
|
|
|
|
|
|
class InputFlowSlip39BasicRecoveryWrongNthWord(InputFlowBase):
|
|
|
|
def __init__(self, client: Client, share: list[str], nth_word: int):
|
|
|
|
super().__init__(client)
|
|
|
|
self.share = share
|
|
|
|
self.nth_word = nth_word
|
2023-07-21 09:38:28 +00:00
|
|
|
# Invalid share - just enough words to trigger the warning
|
|
|
|
self.modified_share = share[:nth_word] + [self.share[-1]]
|
2023-05-04 12:20:24 +00:00
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def input_flow_common(self) -> BRGeneratorType:
|
|
|
|
yield from self.REC.confirm_recovery()
|
|
|
|
yield from self.REC.setup_slip39_recovery(len(self.share))
|
|
|
|
yield from self.REC.input_mnemonic(self.share)
|
|
|
|
yield from self.REC.success_more_shares_needed()
|
|
|
|
yield from self.REC.input_mnemonic(self.modified_share)
|
|
|
|
yield from self.REC.warning_share_from_another_shamir()
|
2023-05-12 09:19:35 +00:00
|
|
|
|
2023-07-21 09:12:14 +00:00
|
|
|
yield
|
2023-05-12 09:19:35 +00:00
|
|
|
self.client.cancel()
|
|
|
|
|
2023-05-04 12:20:24 +00:00
|
|
|
|
|
|
|
class InputFlowSlip39BasicRecoverySameShare(InputFlowBase):
|
2023-07-21 09:38:28 +00:00
|
|
|
def __init__(self, client: Client, share: list[str]):
|
2023-05-04 12:20:24 +00:00
|
|
|
super().__init__(client)
|
2023-07-21 09:38:28 +00:00
|
|
|
self.share = share
|
|
|
|
# Second duplicate share - only 4 words are needed to verify it
|
|
|
|
self.duplicate_share = self.share[:4]
|
2023-05-04 12:20:24 +00:00
|
|
|
|
2023-07-21 09:38:28 +00:00
|
|
|
def input_flow_common(self) -> BRGeneratorType:
|
|
|
|
yield from self.REC.confirm_recovery()
|
|
|
|
yield from self.REC.setup_slip39_recovery(len(self.share))
|
|
|
|
yield from self.REC.input_mnemonic(self.share)
|
|
|
|
yield from self.REC.success_more_shares_needed()
|
|
|
|
yield from self.REC.input_mnemonic(self.duplicate_share)
|
|
|
|
yield from self.REC.warning_share_already_entered()
|
2023-05-12 09:19:35 +00:00
|
|
|
|
|
|
|
yield
|
|
|
|
self.client.cancel()
|
|
|
|
|
2023-05-04 12:20:24 +00:00
|
|
|
|
|
|
|
class InputFlowResetSkipBackup(InputFlowBase):
|
|
|
|
def __init__(self, client: Client):
|
|
|
|
super().__init__(client)
|
|
|
|
|
2024-05-27 22:19:01 +00:00
|
|
|
def input_flow_tt(self) -> BRGeneratorType:
|
2023-07-21 09:38:28 +00:00
|
|
|
yield from self.BAK.confirm_new_wallet()
|
2023-05-12 09:19:35 +00:00
|
|
|
yield # Skip Backup
|
2024-05-27 22:19:01 +00:00
|
|
|
TR.assert_in(self.text_content(), "backup__new_wallet_successfully_created")
|
|
|
|
self.debug.press_no()
|
|
|
|
yield # Confirm skip backup
|
|
|
|
TR.assert_in(self.text_content(), "backup__want_to_skip")
|
|
|
|
self.debug.press_no()
|
|
|
|
|
|
|
|
def input_flow_tr(self) -> BRGeneratorType:
|
|
|
|
yield from self.BAK.confirm_new_wallet()
|
|
|
|
yield # Skip Backup
|
|
|
|
TR.assert_in(self.text_content(), "backup__new_wallet_created")
|
|
|
|
self.debug.press_right()
|
2023-05-12 09:19:35 +00:00
|
|
|
self.debug.press_no()
|
2023-07-11 15:25:44 +00:00
|
|
|
yield # Confirm skip backup
|
2023-08-11 15:57:32 +00:00
|
|
|
TR.assert_in(self.text_content(), "backup__want_to_skip")
|
2023-07-11 15:25:44 +00:00
|
|
|
self.debug.press_no()
|
2024-05-21 21:49:08 +00:00
|
|
|
|
2024-05-27 22:19:01 +00:00
|
|
|
def input_flow_t3t1(self) -> BRGeneratorType:
|
|
|
|
yield from self.BAK.confirm_new_wallet()
|
|
|
|
yield # Skip Backup
|
|
|
|
TR.assert_in(self.text_content(), "backup__new_wallet_created")
|
|
|
|
self.debug.swipe_up()
|
|
|
|
yield
|
|
|
|
self.debug.click(buttons.CORNER_BUTTON)
|
|
|
|
self.debug.synchronize_at("VerticalMenu")
|
|
|
|
self.debug.click(buttons.VERTICAL_MENU[0])
|
|
|
|
self.debug.swipe_up()
|
|
|
|
self.debug.synchronize_at("PromptScreen")
|
|
|
|
self.debug.click(buttons.TAP_TO_CONFIRM)
|
|
|
|
|
2024-05-21 21:49:08 +00:00
|
|
|
|
|
|
|
class InputFlowConfirmAllWarnings(InputFlowBase):
|
|
|
|
def __init__(self, client: Client):
|
|
|
|
super().__init__(client)
|
|
|
|
|
|
|
|
def input_flow_tt(self) -> BRGeneratorType:
|
|
|
|
br = yield
|
|
|
|
while True:
|
|
|
|
# wait for homescreen to go away
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.read_layout()
|
2024-05-21 21:49:08 +00:00
|
|
|
self.client.ui._default_input_flow(br)
|
|
|
|
br = yield
|
|
|
|
|
|
|
|
def input_flow_tr(self) -> BRGeneratorType:
|
|
|
|
return self.input_flow_tt()
|
|
|
|
|
|
|
|
def input_flow_t3t1(self) -> BRGeneratorType:
|
|
|
|
br = yield
|
|
|
|
while True:
|
|
|
|
# wait for homescreen to go away
|
|
|
|
# probably won't be needed after https://github.com/trezor/trezor-firmware/pull/3686
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.read_layout()
|
2024-05-21 21:49:08 +00:00
|
|
|
# Paginating (going as further as possible) and pressing Yes
|
|
|
|
if br.pages is not None:
|
|
|
|
for _ in range(br.pages - 1):
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.swipe_up()
|
2024-05-21 21:49:08 +00:00
|
|
|
layout = self.debug.read_layout()
|
|
|
|
text = layout.text_content().lower()
|
|
|
|
# hi priority warning
|
2024-05-27 22:19:01 +00:00
|
|
|
hi_prio = (
|
2024-10-18 10:25:56 +00:00
|
|
|
TR.translate("ethereum__unknown_contract_address")
|
|
|
|
+ TR.translate("addr_mismatch__wrong_derivation_path")
|
2024-05-27 22:19:01 +00:00
|
|
|
+ TR.translate("send__receiving_to_multisig")
|
|
|
|
+ [
|
|
|
|
"witness path",
|
|
|
|
"certificate path",
|
|
|
|
"pool owner staking path",
|
|
|
|
]
|
|
|
|
)
|
|
|
|
if any(needle.lower() in text for needle in hi_prio):
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.click(buttons.CORNER_BUTTON)
|
2024-05-21 21:49:08 +00:00
|
|
|
self.debug.synchronize_at("VerticalMenu")
|
|
|
|
self.debug.click(buttons.VERTICAL_MENU[1])
|
2024-06-05 23:24:10 +00:00
|
|
|
elif "PromptScreen" in layout.all_components():
|
|
|
|
self.debug.press_yes()
|
|
|
|
elif "SwipeContent" in layout.all_components():
|
2024-05-21 21:49:08 +00:00
|
|
|
self.debug.swipe_up()
|
|
|
|
else:
|
|
|
|
self.debug.press_yes()
|
|
|
|
br = yield
|
2024-07-08 23:41:29 +00:00
|
|
|
|
|
|
|
|
2024-07-29 22:12:28 +00:00
|
|
|
class InputFlowFidoConfirm(InputFlowBase):
|
|
|
|
def __init__(self, client: Client, cancel: bool = False):
|
|
|
|
super().__init__(client)
|
|
|
|
self.cancel = cancel
|
|
|
|
|
|
|
|
def input_flow_tt(self) -> BRGeneratorType:
|
|
|
|
while True:
|
|
|
|
yield
|
|
|
|
self.debug.press_yes()
|
|
|
|
|
|
|
|
def input_flow_tr(self) -> BRGeneratorType:
|
|
|
|
yield from self.input_flow_tt()
|
|
|
|
|
|
|
|
def input_flow_t3t1(self) -> BRGeneratorType:
|
|
|
|
while True:
|
|
|
|
yield
|
2023-11-21 12:51:59 +00:00
|
|
|
self.debug.swipe_up()
|
|
|
|
self.debug.click(buttons.TAP_TO_CONFIRM)
|