test: rename CTransaction .sha256 -> .txid_int for consistency

Note that we unfortunately can't use a scripted diff here, as the same
property name is also used for `CBlockHeader`/`CBlock` instances.
This commit is contained in:
Sebastian Falbesoner
2025-05-05 16:00:44 +02:00
parent ce83924237
commit 81af4334e8
13 changed files with 114 additions and 114 deletions

View File

@@ -187,7 +187,7 @@ def create_tx_with_script(prevtx, n, script_sig=b"", *, amount, output_script=No
output_script = CScript()
tx = CTransaction()
assert n < len(prevtx.vout)
tx.vin.append(CTxIn(COutPoint(prevtx.sha256, n), script_sig, SEQUENCE_FINAL))
tx.vin.append(CTxIn(COutPoint(prevtx.txid_int, n), script_sig, SEQUENCE_FINAL))
tx.vout.append(CTxOut(amount, output_script))
return tx

View File

@@ -672,7 +672,7 @@ class CTransaction:
return hash256(self.serialize_without_witness())[::-1].hex()
@property
def sha256(self):
def txid_int(self):
"""Return txid (transaction hash without witness) as integer."""
return uint256_from_str(hash256(self.serialize_without_witness()))
@@ -804,7 +804,7 @@ class CBlock(CBlockHeader):
def calc_merkle_root(self):
hashes = []
for tx in self.vtx:
hashes.append(ser_uint256(tx.sha256))
hashes.append(ser_uint256(tx.txid_int))
return self.get_merkle_root(hashes)
def calc_witness_merkle_root(self):
@@ -996,7 +996,7 @@ class HeaderAndShortIDs:
[k0, k1] = self.get_siphash_keys()
for i in range(len(block.vtx)):
if i not in prefill_list:
tx_hash = block.vtx[i].sha256
tx_hash = block.vtx[i].txid_int
if use_witness:
tx_hash = block.vtx[i].wtxid_int
self.shortids.append(calculate_shortid(k0, k1, tx_hash))

View File

@@ -911,7 +911,7 @@ class P2PDataStore(P2PInterface):
with p2p_lock:
for tx in txs:
self.tx_store[tx.sha256] = tx
self.tx_store[tx.txid_int] = tx
reject_reason = [reject_reason] if reject_reason else []
with node.assert_debug_log(expected_msgs=reject_reason):