Ejemplo n.º 1
0
 def hash(self):
     writer = BinaryWriter(stream=bytearray())
     self.serialize_unsigned(writer)
     hash_data = writer._stream.getvalue()
     hash = hashlib.sha256(hashlib.sha256(hash_data).digest()).digest()
     writer.cleanup()
     return UInt256(data=hash)
Ejemplo n.º 2
0
 def to_array(self) -> bytearray:
     writer = BinaryWriter(stream=bytearray())
     self.serialize(writer)
     data = bytearray(writer._stream.getvalue())
     writer.cleanup()
     return data
Ejemplo n.º 3
0
 def test_var_string(self):
     data = "hello"
     b = BinaryWriter(stream=bytearray())
     b.write_var_string(data)
     self.assertTrue(data, b._stream.getvalue())