refactor(core): inline THP `PairingContext` confirmation methods
What changed, and why it matters
This commit is a simple code cleanup: it removes two small helper methods from a class and replaces their calls with direct calls to the underlying user-interface functions. There is no change in behavior, no bug fix, and no security-related change.
No action needed; this is a non-security refactor.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change inlines PairingContext.show_connection_dialog() and PairingContext.show_autoconnect_credential_confirmation_screen() by calling ui.show_connection_dialog(...) and ui.show_autoconnect_credential_confirmation_screen(...) directly from apps/thp/pairing.py. The methods are removed from core/src/trezor/wire/thp/pairing_context.py. The arguments passed (host_name, app_name) are identical to what the removed wrappers used. This is a pure refactor with no functional or security impact.
Changed components
core/src/apps/thp/pairing.pycore/src/trezor/wire/thp/pairing_context.pyInspect captured patch +11 / −11
diff --git a/core/src/apps/thp/pairing.py b/core/src/apps/thp/pairing.py
index 61a37bf27..53970a55e 100644
--- a/core/src/apps/thp/pairing.py
+++ b/core/src/apps/thp/pairing.py
@@ -35,7 +35,13 @@ from trezor.wire.errors import (
SilentError,
UnexpectedMessage,
)
-from trezor.wire.thp import ChannelState, ThpError, crypto, get_enabled_pairing_methods
+from trezor.wire.thp import (
+ ChannelState,
+ ThpError,
+ crypto,
+ get_enabled_pairing_methods,
+ ui,
+)
from trezor.wire.thp.pairing_context import PairingContext
from .credential_manager import is_credential_autoconnect, issue_credential
@@ -195,7 +201,7 @@ async def handle_credential_phase(
raise DataError("Missing host/app name in credential")
if show_connection_dialog and not autoconnect:
- await ctx.show_connection_dialog()
+ await ui.show_connection_dialog(ctx.host_name, ctx.app_name)
while ThpCredentialRequest.is_type_of(message):
message = await _handle_credential_request(ctx, message)
@@ -425,7 +431,9 @@ async def _handle_credential_request(
"Cannot ask for autoconnect credential without a valid credential!"
)
- await ctx.show_autoconnect_credential_confirmation_screen() # TODO add device name
+ await ui.show_autoconnect_credential_confirmation_screen(
+ host_name=ctx.host_name, app_name=ctx.app_name
+ )
trezor_static_public_key = crypto.get_trezor_static_public_key()
credential_metadata = ThpCredentialMetadata(
diff --git a/core/src/trezor/wire/thp/pairing_context.py b/core/src/trezor/wire/thp/pairing_context.py
index 8520f08c2..7d97b935b 100644
--- a/core/src/trezor/wire/thp/pairing_context.py
+++ b/core/src/trezor/wire/thp/pairing_context.py
@@ -143,14 +143,6 @@ class PairingContext(Context):
action=action_string,
)
- async def show_connection_dialog(self) -> None:
- await ui.show_connection_dialog(self.host_name, self.app_name)
-
- async def show_autoconnect_credential_confirmation_screen(self) -> None:
- await ui.show_autoconnect_credential_confirmation_screen(
- self.host_name, self.app_name
- )
-
async def show_pairing_method_screen(
self, selected_method: ThpPairingMethod | None = None
) -> UiResult:
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.