mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-06-03 22:58:46 +00:00
chore(python): set CodeEntry as default pairing method when not using TrezorClientDebugLink
This commit is contained in:
parent
e690b2d4c7
commit
a8ef380d0f
@ -63,7 +63,7 @@ class TrezorClient:
|
|||||||
_last_active_session: SessionV1 | None = None
|
_last_active_session: SessionV1 | None = None
|
||||||
|
|
||||||
_session_id_counter: int = 0
|
_session_id_counter: int = 0
|
||||||
|
_default_pairing_method: int = messages.ThpPairingMethod.CodeEntry
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
transport: Transport,
|
transport: Transport,
|
||||||
@ -101,10 +101,12 @@ class TrezorClient:
|
|||||||
else:
|
else:
|
||||||
raise Exception("Unknown protocol version")
|
raise Exception("Unknown protocol version")
|
||||||
|
|
||||||
def do_pairing(self) -> None:
|
def do_pairing(self, pairing_method: int | None = None) -> None:
|
||||||
from .transport.session import SessionV2
|
from .transport.session import SessionV2
|
||||||
|
|
||||||
assert self.protocol_version == ProtocolVersion.V2
|
assert self.protocol_version == ProtocolVersion.V2
|
||||||
|
if pairing_method is None:
|
||||||
|
pairing_method = self._default_pairing_method
|
||||||
session = SessionV2(client=self, id=b"\x00")
|
session = SessionV2(client=self, id=b"\x00")
|
||||||
session.call(
|
session.call(
|
||||||
messages.ThpPairingRequest(host_name="Trezorlib"),
|
messages.ThpPairingRequest(host_name="Trezorlib"),
|
||||||
@ -112,9 +114,7 @@ class TrezorClient:
|
|||||||
skip_firmware_version_check=True,
|
skip_firmware_version_check=True,
|
||||||
)
|
)
|
||||||
session.call(
|
session.call(
|
||||||
messages.ThpSelectMethod(
|
messages.ThpSelectMethod(selected_pairing_method=pairing_method),
|
||||||
selected_pairing_method=messages.ThpPairingMethod.SkipPairing
|
|
||||||
),
|
|
||||||
expect=messages.ThpEndResponse,
|
expect=messages.ThpEndResponse,
|
||||||
skip_firmware_version_check=True,
|
skip_firmware_version_check=True,
|
||||||
)
|
)
|
||||||
|
@ -1097,7 +1097,7 @@ class TrezorClientDebugLink(TrezorClient):
|
|||||||
# and know the supported debug capabilities
|
# and know the supported debug capabilities
|
||||||
if self.protocol_version is ProtocolVersion.V2:
|
if self.protocol_version is ProtocolVersion.V2:
|
||||||
assert isinstance(self.protocol, ProtocolV2Channel)
|
assert isinstance(self.protocol, ProtocolV2Channel)
|
||||||
self.do_pairing()
|
self.do_pairing(pairing_method=messages.ThpPairingMethod.SkipPairing)
|
||||||
# self.protocol = self.protocol.get_channel()
|
# self.protocol = self.protocol.get_channel()
|
||||||
self.debug.model = self.model
|
self.debug.model = self.model
|
||||||
self.debug.version = self.version
|
self.debug.version = self.version
|
||||||
|
Loading…
Reference in New Issue
Block a user