mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 15:09:59 +01:00
Merge bitcoin/bitcoin#28107: util: Type-safe transaction identifiers
940a49978cUse type-safe txid types in orphanage (dergoegge)ed70e65016Introduce types for txids & wtxids (dergoegge)cdb14d79e8[net processing] Use HasWitness over comparing (w)txids (dergoegge) Pull request description: We currently have two different identifiers for transactions: `txid` (refering to the hash of a transaction without witness data) and `wtxid` (referring to the hash of a transaction including witness data). Both are typed as `uint256` which could lead to type-safety bugs in which one transaction identifier type is passed where the other would be expected. This PR introduces explicit `Txid` and `Wtxid` types that (if used) would cause compilation errors for such type confusion bugs. (Only the orphanage is converted to use these types in this PR) ACKs for top commit: achow101: ACK940a49978cstickies-v: ACK940a49978chebasto: ACK940a49978c, I have reviewed the code and it looks OK. instagibbs: re-ACK940a49978cBrandonOdiwuor: re-ACK940a49978cglozow: reACK940a49978cTree-SHA512: 55298d1c2bb82b7a6995e96e554571c22eaf4a89fb2a4d7a236d70e0f625e8cca62ff2490e1c179c47bd93153fe6527b56870198f026f5ee7753d64d7a424c92
This commit is contained in:
@@ -618,7 +618,7 @@ private:
|
||||
|
||||
const CTransactionRef& m_ptx;
|
||||
/** Txid. */
|
||||
const uint256& m_hash;
|
||||
const Txid& m_hash;
|
||||
TxValidationState m_state;
|
||||
/** A temporary cache containing serialized transaction data for signature verification.
|
||||
* Reused across PolicyScriptChecks and ConsensusScriptChecks. */
|
||||
@@ -1870,7 +1870,7 @@ bool CheckInputScripts(const CTransaction& tx, TxValidationState& state,
|
||||
// transaction).
|
||||
uint256 hashCacheEntry;
|
||||
CSHA256 hasher = g_scriptExecutionCacheHasher;
|
||||
hasher.Write(tx.GetWitnessHash().begin(), 32).Write((unsigned char*)&flags, sizeof(flags)).Finalize(hashCacheEntry.begin());
|
||||
hasher.Write(UCharCast(tx.GetWitnessHash().begin()), 32).Write((unsigned char*)&flags, sizeof(flags)).Finalize(hashCacheEntry.begin());
|
||||
AssertLockHeld(cs_main); //TODO: Remove this requirement by making CuckooCache not require external locks
|
||||
if (g_scriptExecutionCache.contains(hashCacheEntry, !cacheFullScriptStore)) {
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user