Skip to content

Commit

Permalink
chore(python): add handshake hash to channelData
Browse files Browse the repository at this point in the history
[no changelog]
  • Loading branch information
M1nd3r committed Jan 31, 2025
1 parent 1102993 commit 9203649
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion python/src/trezorlib/transport/thp/channel_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def __init__(
self.nonce_response: int = nonce_response
self.sync_bit_receive: int = sync_bit_receive
self.sync_bit_send: int = sync_bit_send
self.handshake_hash: bytes = handshake_hash
self.handshake_hash: str = hexlify(handshake_hash).decode()

def to_dict(self):
return {
Expand Down
2 changes: 1 addition & 1 deletion python/src/trezorlib/transport/thp/channel_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def dict_to_channel_data(dict: t.Dict) -> ChannelData:
nonce_response=dict["nonce_response"],
sync_bit_send=dict["sync_bit_send"],
sync_bit_receive=dict["sync_bit_receive"],
handshake_hash=dict["handshake_hash"],
handshake_hash=bytes.fromhex(dict["handshake_hash"]),
)


Expand Down
3 changes: 2 additions & 1 deletion python/src/trezorlib/transport/thp/protocol_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class ProtocolV2(ProtocolAndChannel):
nonce_response: int
sync_bit_send: int
sync_bit_receive: int
handshake_hash: bytes

_has_valid_channel: bool = False
_features: messages.Features | None = None
Expand All @@ -81,7 +82,7 @@ def __init__(
self.nonce_response = channel_data.nonce_response
self.sync_bit_receive = channel_data.sync_bit_receive
self.sync_bit_send = channel_data.sync_bit_send
self.handshake_hash: bytes = b""
self.handshake_hash = bytes.fromhex(channel_data.handshake_hash)
self._has_valid_channel = True

def get_channel(self, helper_debug: DebugLink | None = None) -> ProtocolV2:
Expand Down

0 comments on commit 9203649

Please sign in to comment.