|
|
|
@ -1,8 +1,8 @@
|
|
|
|
|
from typing import TYPE_CHECKING
|
|
|
|
|
from ubinascii import hexlify
|
|
|
|
|
|
|
|
|
|
from trezor import io, log, loop, ui, wire, workflow
|
|
|
|
|
from trezor import io, log, loop, ui
|
|
|
|
|
from trezor.enums import ButtonRequestType
|
|
|
|
|
from trezor.wire import ActionCancelled
|
|
|
|
|
|
|
|
|
|
import trezorui2
|
|
|
|
|
|
|
|
|
@ -11,11 +11,18 @@ from ..common import button_request, interact
|
|
|
|
|
if TYPE_CHECKING:
|
|
|
|
|
from typing import Any, Awaitable, Iterable, NoReturn, Sequence, TypeVar
|
|
|
|
|
|
|
|
|
|
from trezor.wire import GenericContext, Context
|
|
|
|
|
from ..common import PropertyType, ExceptionType
|
|
|
|
|
|
|
|
|
|
T = TypeVar("T")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CONFIRMED = trezorui2.CONFIRMED # global_import_cache
|
|
|
|
|
CANCELLED = trezorui2.CANCELLED # global_import_cache
|
|
|
|
|
INFO = trezorui2.INFO # global_import_cache
|
|
|
|
|
BR_TYPE_OTHER = ButtonRequestType.Other # global_import_cache
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class _RustLayout(ui.Layout):
|
|
|
|
|
# pylint: disable=super-init-not-called
|
|
|
|
|
def __init__(self, layout: Any, is_backup: bool = False):
|
|
|
|
@ -132,6 +139,8 @@ class _RustLayout(ui.Layout):
|
|
|
|
|
ui.backlight_fade(self.BACKLIGHT_LEVEL)
|
|
|
|
|
|
|
|
|
|
def handle_input_and_rendering(self) -> loop.Task: # type: ignore [awaitable-is-generator]
|
|
|
|
|
from trezor import workflow
|
|
|
|
|
|
|
|
|
|
touch = loop.wait(io.TOUCH)
|
|
|
|
|
self._before_render()
|
|
|
|
|
# self.layout.bounds()
|
|
|
|
@ -160,7 +169,7 @@ class _RustLayout(ui.Layout):
|
|
|
|
|
return self.layout.page_count()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def raise_if_not_confirmed(a: Awaitable[T], exc: Any = wire.ActionCancelled) -> T:
|
|
|
|
|
async def raise_if_not_confirmed(a: Awaitable[T], exc: Any = ActionCancelled) -> T:
|
|
|
|
|
result = await a
|
|
|
|
|
if result is not trezorui2.CONFIRMED:
|
|
|
|
|
raise exc
|
|
|
|
@ -168,7 +177,7 @@ async def raise_if_not_confirmed(a: Awaitable[T], exc: Any = wire.ActionCancelle
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def confirm_action(
|
|
|
|
|
ctx: wire.GenericContext,
|
|
|
|
|
ctx: GenericContext,
|
|
|
|
|
br_type: str,
|
|
|
|
|
title: str,
|
|
|
|
|
action: str | None = None,
|
|
|
|
@ -183,8 +192,8 @@ async def confirm_action(
|
|
|
|
|
icon_color: int | None = None,
|
|
|
|
|
reverse: bool = False,
|
|
|
|
|
larger_vspace: bool = False,
|
|
|
|
|
exc: ExceptionType = wire.ActionCancelled,
|
|
|
|
|
br_code: ButtonRequestType = ButtonRequestType.Other,
|
|
|
|
|
exc: ExceptionType = ActionCancelled,
|
|
|
|
|
br_code: ButtonRequestType = BR_TYPE_OTHER,
|
|
|
|
|
) -> None:
|
|
|
|
|
if isinstance(verb, bytes) or isinstance(verb_cancel, bytes):
|
|
|
|
|
raise NotImplementedError
|
|
|
|
@ -220,7 +229,7 @@ async def confirm_action(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def confirm_reset_device(
|
|
|
|
|
ctx: wire.GenericContext, prompt: str, recovery: bool = False
|
|
|
|
|
ctx: GenericContext, prompt: str, recovery: bool = False
|
|
|
|
|
) -> None:
|
|
|
|
|
if recovery:
|
|
|
|
|
title = "RECOVERY MODE"
|
|
|
|
@ -245,7 +254,7 @@ async def confirm_reset_device(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# TODO cleanup @ redesign
|
|
|
|
|
async def confirm_backup(ctx: wire.GenericContext) -> bool:
|
|
|
|
|
async def confirm_backup(ctx: GenericContext) -> bool:
|
|
|
|
|
result = await interact(
|
|
|
|
|
ctx,
|
|
|
|
|
_RustLayout(
|
|
|
|
@ -260,7 +269,7 @@ async def confirm_backup(ctx: wire.GenericContext) -> bool:
|
|
|
|
|
"backup_device",
|
|
|
|
|
ButtonRequestType.ResetDevice,
|
|
|
|
|
)
|
|
|
|
|
if result is trezorui2.CONFIRMED:
|
|
|
|
|
if result is CONFIRMED:
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
result = await interact(
|
|
|
|
@ -277,11 +286,11 @@ async def confirm_backup(ctx: wire.GenericContext) -> bool:
|
|
|
|
|
"backup_device",
|
|
|
|
|
ButtonRequestType.ResetDevice,
|
|
|
|
|
)
|
|
|
|
|
return result is trezorui2.CONFIRMED
|
|
|
|
|
return result is CONFIRMED
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def confirm_path_warning(
|
|
|
|
|
ctx: wire.GenericContext, path: str, path_type: str = "Path"
|
|
|
|
|
ctx: GenericContext, path: str, path_type: str = "Path"
|
|
|
|
|
) -> None:
|
|
|
|
|
await raise_if_not_confirmed(
|
|
|
|
|
interact(
|
|
|
|
@ -309,9 +318,7 @@ def _show_xpub(xpub: str, title: str, cancel: str) -> ui.Layout:
|
|
|
|
|
return content
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def show_xpub(
|
|
|
|
|
ctx: wire.GenericContext, xpub: str, title: str, cancel: str
|
|
|
|
|
) -> None:
|
|
|
|
|
async def show_xpub(ctx: GenericContext, xpub: str, title: str, cancel: str) -> None:
|
|
|
|
|
await raise_if_not_confirmed(
|
|
|
|
|
interact(
|
|
|
|
|
ctx,
|
|
|
|
@ -323,7 +330,7 @@ async def show_xpub(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def show_address(
|
|
|
|
|
ctx: wire.GenericContext,
|
|
|
|
|
ctx: GenericContext,
|
|
|
|
|
address: str,
|
|
|
|
|
*,
|
|
|
|
|
address_qr: str | None = None,
|
|
|
|
@ -351,7 +358,7 @@ async def show_address(
|
|
|
|
|
"show_address",
|
|
|
|
|
ButtonRequestType.Address,
|
|
|
|
|
)
|
|
|
|
|
if result is trezorui2.CONFIRMED:
|
|
|
|
|
if result is CONFIRMED:
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
result = await interact(
|
|
|
|
@ -367,7 +374,7 @@ async def show_address(
|
|
|
|
|
"show_qr",
|
|
|
|
|
ButtonRequestType.Address,
|
|
|
|
|
)
|
|
|
|
|
if result is trezorui2.CONFIRMED:
|
|
|
|
|
if result is CONFIRMED:
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
if is_multisig:
|
|
|
|
@ -381,12 +388,12 @@ async def show_address(
|
|
|
|
|
"show_xpub",
|
|
|
|
|
ButtonRequestType.PublicKey,
|
|
|
|
|
)
|
|
|
|
|
if result is trezorui2.CONFIRMED:
|
|
|
|
|
if result is CONFIRMED:
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def show_pubkey(
|
|
|
|
|
ctx: wire.Context, pubkey: str, title: str = "Confirm public key"
|
|
|
|
|
ctx: Context, pubkey: str, title: str = "Confirm public key"
|
|
|
|
|
) -> Awaitable[None]:
|
|
|
|
|
return confirm_blob(
|
|
|
|
|
ctx,
|
|
|
|
@ -399,14 +406,14 @@ def show_pubkey(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def show_error_and_raise(
|
|
|
|
|
ctx: wire.GenericContext,
|
|
|
|
|
ctx: GenericContext,
|
|
|
|
|
br_type: str,
|
|
|
|
|
content: str,
|
|
|
|
|
header: str = "Error",
|
|
|
|
|
subheader: str | None = None,
|
|
|
|
|
button: str = "CLOSE",
|
|
|
|
|
red: bool = False,
|
|
|
|
|
exc: ExceptionType = wire.ActionCancelled,
|
|
|
|
|
exc: ExceptionType = ActionCancelled,
|
|
|
|
|
) -> NoReturn:
|
|
|
|
|
await interact(
|
|
|
|
|
ctx,
|
|
|
|
@ -419,13 +426,13 @@ async def show_error_and_raise(
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
br_type,
|
|
|
|
|
ButtonRequestType.Other,
|
|
|
|
|
BR_TYPE_OTHER,
|
|
|
|
|
)
|
|
|
|
|
raise exc
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def show_warning(
|
|
|
|
|
ctx: wire.GenericContext,
|
|
|
|
|
ctx: GenericContext,
|
|
|
|
|
br_type: str,
|
|
|
|
|
content: str,
|
|
|
|
|
header: str = "Warning",
|
|
|
|
@ -453,7 +460,7 @@ async def show_warning(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def show_success(
|
|
|
|
|
ctx: wire.GenericContext,
|
|
|
|
|
ctx: GenericContext,
|
|
|
|
|
br_type: str,
|
|
|
|
|
content: str,
|
|
|
|
|
subheader: str | None = None,
|
|
|
|
@ -477,7 +484,7 @@ async def show_success(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def confirm_output(
|
|
|
|
|
ctx: wire.GenericContext,
|
|
|
|
|
ctx: GenericContext,
|
|
|
|
|
address: str,
|
|
|
|
|
amount: str,
|
|
|
|
|
font_amount: int = ui.NORMAL, # TODO cleanup @ redesign
|
|
|
|
@ -517,7 +524,7 @@ async def confirm_output(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def confirm_payment_request(
|
|
|
|
|
ctx: wire.GenericContext,
|
|
|
|
|
ctx: GenericContext,
|
|
|
|
|
recipient_name: str,
|
|
|
|
|
amount: str,
|
|
|
|
|
memos: list[str],
|
|
|
|
@ -537,21 +544,21 @@ async def confirm_payment_request(
|
|
|
|
|
"confirm_payment_request",
|
|
|
|
|
ButtonRequestType.ConfirmOutput,
|
|
|
|
|
)
|
|
|
|
|
if result is trezorui2.CONFIRMED:
|
|
|
|
|
if result is CONFIRMED:
|
|
|
|
|
return confirm.CONFIRMED
|
|
|
|
|
elif result is trezorui2.INFO:
|
|
|
|
|
elif result is INFO:
|
|
|
|
|
return confirm.INFO
|
|
|
|
|
else:
|
|
|
|
|
raise wire.ActionCancelled
|
|
|
|
|
raise ActionCancelled
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def should_show_more(
|
|
|
|
|
ctx: wire.GenericContext,
|
|
|
|
|
ctx: GenericContext,
|
|
|
|
|
title: str,
|
|
|
|
|
para: Iterable[tuple[int, str]],
|
|
|
|
|
button_text: str = "Show all",
|
|
|
|
|
br_type: str = "should_show_more",
|
|
|
|
|
br_code: ButtonRequestType = ButtonRequestType.Other,
|
|
|
|
|
br_code: ButtonRequestType = BR_TYPE_OTHER,
|
|
|
|
|
icon: str = ui.ICON_DEFAULT,
|
|
|
|
|
icon_color: int = ui.ORANGE_ICON,
|
|
|
|
|
confirm: str | bytes | None = None,
|
|
|
|
@ -583,27 +590,29 @@ async def should_show_more(
|
|
|
|
|
br_code,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if result is trezorui2.CONFIRMED:
|
|
|
|
|
if result is CONFIRMED:
|
|
|
|
|
return False
|
|
|
|
|
elif result is trezorui2.INFO:
|
|
|
|
|
elif result is INFO:
|
|
|
|
|
return True
|
|
|
|
|
else:
|
|
|
|
|
assert result is trezorui2.CANCELLED
|
|
|
|
|
raise wire.ActionCancelled
|
|
|
|
|
assert result is CANCELLED
|
|
|
|
|
raise ActionCancelled
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def confirm_blob(
|
|
|
|
|
ctx: wire.GenericContext,
|
|
|
|
|
ctx: GenericContext,
|
|
|
|
|
br_type: str,
|
|
|
|
|
title: str,
|
|
|
|
|
data: bytes | str,
|
|
|
|
|
description: str | None = None,
|
|
|
|
|
hold: bool = False,
|
|
|
|
|
br_code: ButtonRequestType = ButtonRequestType.Other,
|
|
|
|
|
br_code: ButtonRequestType = BR_TYPE_OTHER,
|
|
|
|
|
icon: str = ui.ICON_SEND, # TODO cleanup @ redesign
|
|
|
|
|
icon_color: int = ui.GREEN, # TODO cleanup @ redesign
|
|
|
|
|
ask_pagination: bool = False,
|
|
|
|
|
) -> None:
|
|
|
|
|
from ubinascii import hexlify
|
|
|
|
|
|
|
|
|
|
if isinstance(data, bytes):
|
|
|
|
|
data = hexlify(data).decode()
|
|
|
|
|
|
|
|
|
@ -626,12 +635,12 @@ async def confirm_blob(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def confirm_address(
|
|
|
|
|
ctx: wire.GenericContext,
|
|
|
|
|
ctx: GenericContext,
|
|
|
|
|
title: str,
|
|
|
|
|
address: str,
|
|
|
|
|
description: str | None = "Address:",
|
|
|
|
|
br_type: str = "confirm_address",
|
|
|
|
|
br_code: ButtonRequestType = ButtonRequestType.Other,
|
|
|
|
|
br_code: ButtonRequestType = BR_TYPE_OTHER,
|
|
|
|
|
icon: str = ui.ICON_SEND, # TODO cleanup @ redesign
|
|
|
|
|
icon_color: int = ui.GREEN, # TODO cleanup @ redesign
|
|
|
|
|
) -> Awaitable[None]:
|
|
|
|
@ -647,12 +656,12 @@ def confirm_address(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def confirm_text(
|
|
|
|
|
ctx: wire.GenericContext,
|
|
|
|
|
ctx: GenericContext,
|
|
|
|
|
br_type: str,
|
|
|
|
|
title: str,
|
|
|
|
|
data: str,
|
|
|
|
|
description: str | None = None,
|
|
|
|
|
br_code: ButtonRequestType = ButtonRequestType.Other,
|
|
|
|
|
br_code: ButtonRequestType = BR_TYPE_OTHER,
|
|
|
|
|
icon: str = ui.ICON_SEND, # TODO cleanup @ redesign
|
|
|
|
|
icon_color: int = ui.GREEN, # TODO cleanup @ redesign
|
|
|
|
|
) -> None:
|
|
|
|
@ -668,12 +677,12 @@ async def confirm_text(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def confirm_amount(
|
|
|
|
|
ctx: wire.GenericContext,
|
|
|
|
|
ctx: GenericContext,
|
|
|
|
|
title: str,
|
|
|
|
|
amount: str,
|
|
|
|
|
description: str = "Amount:",
|
|
|
|
|
br_type: str = "confirm_amount",
|
|
|
|
|
br_code: ButtonRequestType = ButtonRequestType.Other,
|
|
|
|
|
br_code: ButtonRequestType = BR_TYPE_OTHER,
|
|
|
|
|
icon: str = ui.ICON_SEND, # TODO cleanup @ redesign
|
|
|
|
|
icon_color: int = ui.GREEN, # TODO cleanup @ redesign
|
|
|
|
|
) -> Awaitable[None]:
|
|
|
|
@ -689,7 +698,7 @@ def confirm_amount(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def confirm_value(
|
|
|
|
|
ctx: wire.GenericContext,
|
|
|
|
|
ctx: GenericContext,
|
|
|
|
|
title: str,
|
|
|
|
|
value: str,
|
|
|
|
|
description: str,
|
|
|
|
@ -723,7 +732,7 @@ def confirm_value(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def confirm_properties(
|
|
|
|
|
ctx: wire.GenericContext,
|
|
|
|
|
ctx: GenericContext,
|
|
|
|
|
br_type: str,
|
|
|
|
|
title: str,
|
|
|
|
|
props: Iterable[PropertyType],
|
|
|
|
@ -733,6 +742,8 @@ async def confirm_properties(
|
|
|
|
|
br_code: ButtonRequestType = ButtonRequestType.ConfirmOutput,
|
|
|
|
|
) -> None:
|
|
|
|
|
def handle_bytes(prop):
|
|
|
|
|
from ubinascii import hexlify
|
|
|
|
|
|
|
|
|
|
if isinstance(prop[1], bytes):
|
|
|
|
|
return (prop[0], hexlify(prop[1]).decode(), True)
|
|
|
|
|
else:
|
|
|
|
@ -751,11 +762,11 @@ async def confirm_properties(
|
|
|
|
|
br_code,
|
|
|
|
|
)
|
|
|
|
|
if result is not trezorui2.CONFIRMED:
|
|
|
|
|
raise wire.ActionCancelled
|
|
|
|
|
raise ActionCancelled
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def confirm_total(
|
|
|
|
|
ctx: wire.GenericContext,
|
|
|
|
|
ctx: GenericContext,
|
|
|
|
|
total_amount: str,
|
|
|
|
|
fee_amount: str,
|
|
|
|
|
fee_rate_amount: str | None = None,
|
|
|
|
@ -788,7 +799,7 @@ async def confirm_total(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def confirm_joint_total(
|
|
|
|
|
ctx: wire.GenericContext, spending_amount: str, total_amount: str
|
|
|
|
|
ctx: GenericContext, spending_amount: str, total_amount: str
|
|
|
|
|
) -> None:
|
|
|
|
|
|
|
|
|
|
await raise_if_not_confirmed(
|
|
|
|
@ -807,7 +818,7 @@ async def confirm_joint_total(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def confirm_metadata(
|
|
|
|
|
ctx: wire.GenericContext,
|
|
|
|
|
ctx: GenericContext,
|
|
|
|
|
br_type: str,
|
|
|
|
|
title: str,
|
|
|
|
|
content: str,
|
|
|
|
@ -856,9 +867,7 @@ async def confirm_metadata(
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def confirm_replacement(
|
|
|
|
|
ctx: wire.GenericContext, description: str, txid: str
|
|
|
|
|
) -> None:
|
|
|
|
|
async def confirm_replacement(ctx: GenericContext, description: str, txid: str) -> None:
|
|
|
|
|
await confirm_blob(
|
|
|
|
|
ctx,
|
|
|
|
|
title=description.upper(),
|
|
|
|
@ -870,7 +879,7 @@ async def confirm_replacement(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def confirm_modify_output(
|
|
|
|
|
ctx: wire.GenericContext,
|
|
|
|
|
ctx: GenericContext,
|
|
|
|
|
address: str,
|
|
|
|
|
sign: int,
|
|
|
|
|
amount_change: str,
|
|
|
|
@ -894,7 +903,7 @@ async def confirm_modify_output(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def confirm_modify_fee(
|
|
|
|
|
ctx: wire.GenericContext,
|
|
|
|
|
ctx: GenericContext,
|
|
|
|
|
sign: int,
|
|
|
|
|
user_fee_change: str,
|
|
|
|
|
total_fee_new: str,
|
|
|
|
@ -917,7 +926,7 @@ async def confirm_modify_fee(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def confirm_coinjoin(
|
|
|
|
|
ctx: wire.GenericContext, max_rounds: int, max_fee_per_vbyte: str
|
|
|
|
|
ctx: GenericContext, max_rounds: int, max_fee_per_vbyte: str
|
|
|
|
|
) -> None:
|
|
|
|
|
await raise_if_not_confirmed(
|
|
|
|
|
interact(
|
|
|
|
@ -940,7 +949,7 @@ def show_coinjoin() -> None:
|
|
|
|
|
|
|
|
|
|
# TODO cleanup @ redesign
|
|
|
|
|
async def confirm_sign_identity(
|
|
|
|
|
ctx: wire.GenericContext, proto: str, identity: str, challenge_visual: str | None
|
|
|
|
|
ctx: GenericContext, proto: str, identity: str, challenge_visual: str | None
|
|
|
|
|
) -> None:
|
|
|
|
|
await confirm_blob(
|
|
|
|
|
ctx,
|
|
|
|
@ -953,7 +962,7 @@ async def confirm_sign_identity(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def confirm_signverify(
|
|
|
|
|
ctx: wire.GenericContext, coin: str, message: str, address: str, verify: bool
|
|
|
|
|
ctx: GenericContext, coin: str, message: str, address: str, verify: bool
|
|
|
|
|
) -> None:
|
|
|
|
|
if verify:
|
|
|
|
|
title = f"VERIFY {coin} MESSAGE"
|
|
|
|
@ -964,19 +973,19 @@ async def confirm_signverify(
|
|
|
|
|
|
|
|
|
|
await confirm_blob(
|
|
|
|
|
ctx,
|
|
|
|
|
title=title,
|
|
|
|
|
data=address,
|
|
|
|
|
description="Confirm address:",
|
|
|
|
|
br_type=br_type,
|
|
|
|
|
br_type,
|
|
|
|
|
title,
|
|
|
|
|
address,
|
|
|
|
|
"Confirm address:",
|
|
|
|
|
br_code=ButtonRequestType.Other,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
await confirm_blob(
|
|
|
|
|
ctx,
|
|
|
|
|
title=title,
|
|
|
|
|
data=message,
|
|
|
|
|
description="Confirm message:",
|
|
|
|
|
br_type=br_type,
|
|
|
|
|
br_type,
|
|
|
|
|
title,
|
|
|
|
|
message,
|
|
|
|
|
"Confirm message:",
|
|
|
|
|
br_code=ButtonRequestType.Other,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
@ -1004,7 +1013,7 @@ def draw_simple_text(title: str, description: str = "") -> None:
|
|
|
|
|
log.error(__name__, "draw_simple_text not implemented")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def request_passphrase_on_device(ctx: wire.GenericContext, max_len: int) -> str:
|
|
|
|
|
async def request_passphrase_on_device(ctx: GenericContext, max_len: int) -> str:
|
|
|
|
|
await button_request(
|
|
|
|
|
ctx, "passphrase_device", code=ButtonRequestType.PassphraseEntry
|
|
|
|
|
)
|
|
|
|
@ -1013,19 +1022,21 @@ async def request_passphrase_on_device(ctx: wire.GenericContext, max_len: int) -
|
|
|
|
|
trezorui2.request_passphrase(prompt="Enter passphrase", max_len=max_len)
|
|
|
|
|
)
|
|
|
|
|
result = await ctx.wait(keyboard)
|
|
|
|
|
if result is trezorui2.CANCELLED:
|
|
|
|
|
raise wire.ActionCancelled("Passphrase entry cancelled")
|
|
|
|
|
if result is CANCELLED:
|
|
|
|
|
raise ActionCancelled("Passphrase entry cancelled")
|
|
|
|
|
|
|
|
|
|
assert isinstance(result, str)
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def request_pin_on_device(
|
|
|
|
|
ctx: wire.GenericContext,
|
|
|
|
|
ctx: GenericContext,
|
|
|
|
|
prompt: str,
|
|
|
|
|
attempts_remaining: int | None,
|
|
|
|
|
allow_cancel: bool,
|
|
|
|
|
) -> str:
|
|
|
|
|
from trezor.wire import PinCancelled
|
|
|
|
|
|
|
|
|
|
await button_request(ctx, "pin_device", code=ButtonRequestType.PinEntry)
|
|
|
|
|
|
|
|
|
|
warning = "Wrong PIN" if "Wrong" in prompt else None
|
|
|
|
@ -1049,7 +1060,7 @@ async def request_pin_on_device(
|
|
|
|
|
)
|
|
|
|
|
while True:
|
|
|
|
|
result = await ctx.wait(dialog)
|
|
|
|
|
if result is trezorui2.CANCELLED:
|
|
|
|
|
raise wire.PinCancelled
|
|
|
|
|
if result is CANCELLED:
|
|
|
|
|
raise PinCancelled
|
|
|
|
|
assert isinstance(result, str)
|
|
|
|
|
return result
|
|
|
|
|