Remove tx == stx
MODIFY
WalletWasabi.Tests/UnitTests/SmartTransactionTests.cs
WalletWasabi.Tests/UnitTests/SmartTransactionTests.cs
@@ -63,12 +63,9 @@ namespace WalletWasabi.Tests.UnitTests
Assert.Equal(smartTx.Height, deserialized.Height);
Assert.Equal(deserialized, deserialized2);
Assert.Equal(deserialized, deserialized3);
- Assert.True(smartTx.Transaction == deserialized3);
- Assert.True(smartTx.Equals(deserialized2.Transaction));
+
object sto = deserialized;
Assert.True(smartTx.Equals(sto));
- Assert.True(smartTx.Equals(deserialized.Transaction));
- // ToDo: Assert.True(smartTx.Equals(to));
var serializedWithoutLabel = "{\"Transaction\":\"02000000040aa8d0af84518df6e3a60c5bb19d9c3fcc3dc6e26b2f2449e8d7bf8d3fe84b87010000006a473044022018dfe9216c1209dd6c2b6c1607dbac4e499c1fce4878bc7d5d83fccbf3e24c9402202cac351c9c6a2b5eef338cbf0ec000d8de1c05e96a904cbba2b9e6ffc2d4e19501210364cc39da1091b1a9c12ec905a14a9e8478f951f7a1accdabeb40180533f2eaa5feffffff112c07d0f5e0617d720534f0b2b84dc0d5b7314b358c3ab338823b9e5bfbddf5010000006b483045022100ec155e7141e74661ee511ae980150a6c89261f31070999858738369afc28f2b6022006230d2aa24fac110b74ef15b84371486cf76c539b335a253c14462447912a300121020c2f41390f031d471b22abdb856e6cdbe0f4d74e72c197469bfd54e5a08f7e67feffffff38e799b8f6cf04fd021a9b135cdcd347da7aac4fd8bb8d0da9316a9fb228bb6e000000006b483045022100fc1944544a3f96edd8c8a9795c691e2725612b5ab2e1c999be11a2a4e3f841f1022077b2e088877829edeada0c707a9bb577aa79f26dafacba3d1d2d047f52524296012102e6015963dff9826836400cf8f45597c0705757d5dcdc6bf734f661c7dab89e69feffffff64c3f0377e86625123f2f1ee229319ed238e8ca8b7dda5bc080a2c5ecb984629000000006a47304402204233a90d6296182914424fd2901e16e6f5b13b451b67b0eec25a5eaacc5033c902203d8a13ef0b494c12009663475458e51da6bd55cc67688264230ece81d3eeca24012102f806d7152da2b52c1d9ad928e4a6253ccba080a5b9ab9efdd80e37274ac67f9bfeffffff0290406900000000001976a91491ac4e49b66f845180d98d8f8be6121588be6e3b88ac52371600000000001976a9142f44ed6749e8c84fd476e4440741f7e6f55542fa88acadd30700\",\"Height\":\"2147483646\"}";
var deserializedWithoutLabel = JsonConvert.DeserializeObject<SmartTransaction>(serializedWithoutLabel);

MODIFY
WalletWasabi/Models/SmartTransaction.cs
WalletWasabi/Models/SmartTransaction.cs
@@ -10,7 +10,7 @@ using WalletWasabi.Logging;
namespace WalletWasabi.Models
{
[JsonObject(MemberSerialization.OptIn)]
- public class SmartTransaction : IEquatable<SmartTransaction>, IEquatable<Transaction>
+ public class SmartTransaction : IEquatable<SmartTransaction>
{
#region Members
@@ -197,55 +197,18 @@ namespace WalletWasabi.Models
#endregion LineSerialization
- #region Equality
+ #region EqualityAndComparison
- public bool Equals(SmartTransaction other) => GetHash().Equals(other?.GetHash());
+ public override bool Equals(object obj) => obj is SmartTransaction tx && this == tx;
- public bool Equals(Transaction other) => GetHash().Equals(other?.GetHash());
-
- public override bool Equals(object obj) =>
- obj is SmartTransaction transaction && this == transaction;
+ public bool Equals(SmartTransaction other) => this == other;
public override int GetHashCode() => GetHash().GetHashCode();
- public static bool operator !=(SmartTransaction tx1, SmartTransaction tx2) => !(tx1 == tx2);
-
- public static bool operator ==(SmartTransaction tx1, SmartTransaction tx2)
- {
- bool rc;
-
- if (ReferenceEquals(tx1, tx2))
- {
- rc = true;
- }
- else if (tx1 is null || tx2 is null)
- {
- rc = false;
- }
- else
- {
- rc = tx1.GetHash().Equals(tx2.GetHash());
- }
-
- return rc;
- }
-
- public static bool operator ==(Transaction tx1, SmartTransaction tx2)
- {
- bool rc = tx1 is null || tx2 is null ? false : tx1.GetHash().Equals(tx2.GetHash());
- return rc;
- }
-
- public static bool operator !=(Transaction tx1, SmartTransaction tx2) => !(tx1 == tx2);
-
- public static bool operator ==(SmartTransaction tx1, Transaction tx2)
- {
- bool rc = tx1 is null || tx2 is null ? false : tx1.GetHash().Equals(tx2.GetHash());
- return rc;
- }
+ public static bool operator ==(SmartTransaction x, SmartTransaction y) => y?.GetHash() == x?.GetHash();
- public static bool operator !=(SmartTransaction tx1, Transaction tx2) => !(tx1 == tx2);
+ public static bool operator !=(SmartTransaction x, SmartTransaction y) => !(x == y);
- #endregion Equality
+ #endregion EqualityAndComparison
}
}

Remove tx == stx