@@ -152,14 +152,14 @@ def serialize(self):
152
152
result += int_to_little_endian (self .receiver_services , 8 )
153
153
# IPV4 is 10 00 bytes and 2 ff bytes then receiver ip
154
154
result += b'\x00 ' * 10 + b'\xff \xff ' + self .receiver_ip
155
- # receiver port is 2 bytes, little endian should be 0
156
- result += int_to_little_endian ( self .receiver_port , 2 )
155
+ # receiver port is 2 bytes, big endian
156
+ result += self .receiver_port . to_bytes ( 2 , 'big' )
157
157
# sender services is 8 bytes little endian
158
158
result += int_to_little_endian (self .sender_services , 8 )
159
159
# IPV4 is 10 00 bytes and 2 ff bytes then sender ip
160
160
result += b'\x00 ' * 10 + b'\xff \xff ' + self .sender_ip
161
- # sender port is 2 bytes, little endian should be 0
162
- result += int_to_little_endian ( self .sender_port , 2 )
161
+ # sender port is 2 bytes, big endian
162
+ result += self .sender_port . to_bytes ( 2 , 'big' )
163
163
# nonce should be 8 bytes
164
164
result += self .nonce
165
165
# useragent is a variable string, so varint first
@@ -179,7 +179,7 @@ class VersionMessageTest(TestCase):
179
179
180
180
def test_serialize (self ):
181
181
v = VersionMessage (timestamp = 0 , nonce = b'\x00 ' * 8 )
182
- self .assertEqual (v .serialize ().hex (), '7f11010000000000000000000000000000000000000000000000000000000000000000000000ffff000000008d20000000000000000000000000000000000000ffff000000008d200000000000000000182f70726f6772616d6d696e67626974636f696e3a302e312f0000000000 ' )
182
+ self .assertEqual (v .serialize ().hex (), '7f11010000000000000000000000000000000000000000000000000000000000000000000000ffff00000000208d000000000000000000000000000000000000ffff00000000208d0000000000000000182f70726f6772616d6d696e67626974636f696e3a302e312f0000000000 ' )
183
183
184
184
185
185
class VerAckMessage :
0 commit comments