fix(core/caesar): ctx menu with extra info
What changed, and why it matters
This commit fixes UI navigation behavior on Trezor Safe 3 and related Caesar-layout devices when confirming cryptocurrency transactions. Previously, pressing the shifted-right button on certain confirmation screens could cancel the signing flow instead of going back to the previous screen, and some screens lacked a proper cancel option in the menu. The patch makes navigation consistent so users can move back and forth between recipient/amount/summary screens and cancel safely from the menu, reducing the chance of accidental transaction confirmation or cancellation.
Treat as a low-severity UX/consistency fix. Review that all Caesar-layout transaction confirmations now map shifted-right and menu-cancel actions correctly, and run the updated device tests on safe3/t3t1/t3w1 to verify no regression in cancellation behavior.
Security signals we found
UI state-machine fix: Cancel signal reinterpreted as Back when back_on_first_page is set
New back_button parameter propagated through multiple confirmation-page constructors
Multiple transaction flows refactored to use menu-based cancel and explicit back navigation
Test coverage expanded to include safe3 for back/cancel behavior from amount screen
Evidence from the diff
The patch updates the Caesar UI layout in Trezor firmware so that PageMsg::Cancelled is translated to BACK instead of CANCELLED when the page is configured with back-on-first-page. It threads a new back_button flag through content_in_button_page and several confirm_* helpers, enabling shifted-right-button navigation to return to the prior screen rather than aborting. It also refactors confirm_output, confirm_ethereum_tx, confirm_ethereum_staking_tx, confirm_ethereum_vault_tx, confirm_solana_staking_tx, confirm_tron_claim, and related flows to use external menus with explicit cancel labels and linear-flow navigation. Tests are updated to include safe3 in back-from-amount and cancel-from-amount scenarios.
Changed components
core/embed/rust/src/ui/layout_caesar/component/page.rscore/embed/rust/src/ui/layout_caesar/component_msg_obj.rscore/embed/rust/src/ui/layout_caesar/ui_firmware.rscore/src/trezor/ui/layouts/caesar/__init__.pytests/device_tests/bitcoin/test_signtx.pytests/input_flows.pyInspect captured patch +356 / −205
### core/embed/rust/src/ui/layout_caesar/component/page.rs
@@ -91,7 +91,8 @@ where
}
/// "Shift" is offered also on the first page, where it goes back to the
- /// previous screen of the flow - the screen returns `PageMsg::Cancelled`.
+ /// previous screen of the flow - the screen returns `PageMsg::Cancelled`,
+ /// which is `BACK` for MicroPython.
/// Only for `MenuNav::Menu` and `MenuNav::ChoiceMenu`, where the left
/// button does not cancel.
pub fn with_back_on_first_page(mut self) -> Self {
@@ -109,6 +110,12 @@ where
self
}
+ /// Whether `PageMsg::Cancelled` means going back to the previous screen
+ /// (see `with_back_on_first_page`) rather than cancelling.
+ pub fn cancelled_is_back(&self) -> bool {
+ self.back_on_first_page && self.menu_nav != Some(MenuNav::Close)
+ }
+
/// Basically just determining whether the right button for
/// initial page should be "NEXT" or "CONFIRM".
/// Can only be called when we know the final page_count.
### core/embed/rust/src/ui/layout_caesar/component_msg_obj.rs
@@ -40,6 +40,7 @@ where
fn msg_try_into_obj(&self, msg: Self::Msg) -> Result<Obj, Error> {
match msg {
PageMsg::Confirmed => Ok(CONFIRMED.as_obj()),
+ PageMsg::Cancelled if self.cancelled_is_back() => Ok(BACK.as_obj()),
PageMsg::Cancelled => Ok(CANCELLED.as_obj()),
PageMsg::Info => Ok(INFO.as_obj()),
_ => Err(Error::TypeError),
### core/embed/rust/src/ui/layout_caesar/ui_firmware.rs
@@ -24,7 +24,8 @@ use crate::ui::component::text::paragraphs::{
};
use crate::ui::component::text::TextStyle;
use crate::ui::component::{
- Component, ComponentExt, Empty, FlowMsg, FormattedText, Never, PageMsg, Paginate, Timeout,
+ Component, ComponentExt, Empty, FlowMsg, FormattedText, LineBreaking, Never, PageMsg, Paginate,
+ Timeout,
};
use crate::ui::layout::menu_item_intent::MenuItemIntent;
use crate::ui::layout::obj::{LayoutMaybeTrace, LayoutObj, RootComponent};
@@ -75,6 +76,7 @@ impl FirmwareUI for UICaesar {
verb_cancel,
hold,
external_menu,
+ false,
)
}
@@ -98,8 +100,11 @@ impl FirmwareUI for UICaesar {
if chunkify {
ops.add_chunkify_text(None);
}
- ops.add_text_with_font(label, fonts::FONT_NORMAL)
- .add_newline();
+ // the label is a text, breaking only at whitespace
+ ops.add_line_breaking(LineBreaking::BreakAtWhitespace)
+ .add_text_with_font(label, fonts::FONT_NORMAL)
+ .add_newline()
+ .add_line_breaking(theme::TEXT_MONO_DATA.line_breaking);
}
if chunkify {
// Chunkifying the address into smaller pieces when requested
@@ -148,7 +153,7 @@ impl FirmwareUI for UICaesar {
_page_counter: bool,
_prompt_screen: bool,
_cancel: bool,
- _back_button: bool,
+ back_button: bool,
_footer: Option<(TString<'static>, bool)>,
external_menu: bool,
) -> Result<impl LayoutMaybeTrace, Error> {
@@ -176,6 +181,7 @@ impl FirmwareUI for UICaesar {
verb_cancel,
hold,
external_menu,
+ back_button,
)
}
@@ -225,6 +231,7 @@ impl FirmwareUI for UICaesar {
None,
true,
false,
+ false,
)
}
@@ -345,6 +352,7 @@ impl FirmwareUI for UICaesar {
Some("".into()),
false,
false,
+ false,
)
}
@@ -373,6 +381,7 @@ impl FirmwareUI for UICaesar {
Some("".into()),
false,
false,
+ false,
)
}
@@ -404,6 +413,7 @@ impl FirmwareUI for UICaesar {
Some("<".into()),
false,
false,
+ false,
)
}
@@ -430,6 +440,7 @@ impl FirmwareUI for UICaesar {
Some("".into()),
hold,
external_menu,
+ false,
)
}
@@ -453,7 +464,15 @@ impl FirmwareUI for UICaesar {
.add_text_with_font(TR::reset__tos_link, fonts::FONT_BOLD);
let formatted = FormattedText::new(ops).vertically_centered();
- content_in_button_page(title, formatted, button, Some("".into()), false, false)
+ content_in_button_page(
+ title,
+ formatted,
+ button,
+ Some("".into()),
+ false,
+ false,
+ false,
+ )
}
fn confirm_summary(
@@ -607,6 +626,7 @@ impl FirmwareUI for UICaesar {
Some("".into()),
false,
false,
+ false,
)?;
LayoutObj::new_root(layout)
}
@@ -998,6 +1018,7 @@ impl FirmwareUI for UICaesar {
None,
false,
false,
+ false,
)
}
@@ -1376,15 +1397,18 @@ const DOWN_ARROW: &str = "V";
/// Has optional title (supply empty `TString` for that) and hold-to-confirm
/// functionality.
///
-/// With `external_menu`, the left button opens the context menu. Otherwise, an
-/// empty `verb_cancel` puts a cross cancelling the flow on the left.
+/// With `external_menu`, the left button opens the context menu, and with
+/// `back_button` also "Shift" + right button on the first page goes back to the
+/// previous screen. Otherwise, an empty `verb_cancel` puts a cross cancelling
+/// the flow on the left.
fn content_in_button_page<T: Component + Paginate + MaybeTrace + 'static>(
title: TString<'static>,
content: T,
verb: TString<'static>,
verb_cancel: Option<TString<'static>>,
hold: bool,
external_menu: bool,
+ back_button: bool,
) -> Result<impl LayoutMaybeTrace, Error> {
// Right button - down arrow, text or nothing.
// Optional HoldToConfirm
@@ -1402,6 +1426,9 @@ fn content_in_button_page<T: Component + Paginate + MaybeTrace + 'static>(
let mut content = ButtonPage::new(content, theme::BG).with_confirm_btn(confirm_btn);
if external_menu {
content = content.with_menu_nav(MenuNav::Menu);
+ if back_button {
+ content = content.with_back_on_first_page();
+ }
} else if verb_cancel.is_some_and(|verb_cancel| verb_cancel.is_empty()) {
content = content.with_menu_nav(MenuNav::Close);
} else {
### core/src/trezor/ui/layouts/caesar/__init__.py
@@ -393,10 +393,12 @@ async def show_qr_code() -> None:
)
)
+ # shown above the address
+ address_label = "\n".join(line for line in (network, warning) if line)
with trezorui_api.confirm_address(
title=title,
address=address,
- address_label=None,
+ address_label=address_label or None,
info_button=True,
chunkify=chunkify,
) as layout:
@@ -423,6 +425,7 @@ async def show_pubkey(
br_name=br_name,
br_code=ButtonRequestType.PublicKey,
mismatch_title=mismatch_title,
+ warning=warning,
chunkify=False,
)
@@ -612,7 +615,7 @@ async def _task() -> None:
) as main_layout:
await confirm_with_menu(
main_layout,
- _menu_with_cancel(menu_items),
+ _menu_with_cancel(menu_items, TR.buttons__cancel_sign),
"confirm_payment_request",
)
else:
@@ -657,50 +660,61 @@ async def confirm_output(
address_label: str | None = None,
output_index: int | None = None,
chunkify: bool = False,
- source_account: str | None = None, # ignored on safe 3
- source_account_path: str | None = None, # ignored on safe 3
+ source_account: str | None = None,
+ source_account_path: str | None = None,
) -> None:
- title = title or TR.send__confirm_sending # def_arg
+ from trezor.ui.layouts.menu import interact_with_menu
+
+ from ..common import confirm_linear_flow
+
address_title = TR.words__recipient
if output_index is not None:
address_title += f" #{output_index + 1}"
amount_title = TR.words__amount
if output_index is not None:
amount_title += f" #{output_index + 1}"
- while True:
- with trezorui_api.confirm_address(
- title=address_title,
- address=address,
- address_label=address_label or None,
- verb=TR.buttons__continue,
- info_button=False,
- chunkify=chunkify,
- ) as layout:
- await interact(
- layout,
- "confirm_output",
- br_code,
+ account_items: list[StrPropertyType] = []
+ if source_account:
+ account_items.append((TR.words__wallet, source_account, None))
+ if source_account_path and source_account_path != source_account:
+ # the reason for this check is account_label in bitcoin/sign_tx/layout.py
+ # which can return the derivation path instead of the account
+ account_items.append(
+ (TR.address_details__derivation_path, source_account_path, None)
+ )
+ menu_items = []
+ if account_items:
+ menu_items.append(
+ create_info_menu_leaf(
+ TR.address_details__account_info, with_colon(account_items)
)
+ )
+ menu = _menu_with_cancel(menu_items, TR.buttons__cancel_sign)
- try:
- with trezorui_api.confirm_value(
- title=amount_title,
- value=amount,
- description=None,
- verb_cancel="^",
- verb=TR.buttons__confirm,
- ) as layout:
- await interact(
- layout,
- "confirm_output",
- br_code,
- )
- except ActionCancelled:
- # if the user cancels here, go back to confirm_value
- continue
- else:
- return
+ address_ctx = trezorui_api.confirm_address(
+ title=address_title,
+ address=address,
+ address_label=address_label or None,
+ verb=TR.buttons__continue,
+ info_button=True,
+ chunkify=chunkify,
+ )
+ # "Shift" + right button goes back to the address
+ amount_ctx = trezorui_api.confirm_value(
+ title=amount_title,
+ value=amount,
+ description=None,
+ verb=TR.buttons__confirm,
+ external_menu=True,
+ back_button=True,
+ )
+
+ with address_ctx as address_layout, amount_ctx as amount_layout:
+ await confirm_linear_flow(
+ lambda: interact_with_menu(address_layout, menu, "confirm_output", br_code),
+ lambda: interact_with_menu(amount_layout, menu, "confirm_output", br_code),
+ )
async def tutorial(br_code: ButtonRequestType = BR_CODE_OTHER) -> ui.UiResult:
@@ -874,8 +888,25 @@ def confirm_address(
info_items: Iterable[StrPropertyType] | None = None,
info_title: str | None = None,
) -> Awaitable[None]:
+ br_name = br_name or "confirm_address" # def_arg
+ if info_items:
+ return _confirm_value_with_menu(
+ br_name,
+ br_code,
+ subtitle or title,
+ address,
+ [
+ create_info_menu_leaf(
+ info_title or TR.words__title_information,
+ with_colon(info_items),
+ )
+ ],
+ description=with_colon(description),
+ verb=verb or TR.buttons__confirm,
+ chunkify=chunkify,
+ )
return confirm_blob(
- br_name or "confirm_address",
+ br_name,
subtitle or title,
address,
description,
@@ -933,6 +964,7 @@ async def confirm_properties(
title=title,
items=items,
hold=hold,
+ verb=verb,
) as layout:
return await raise_if_not_confirmed(
layout,
@@ -956,8 +988,12 @@ async def confirm_value(
chunkify: bool = False,
chunkify_info: bool = False,
cancel: bool = False,
+ cancel_text: str | None = None,
) -> None:
- """General confirmation dialog, used by many other confirm_* functions."""
+ """General confirmation dialog, used by many other confirm_* functions.
+
+ `info_items` are shown in the menu, `cancel_text` labels its cancel item.
+ """
if description and value:
description = with_colon(description)
@@ -981,25 +1017,7 @@ async def confirm_value(
br_code,
)
- from trezor.ui.layouts.menu import confirm_with_menu, leaf_from_layout
-
- if chunkify:
- main_ctx = trezorui_api.confirm_address(
- title=title,
- address=value,
- address_label=None,
- verb=verb or TR.buttons__confirm,
- info_button=True,
- chunkify=chunkify,
- )
- else:
- main_ctx = trezorui_api.confirm_with_info(
- title=title,
- subtitle=description,
- items=((value, False),),
- verb=verb or TR.buttons__confirm,
- external_menu=True,
- )
+ from trezor.ui.layouts.menu import leaf_from_layout
def item_factory(
info_title: str, info_value: str
@@ -1014,12 +1032,21 @@ def item_factory(
chunkify=chunkify_info,
)
- menu = _menu_with_cancel(
- leaf_from_layout(name or "", item_factory(name or "", value or ""))
- for name, value, _is_data in info_items
+ await _confirm_value_with_menu(
+ br_name,
+ br_code,
+ title,
+ value,
+ [
+ leaf_from_layout(name or "", item_factory(name or "", value or ""))
+ for name, value, _is_data in info_items
+ ],
+ description=description,
+ verb=verb or TR.buttons__confirm,
+ is_data=is_data,
+ chunkify=chunkify,
+ cancel=cancel_text,
)
- with main_ctx as main:
- return await confirm_with_menu(main, menu, br_name, br_code)
async def confirm_total(
@@ -1086,7 +1113,7 @@ async def confirm_trade(
]
for k, v in extra_menu_items:
menu_items.append(create_info_menu_leaf(k, v))
- menu = _menu_with_cancel(menu_items)
+ menu = _menu_with_cancel(menu_items, TR.buttons__cancel_sign)
with trade_ctx as trade_layout:
await confirm_with_menu(trade_layout, menu, "confirm_trade")
@@ -1236,9 +1263,7 @@ async def confirm_ethereum_approve(
False,
)
- account_items: tuple[StrPropertyType] | None = None
- if account_path:
- account_items = ((TR.address_details__derivation_path, account_path, None),)
+ account_items = _account_info_items(account, account_path)
await _confirm_summary(
"confirm_ethereum_approve",
@@ -1249,7 +1274,7 @@ async def confirm_ethereum_approve(
title=TR.words__title_summary,
info=(
(TR.confirm_total__title_fee, with_colon(fee_info_items)),
- (TR.address_details__account_info, with_colon(account_items)),
+ (TR.address_details__account_info, account_items),
),
br_code=BR_CODE_OTHER,
)
@@ -1330,8 +1355,8 @@ async def confirm_ethereum_staking_tx(
intro_question: str,
verb: str,
total_amount: str,
- _account: str | None,
- _account_path: str | None,
+ account: str | None,
+ account_path: str | None,
maximum_fee: str,
address: str,
address_title: str,
@@ -1340,17 +1365,31 @@ async def confirm_ethereum_staking_tx(
br_name: str = "confirm_ethereum_staking_tx",
br_code: ButtonRequestType = ButtonRequestType.SignTx,
) -> None:
+ from trezor.ui.layouts.menu import leaf_from_layout
+
from ..properties import with_colon
- await confirm_value(
- title,
- intro_question,
- "",
+ def address_layout() -> trezorui_api.LayoutContext:
+ # chunkified when requested, closed by the left button
+ return trezorui_api.confirm_value(
+ title=address_title,
+ value=address,
+ description=None,
+ verb="",
+ verb_cancel="",
+ chunkify=chunkify,
+ )
+
+ await _confirm_value_with_menu(
br_name,
br_code,
+ title,
+ intro_question,
+ [leaf_from_layout(address_title, address_layout)]
+ + _account_info_leaves(account, account_path),
verb=verb,
- info_items=((address_title, address, None),),
- chunkify_info=chunkify,
+ is_data=False,
+ cancel=TR.buttons__cancel_sign,
)
# confirmation
@@ -1393,25 +1432,15 @@ async def confirm_ethereum_vault_tx(
) -> None:
from ..properties import with_colon
- account_properties: list[StrPropertyType] = []
- if account:
- account_properties.append((TR.words__account, account, None))
- if account_path:
- account_properties.append(
- (TR.address_details__derivation_path, account_path, None)
- )
-
- await confirm_value(
- title=title,
- value=intro_question,
- is_data=False,
- description=None,
+ await _confirm_value_with_menu(
+ f"{br_name}/intro",
+ br_code,
+ title,
+ intro_question,
+ _account_info_leaves(account, account_path),
verb=TR.buttons__continue,
- chunkify=False,
- info_items=account_properties if account_properties else None,
- cancel=True,
- br_name=f"{br_name}/intro",
- br_code=br_code,
+ is_data=False,
+ cancel=TR.buttons__cancel_sign,
)
await confirm_value(
@@ -1493,25 +1522,15 @@ async def confirm_ethereum_vault_claim(
from ..properties import with_colon
- account_properties: list[StrPropertyType] = []
- if account:
- account_properties.append((TR.words__account, account, None))
- if account_path:
- account_properties.append(
- (TR.address_details__derivation_path, account_path, None)
- )
-
- await confirm_value(
- title=title,
- value=intro_question,
- is_data=False,
- description=None,
+ await _confirm_value_with_menu(
+ f"{br_name}/intro",
+ br_code,
+ title,
+ intro_question,
+ _account_info_leaves(account, account_path),
verb=TR.buttons__continue,
- chunkify=False,
- info_items=account_properties if account_properties else None,
- cancel=True,
- br_name=f"{br_name}/intro",
- br_code=br_code,
+ is_data=False,
+ cancel=TR.buttons__cancel_sign,
)
await confirm_properties(
@@ -1712,8 +1731,9 @@ async def confirm_solana_staking_tx(
br_name: str = "confirm_solana_staking_tx",
br_code: ButtonRequestType = ButtonRequestType.SignTx,
) -> None:
- from trezor.ui.layouts.menu import confirm_with_menu
+ from trezor.ui.layouts.menu import interact_with_menu
+ from ..common import confirm_linear_flow
from ..properties import with_colon
if not amount_item:
@@ -1733,33 +1753,12 @@ async def confirm_solana_staking_tx(
items.append(stake_item)
items.append(blockhash_item)
- if vote_account:
- description = f"{description}\n{TR.words__provider}:"
- title = None # so the layout will fit in a single page
- else:
- description = f"\n{description}"
-
- main_ctx = trezorui_api.confirm_summary(
- title=title,
- amount=vote_account,
- amount_label=description,
- fee="",
- fee_label="",
- external_menu=True,
- )
- menu = _menu_with_cancel(
- create_info_menu_leaf(name or "", value or "")
- for name, value, _is_data in items
- )
- with main_ctx as main:
- await confirm_with_menu(main, menu, br_name, br_code)
-
- main_ctx = trezorui_api.confirm_summary(
- amount=amount,
- amount_label=with_colon(amount_label),
- fee=fee,
- fee_label=with_colon(fee_label),
- external_menu=True,
+ intro_menu = _menu_with_cancel(
+ (
+ create_info_menu_leaf(name or "", value or "")
+ for name, value, _is_data in items
+ ),
+ TR.buttons__cancel_sign,
)
account_details: list[StrPropertyType] = with_colon(
(
@@ -1771,11 +1770,36 @@ async def confirm_solana_staking_tx(
(TR.confirm_total__title_fee, fee_details),
(TR.address_details__account_info, account_details),
]
- menu = _menu_with_cancel(
- create_info_menu_leaf(name, props) for name, props in iter
+ summary_menu = _menu_with_cancel(
+ (create_info_menu_leaf(name, props) for name, props in iter),
+ TR.buttons__cancel_sign,
)
- with main_ctx as main:
- await confirm_with_menu(main, menu, br_name, br_code)
+
+ async def _intro() -> trezorui_api.UiResult:
+ with trezorui_api.confirm_value(
+ title=title or "",
+ value=vote_account,
+ description=description,
+ extra=with_colon(TR.words__provider) if vote_account else None,
+ chunkify=chunkify,
+ verb=TR.buttons__continue,
+ external_menu=True,
+ ) as layout:
+ return await interact_with_menu(layout, intro_menu, br_name, br_code)
+
+ async def _summary() -> trezorui_api.UiResult:
+ # "Shift" + right button goes back to the intro
+ with trezorui_api.confirm_summary(
+ amount=amount,
+ amount_label=with_colon(amount_label),
+ fee=fee,
+ fee_label=with_colon(fee_label),
+ back_button=True,
+ external_menu=True,
+ ) as layout:
+ return await interact_with_menu(layout, summary_menu, br_name, br_code)
+
+ await confirm_linear_flow(_intro, _summary)
async def confirm_cardano_tx(
amount: str,
@@ -1800,8 +1824,8 @@ async def confirm_cardano_tx(
async def confirm_ethereum_tx(
recipient: str | None,
total_amount: str,
- _account: str | None,
- _account_path: str | None,
+ account: str | None,
+ account_path: str | None,
maximum_fee: str,
fee_info_items: Iterable[StrPropertyType],
is_send: bool,
@@ -1812,50 +1836,58 @@ async def confirm_ethereum_tx(
) -> None:
from trezor.ui.layouts.menu import interact_with_menu
+ from ..common import confirm_linear_flow
from ..properties import with_colon
if native_amount is not None:
# A non-zero native ETH value carried alongside a token transfer;
# show it next to the token amount so it can't be signed unseen.
total_amount = f"{total_amount}\n{native_amount}"
- menu = _menu_with_cancel(
+ if is_send:
+ title = TR.words__recipient
+ else:
+ title = TR.ethereum__contract_address if recipient else ""
+
+ recipient_menu = _menu_with_cancel(
+ _account_info_leaves(account, account_path), TR.buttons__cancel_sign
+ )
+ summary_menu = _menu_with_cancel(
[
create_info_menu_leaf(
TR.confirm_total__title_fee, with_colon(fee_info_items)
)
- ]
+ ],
+ TR.buttons__cancel_sign,
)
- with trezorui_api.confirm_summary(
- amount=total_amount,
- amount_label=with_colon(TR.words__amount),
- fee=maximum_fee,
- fee_label=with_colon(TR.send__maximum_fee),
- back_button=True,
- external_menu=True,
- ) as summary_layout:
- if is_send:
- title = TR.words__recipient
- else:
- title = TR.ethereum__contract_address if recipient else ""
-
- while True:
- # Allowing going back and forth between recipient and summary/details
- await confirm_blob(
- br_name,
- title,
- recipient or TR.ethereum__new_contract,
- verb=TR.buttons__continue,
- br_code=br_code,
- chunkify=(chunkify if recipient else False),
- )
- # going back to the recipient returns CANCELLED
- result = await interact_with_menu(
- summary_layout, menu, br_name, br_code, raise_on_cancel=None
+ async def _recipient() -> trezorui_api.UiResult:
+ with trezorui_api.confirm_value(
+ title=title,
+ value=recipient or TR.ethereum__new_contract,
+ description=None,
+ is_data=bool(recipient),
+ verb=TR.buttons__continue,
+ chunkify=chunkify if recipient else False,
+ external_menu=True,
+ ) as layout:
+ return await interact_with_menu(
+ layout, recipient_menu, br_name, br_code
)
- if result is CONFIRMED:
- break
+
+ async def _summary() -> trezorui_api.UiResult:
+ # "Shift" + right button goes back to the recipient
+ with trezorui_api.confirm_summary(
+ amount=total_amount,
+ amount_label=with_colon(TR.words__amount),
+ fee=maximum_fee,
+ fee_label=with_colon(TR.send__maximum_fee),
+ back_button=True,
+ external_menu=True,
+ ) as layout:
+ return await interact_with_menu(layout, summary_menu, br_name, br_code)
+
+ await confirm_linear_flow(_recipient, _summary)
async def confirm_stellar_tx(
fee: str,
@@ -1985,24 +2017,15 @@ async def confirm_tron_claim(
br_name: str = "tron/claim",
br_code: ButtonRequestType = ButtonRequestType.SignTx,
) -> None:
- account_properties: list[StrPropertyType] = []
- if account:
- account_properties.append((TR.words__account, account, None))
- if account_path:
- account_properties.append(
- (TR.address_details__derivation_path, account_path, None)
- )
- await confirm_value(
- title=title,
- value=intro_question,
- is_data=False,
- description=None,
- chunkify=False,
+ await _confirm_value_with_menu(
+ br_name,
+ br_code,
+ title,
+ intro_question,
+ _account_info_leaves(account, account_path),
verb=TR.buttons__confirm,
- info_items=account_properties,
- cancel=True,
- br_name=br_name,
- br_code=br_code,
+ is_data=False,
+ cancel=TR.buttons__cancel_sign,
)
async def confirm_tron_summary(
@@ -2662,15 +2685,70 @@ def create_info_menu_leaf(
)
-def _menu_with_cancel(items: Iterable[MenuLeaf[R]]) -> Menu[R]:
- """Context menu with the given items, and the last one cancelling the flow."""
+def _menu_with_cancel(
+ items: Iterable[MenuLeaf[R]], cancel: str | None = None
+) -> Menu[R]:
+ """Context menu with the given items, and the last one cancelling the flow
+ (labelled `cancel`, "Cancel" by default)."""
from trezor.ui.layouts.menu import Menu, cancel_leaf
items = list(items)
- items.append(cancel_leaf(TR.buttons__cancel))
+ items.append(cancel_leaf(cancel or TR.buttons__cancel))
return Menu(items)
+def _account_info_items(
+ account: str | None, account_path: str | None
+) -> list[StrPropertyType]:
+ items: list[StrPropertyType] = []
+ if account:
+ items.append((TR.words__account, account, None))
+ if account_path:
+ items.append((TR.address_details__derivation_path, account_path, None))
+ return with_colon(items)
+
+
+def _account_info_leaves(
+ account: str | None, account_path: str | None
+) -> list[MenuLeaf[None]]:
+ """ "Account info" menu item, if there is any."""
+ items = _account_info_items(account, account_path)
+ if not items:
+ return []
+ return [create_info_menu_leaf(TR.address_details__account_info, items)]
+
+
+async def _confirm_value_with_menu(
+ br_name: str,
+ br_code: ButtonRequestType,
+ title: str,
+ value: str,
+ menu_items: Iterable[MenuLeaf[None]],
+ *,
+ description: str | None = None,
+ verb: str | None = None,
+ is_data: bool = True,
+ chunkify: bool = False,
+ cancel: str | None = None,
+) -> None:
+ """Value confirmed by the right button, with `menu_items` and a cancel item
+ in the menu."""
+ from trezor.ui.layouts.menu import confirm_with_menu
+
+ with trezorui_api.confirm_value(
+ title=title,
+ value=value,
+ description=description,
+ verb=verb or TR.buttons__confirm,
+ is_data=is_data,
+ chunkify=chunkify,
+ external_menu=True,
+ ) as layout:
+ await confirm_with_menu(
+ layout, _menu_with_cancel(menu_items, cancel), br_name, br_code
+ )
+
+
async def _confirm_summary(
br_name: str,
*,
### tests/device_tests/bitcoin/test_signtx.py
@@ -158,7 +158,7 @@ def test_one_one_fee(session: Session):
)
-@pytest.mark.models("t3w1", "t3t1")
+@pytest.mark.models("safe3", "t3w1", "t3t1")
def test_one_one_fee_back_from_amount(session: Session):
# input tx: 0dac366fd8a67b2a89fbb0d31086e7acded7a5bbf9ef9daa935bc873229ef5b5
@@ -212,7 +212,7 @@ def test_one_one_fee_back_from_amount(session: Session):
@pytest.mark.models(
- "t3t1", "t3w1", reason="Cannot cancel from Amount screen on Bolt & Caesar"
+ "safe3", "t3t1", "t3w1", reason="Cannot cancel from Amount screen on Bolt"
)
def test_one_one_fee_cancel_from_amount(session: Session):
# input tx: 0dac366fd8a67b2a89fbb0d31086e7acded7a5bbf9ef9daa935bc873229ef5b5
### tests/input_flows.py
@@ -1379,6 +1379,31 @@ def sign_tx_go_to_info_caesar(
class InputFlowSignTxBackFromAmount(InputFlowBase):
+ def input_flow_caesar(self) -> BRGeneratorType:
+ yield
+ layout = self.debug.read_layout()
+ assert TR.words__recipient + " #1" in layout.title()
+ self.debug.press_right()
+
+ yield
+ layout = self.debug.read_layout()
+ assert TR.words__amount + " #1" in layout.title()
+ # "Shift" + right button goes back
+ self.debug.press_right_with_shift()
+
+ yield
+ layout = self.debug.read_layout()
+ assert TR.words__recipient + " #1" in layout.title()
+ self.debug.press_right()
+
+ yield
+ self.debug.read_layout()
+ self.debug.press_right()
+
+ yield
+ self.debug.read_layout()
+ self.debug.press_yes()
+
def input_flow_delizia(self) -> BRGeneratorType:
yield
layout = self.debug.read_layout()
@@ -1435,6 +1460,19 @@ def input_flow_eckhart(self) -> BRGeneratorType:
class InputFlowSignTxCancelFromAmount(InputFlowBase):
+ def input_flow_caesar(self) -> BRGeneratorType:
+ yield # confirm address
+ self.debug.read_layout()
+ self.debug.press_right()
+
+ yield # amount screen
+ layout = self.debug.read_layout()
+ assert TR.words__amount + " #1" in layout.title()
+ # cancel is the last menu item
+ self.debug.press_left()
+ menu = self.debug.synchronize_at("SimpleChoice")
+ self.debug.button_actions.navigate_to_menu_item(menu.page_count() - 1)
+
def input_flow_delizia(self) -> BRGeneratorType:
yield # confirm address
layout = self.debug.read_layout()Why this scored 28/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.