Skip to content

Commit 76589f9

Browse files
icookpetertodd
authored andcommitted
Properly encode bytes for printing
1 parent 4c329ef commit 76589f9

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

bitcoin/messages.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import time
1616
import random
1717
import sys
18-
from binascii import hexlify
18+
1919
if sys.version > '3':
2020
import io
2121
else:
@@ -71,7 +71,7 @@ def stream_deserialize(cls, f, params=MainParams(), protover=PROTO_VERSION):
7171
# check magic
7272
if recvbuf[:4] != params.MESSAGE_START:
7373
raise ValueError("Invalid message start '%s', expected '%s'" %
74-
(recvbuf[:4], params.MESSAGE_START))
74+
(b2x(recvbuf[:4]), b2x(params.MESSAGE_START)))
7575

7676
# remaining header fields: command, msg length, checksum
7777
command = recvbuf[4:4+12].split(b"\x00", 1)[0]
@@ -271,7 +271,7 @@ def msg_ser(self, f):
271271
f.write(self.hashstop)
272272

273273
def __repr__(self):
274-
return "msg_getblocks(locator=%s hashstop=%s)" % (repr(self.locator), hexlify(self.hashstop))
274+
return "msg_getblocks(locator=%s hashstop=%s)" % (repr(self.locator), b2x(self.hashstop))
275275

276276

277277
class msg_getheaders(MsgSerializable):
@@ -294,7 +294,7 @@ def msg_ser(self, f):
294294
f.write(self.hashstop)
295295

296296
def __repr__(self):
297-
return "msg_getheaders(locator=%s hashstop=%s)" % (repr(self.locator), hexlify(self.hashstop))
297+
return "msg_getheaders(locator=%s hashstop=%s)" % (repr(self.locator), b2x(self.hashstop))
298298

299299

300300
class msg_headers(MsgSerializable):

0 commit comments

Comments
 (0)