diff --git a/core/src/apps/bitcoin/sign_tx/approvers.py b/core/src/apps/bitcoin/sign_tx/approvers.py index dece0a572..bdbadf804 100644 --- a/core/src/apps/bitcoin/sign_tx/approvers.py +++ b/core/src/apps/bitcoin/sign_tx/approvers.py @@ -248,9 +248,10 @@ class BasicApprover(Approver): if msg.amount is None: raise DataError("Missing payment request amount.") - result = await helpers.confirm_payment_request(msg, self.coin, self.amount_unit) - # When user wants to see more info, the result will be False. - self.show_payment_req_details = result is False + result = await helpers.should_show_payment_request_details( + msg, self.coin, self.amount_unit + ) + self.show_payment_req_details = result is True async def approve_orig_txids( self, tx_info: TxInfo, orig_txs: list[OriginalTxInfo] diff --git a/core/src/apps/bitcoin/sign_tx/helpers.py b/core/src/apps/bitcoin/sign_tx/helpers.py index 5ee9cdee2..853be7017 100644 --- a/core/src/apps/bitcoin/sign_tx/helpers.py +++ b/core/src/apps/bitcoin/sign_tx/helpers.py @@ -85,8 +85,8 @@ class UiConfirmPaymentRequest(UiConfirm): self.amount_unit = amount_unit self.coin = coin - def confirm_dialog(self) -> Awaitable[Any]: - return layout.confirm_payment_request( + def confirm_dialog(self) -> Awaitable[bool]: + return layout.should_show_payment_request_details( self.payment_req, self.coin, self.amount_unit ) @@ -249,7 +249,7 @@ def confirm_decred_sstx_submission(output: TxOutput, coin: CoinInfo, amount_unit return (yield UiConfirmDecredSSTXSubmission(output, coin, amount_unit)) -def confirm_payment_request(payment_req: TxAckPaymentRequest, coin: CoinInfo, amount_unit: AmountUnit) -> Awaitable[Any]: # type: ignore [awaitable-is-generator] +def should_show_payment_request_details(payment_req: TxAckPaymentRequest, coin: CoinInfo, amount_unit: AmountUnit) -> Awaitable[bool]: # type: ignore [awaitable-is-generator] return (yield UiConfirmPaymentRequest(payment_req, coin, amount_unit)) diff --git a/core/src/apps/bitcoin/sign_tx/layout.py b/core/src/apps/bitcoin/sign_tx/layout.py index 73874063b..fdb55141e 100644 --- a/core/src/apps/bitcoin/sign_tx/layout.py +++ b/core/src/apps/bitcoin/sign_tx/layout.py @@ -18,8 +18,6 @@ from ..common import ( from ..keychain import address_n_to_name if TYPE_CHECKING: - from typing import Any - from trezor.enums import AmountUnit from trezor.messages import TxAckPaymentRequest, TxOutput from trezor.ui.layouts import LayoutType @@ -152,11 +150,11 @@ async def confirm_decred_sstx_submission( ) -async def confirm_payment_request( +async def should_show_payment_request_details( msg: TxAckPaymentRequest, coin: CoinInfo, amount_unit: AmountUnit, -) -> Any: +) -> bool: from trezor import wire memo_texts: list[str] = [] @@ -172,7 +170,7 @@ async def confirm_payment_request( assert msg.amount is not None - return await layouts.confirm_payment_request( + return await layouts.should_show_payment_request_details( msg.recipient_name, format_coin_amount(msg.amount, coin, amount_unit), memo_texts, diff --git a/core/src/trezor/ui/layouts/tr/__init__.py b/core/src/trezor/ui/layouts/tr/__init__.py index fd64888d0..510d35876 100644 --- a/core/src/trezor/ui/layouts/tr/__init__.py +++ b/core/src/trezor/ui/layouts/tr/__init__.py @@ -740,18 +740,19 @@ def tutorial(br_code: ButtonRequestType = BR_TYPE_OTHER) -> Awaitable[None]: ) -def confirm_payment_request( +async def should_show_payment_request_details( recipient_name: str, amount: str, memos: list[str], -) -> Awaitable[None]: +) -> bool: memos_str = "\n".join(memos) - return _placeholder_confirm( + await _placeholder_confirm( "confirm_payment_request", TR.send__title_confirm_sending, description=f"{amount} to\n{recipient_name}\n{memos_str}", br_code=ButtonRequestType.ConfirmOutput, ) + return False async def should_show_more( diff --git a/core/src/trezor/ui/layouts/tt/__init__.py b/core/src/trezor/ui/layouts/tt/__init__.py index 78fc75914..c865c9935 100644 --- a/core/src/trezor/ui/layouts/tt/__init__.py +++ b/core/src/trezor/ui/layouts/tt/__init__.py @@ -657,11 +657,16 @@ async def confirm_output( return -async def confirm_payment_request( +async def should_show_payment_request_details( recipient_name: str, amount: str, memos: list[str], ) -> bool: + """Return True if the user wants to show payment request details (they click a + special button) and False when the user wants to continue without showing details. + + Raises ActionCancelled if the user cancels. + """ result = await interact( RustLayout( trezorui2.confirm_with_info( @@ -676,12 +681,10 @@ async def confirm_payment_request( ButtonRequestType.ConfirmOutput, ) - # When user pressed INFO, returning False, which gets processed in higher function - # to differentiate it from CONFIRMED. Raising otherwise. if result is CONFIRMED: - return True - elif result is INFO: return False + elif result is INFO: + return True else: raise ActionCancelled