(txTo, spent_utxos, hash_type, genesis_hash, input_index = 0, scriptpath = False, script = CScript(), codeseparator_pos = -1, annex = None, leaf_ver = LEAF_VERSION_TAPSCRIPT)
| 929 | return sha256(b"".join(o.serialize() for o in txTo.vout)) |
| 930 | |
| 931 | def TaprootSignatureMsg(txTo, spent_utxos, hash_type, genesis_hash, input_index = 0, scriptpath = False, script = CScript(), codeseparator_pos = -1, annex = None, leaf_ver = LEAF_VERSION_TAPSCRIPT): |
| 932 | assert (len(txTo.vin) == len(spent_utxos)) |
| 933 | assert (input_index < len(txTo.vin)) |
| 934 | out_type = SIGHASH_ALL if hash_type == 0 else hash_type & 3 |
| 935 | in_type = hash_type & SIGHASH_ANYONECANPAY |
| 936 | spk = spent_utxos[input_index].scriptPubKey |
| 937 | ss = b"" |
| 938 | ss += ser_uint256(genesis_hash) |
| 939 | ss += ser_uint256(genesis_hash) |
| 940 | ss += bytes([hash_type]) # hash_type |
| 941 | ss += struct.pack("<i", txTo.nVersion) |
| 942 | ss += struct.pack("<I", txTo.nLockTime) |
| 943 | if in_type != SIGHASH_ANYONECANPAY: |
| 944 | ss += sha256(b"".join(struct.pack("B", ((not i.assetIssuance.isNull()) << 7) + (i.m_is_pegin << 6)) for i in txTo.vin)) |
| 945 | ss += BIP341_sha_prevouts(txTo) |
| 946 | ss += BIP341_sha_amounts(spent_utxos) |
| 947 | ss += BIP341_sha_scriptpubkeys(spent_utxos) |
| 948 | ss += BIP341_sha_sequences(txTo) |
| 949 | ss += sha256(b"".join(i.assetIssuance.taphash_asset_issuance_serialize() for i in txTo.vin)) |
| 950 | ss += sha256(b"".join(iwit.serialize_issuance_proofs() for iwit in txTo.wit.vtxinwit)) |
| 951 | if out_type == SIGHASH_ALL: |
| 952 | ss += BIP341_sha_outputs(txTo) |
| 953 | ss += sha256(b"".join(owit.serialize() for owit in txTo.wit.vtxoutwit)) |
| 954 | spend_type = 0 |
| 955 | if annex is not None: |
| 956 | spend_type |= 1 |
| 957 | if (scriptpath): |
| 958 | spend_type |= 2 |
| 959 | ss += bytes([spend_type]) |
| 960 | |
| 961 | if in_type == SIGHASH_ANYONECANPAY: |
| 962 | ss += struct.pack("B", ((not txTo.vin[input_index].assetIssuance.isNull()) << 7) + (txTo.vin[input_index].m_is_pegin << 6)) |
| 963 | ss += txTo.vin[input_index].prevout.serialize() |
| 964 | ss += spent_utxos[input_index].nAsset.serialize() |
| 965 | ss += spent_utxos[input_index].nValue.serialize() |
| 966 | ss += ser_string(spk) |
| 967 | ss += struct.pack("<I", txTo.vin[input_index].nSequence) |
| 968 | if txTo.vin[input_index].assetIssuance.isNull(): |
| 969 | ss += b'\x00' |
| 970 | else: |
| 971 | ss += txTo.vin[input_index].assetIssuance.serialize() |
| 972 | ss += sha256(txTo.wit.vtxinwit[input_index].serialize_issuance_proofs()) |
| 973 | else: |
| 974 | ss += struct.pack("<I", input_index) |
| 975 | if (spend_type & 1): |
| 976 | ss += sha256(ser_string(annex)) |
| 977 | if out_type == SIGHASH_SINGLE: |
| 978 | if input_index < len(txTo.vout): |
| 979 | ss += sha256(txTo.vout[input_index].serialize()) |
| 980 | ss += sha256(txTo.wit.vtxoutwit[input_index].serialize()) |
| 981 | else: |
| 982 | # Why do we have a case for in > len ? |
| 983 | # Maybe useful in testing. C++ code should never reach here |
| 984 | ss += bytes(0 for _ in range(32)) |
| 985 | ss += bytes(0 for _ in range(32)) |
| 986 | if (scriptpath): |
| 987 | ss += TaggedHash("TapLeaf/elements", bytes([leaf_ver]) + ser_string(script)) |
| 988 | ss += bytes([0]) |
no test coverage detected