#!/usr/bin/env python3 from pyblake2 import blake2b import struct from transaction import ( MAX_MONEY, OVERWINTER_TX_VERSION, Script, Transaction, ) from tv_output import render_args, render_tv from tv_rand import Rand SIGHASH_ALL = 1 SIGHASH_NONE = 2 SIGHASH_SINGLE = 3 SIGHASH_ANYONECANPAY = 0x80 NOT_AN_INPUT = -1 # For portability of the test vectors def getHashPrevouts(tx): digest = blake2b(digest_size=32, person=b'ZcashPrevoutHash') for x in tx.vin: digest.update(bytes(x.prevout)) return digest.digest() def getHashSequence(tx): digest = blake2b(digest_size=32, person=b'ZcashSequencHash') for x in tx.vin: digest.update(struct.pack(' 0: hashJoinSplits = getHashJoinSplits(tx) digest = blake2b( digest_size=32, person=b'ZcashSigHash' + struct.pack(''), ('scriptCode', 'Vec'), ('nIn', 'u32'), ('nHashType', 'u32'), ('amount', 'u64'), ('consensusBranchId', 'u32'), ('sighash', '[u8; 32]'), ), test_vectors, ) if __name__ == '__main__': main()