def testChecksum(self): data = [ ('test', '954d5a49'), ('pycoin', '58709a9f') ] for d, h in data: self.assertEquals(utils.checksum(d).encode('hex'), h) self.assertEquals(utils.doubleSha256(d)[:4].encode('hex'), h)
def serialize_message(self, message_type, payload): if not isinstance(payload, str): buf = BytesIO() payload.toWire(buf, self.version) payload = buf.getvalue() message = MAGIC message += message_type.ljust(12, chr(0)) message += struct.pack("<I", len(payload)) message += checksum(payload) message += payload return message
def serialize_message(self, message_type, payload): if not isinstance(payload, str): buf = BytesIO() payload.toWire(buf, self.version) payload = buf.getvalue() message = params['magic'] message += message_type.ljust(12, chr(0)) message += struct.pack("<I", len(payload)) message += checksum(payload) message += payload return message