From 6efbd1e1dcdfbe9eae2d5c22abab3ee616a75ff2 Mon Sep 17 00:00:00 2001 From: Cory Fields Date: Tue, 10 Jun 2025 21:13:59 +0000 Subject: [PATCH] refactor: CTransaction equality should consider witness data It is not at all obvious that two transactions with differing witness data should test equal to each other. There was only a single instance of a caller relying on this behavior, and that one appears accidental (left-over from before segwit). That caller (in the wallet) has been fixed. Change the definition of transaction equality (and inequality) to use the wtxid instead. --- src/primitives/transaction.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/primitives/transaction.h b/src/primitives/transaction.h index bf86562886a..ad817270949 100644 --- a/src/primitives/transaction.h +++ b/src/primitives/transaction.h @@ -360,12 +360,12 @@ public: friend bool operator==(const CTransaction& a, const CTransaction& b) { - return a.hash == b.hash; + return a.GetWitnessHash() == b.GetWitnessHash(); } friend bool operator!=(const CTransaction& a, const CTransaction& b) { - return a.hash != b.hash; + return !operator==(a, b); } std::string ToString() const;