# (c) Copyright 2026 by Coinkite Inc. This file is covered by license found in COPYING-CC. # # Bitcoin transaction signature hash helpers for tests. # import copy import hashlib import struct from ctransaction import hash256 from serialize import ser_string from pysecp256k1 import tagged_sha256 SIGHASH_DEFAULT = 0 SIGHASH_ALL = 1 def legacy_sighash(tx, in_idx, script_code, sighash=SIGHASH_ALL): tmp = copy.deepcopy(tx) for txin in tmp.vin: txin.scriptSig = b'' tmp.vin[in_idx].scriptSig = script_code return hash256(tmp.serialize_without_witness() + struct.pack('