Skip to content

Commit 6efbd1e

Browse files
committed
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.
1 parent cbf9b2d commit 6efbd1e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/primitives/transaction.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,12 +360,12 @@ class CTransaction
360360

361361
friend bool operator==(const CTransaction& a, const CTransaction& b)
362362
{
363-
return a.hash == b.hash;
363+
return a.GetWitnessHash() == b.GetWitnessHash();
364364
}
365365

366366
friend bool operator!=(const CTransaction& a, const CTransaction& b)
367367
{
368-
return a.hash != b.hash;
368+
return !operator==(a, b);
369369
}
370370

371371
std::string ToString() const;

0 commit comments

Comments
 (0)