chore(core): move `show_pairing_dialog()` to `trezor.wire.thp.ui` module
What changed, and why it matters
This commit is a simple code cleanup: it moves the function that displays the on-screen pairing confirmation dialog from one internal file to another. The actual user-facing behavior and security checks remain exactly the same.
No security action needed; this is a non-functional refactor.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change refactors show_pairing_dialog() out of PairingContext in core/src/trezor/wire/thp/pairing_context.py into a standalone module function in core/src/trezor/wire/thp/ui.py. The caller in core/src/apps/thp/pairing.py is updated from await ctx.show_pairing_dialog() to await ui.show_pairing_dialog(ctx.host_name, ctx.app_name). The dialog still uses confirm_action() with the same br_name, title, and action string, and still requires explicit user approval before pairing proceeds.
Changed components
core/src/apps/thp/pairing.pycore/src/trezor/wire/thp/pairing_context.pycore/src/trezor/wire/thp/ui.pyInspect captured patch +13 / −12
diff --git a/core/src/apps/thp/pairing.py b/core/src/apps/thp/pairing.py
index 8c5dfbd7d..af1c7d327 100644
--- a/core/src/apps/thp/pairing.py
+++ b/core/src/apps/thp/pairing.py
@@ -118,7 +118,7 @@ async def handle_pairing_request(
ctx.host_name = message.host_name
ctx.app_name = message.app_name
- await ctx.show_pairing_dialog()
+ await ui.show_pairing_dialog(ctx.host_name, ctx.app_name)
await ctx.write(ThpPairingRequestApproved())
assert ThpSelectMethod.MESSAGE_WIRE_TYPE is not None
select_method_msg = await ctx.read(
diff --git a/core/src/trezor/wire/thp/pairing_context.py b/core/src/trezor/wire/thp/pairing_context.py
index 7d97b935b..bb3476d93 100644
--- a/core/src/trezor/wire/thp/pairing_context.py
+++ b/core/src/trezor/wire/thp/pairing_context.py
@@ -132,17 +132,6 @@ class PairingContext(Context):
raise DataError("Selected pairing method is not supported")
self.selected_method = selected_method
- async def show_pairing_dialog(self) -> None:
- from trezor.ui.layouts import confirm_action
-
- subject = ui._app_on_host(self.app_name, self.host_name)
- action_string = f"Allow {subject} to pair with this Trezor?"
- await confirm_action(
- br_name="thp_pairing_request",
- title="Before you continue",
- action=action_string,
- )
-
async def show_pairing_method_screen(
self, selected_method: ThpPairingMethod | None = None
) -> UiResult:
diff --git a/core/src/trezor/wire/thp/ui.py b/core/src/trezor/wire/thp/ui.py
index 31a93c324..47f41ce77 100644
--- a/core/src/trezor/wire/thp/ui.py
+++ b/core/src/trezor/wire/thp/ui.py
@@ -29,6 +29,18 @@ async def show_autoconnect_credential_confirmation_screen(
)
+async def show_pairing_dialog(host_name: str | None, app_name: str | None) -> None:
+ from trezor.ui.layouts import confirm_action
+
+ subject = _app_on_host(app_name, host_name)
+ action_string = f"Allow {subject} to pair with this Trezor?"
+ await confirm_action(
+ br_name="thp_pairing_request",
+ title="Before you continue",
+ action=action_string,
+ )
+
+
async def show_connection_dialog(host_name: str | None, app_name: str | None) -> None:
from trezor.ui.layouts import confirm_action
Why this scored 15/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.