def calc_sha256(self): if self.sha256 is None or self.powHash is None: r = b"" r += struct.pack("<i", self.nVersion) r += ser_uint256(self.hashPrevBlock) r += ser_uint256(self.hashMerkleRoot) r += struct.pack("<I", self.nTime) r += struct.pack("<I", self.nBits) r += struct.pack("<I", self.nNonce) self.sha256 = uint256_from_str(hash256(r)) self.powHash = uint256_from_str(powhash.forHeader('neoscrypt', r)) self.hash = encode(hash256(r)[::-1], 'hex_codec').decode('ascii')
def neoscrypt (hexStr): rawData = codecs.decode (hexStr, 'hex_codec') rawHash = bytearray (powhash.forHeader ('neoscrypt', rawData)) rawHash.reverse () return codecs.encode (rawHash, 'hex_codec')