Use DeepEquals for config file change detection
MODIFY
WalletWasabi.Backend/Config.cs
WalletWasabi.Backend/Config.cs
using NBitcoin;
using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
using System;
using System.IO;
using System.Net;
@@ -173,43 +174,10 @@ namespace WalletWasabi.Backend
}
string jsonString = await File.ReadAllTextAsync(FilePath, Encoding.UTF8);
- var config = JsonConvert.DeserializeObject<Config>(jsonString);
-
- if (Network != config.Network)
- {
- return true;
- }
- if (BitcoinRpcConnectionString != config.BitcoinRpcConnectionString)
- {
- return true;
- }
-
- if (!MainNetBitcoinCoreHost.Equals(config.MainNetBitcoinCoreHost, StringComparison.OrdinalIgnoreCase))
- {
- return true;
- }
- if (!TestNetBitcoinCoreHost.Equals(config.TestNetBitcoinCoreHost, StringComparison.OrdinalIgnoreCase))
- {
- return true;
- }
- if (!RegTestBitcoinCoreHost.Equals(config.RegTestBitcoinCoreHost, StringComparison.OrdinalIgnoreCase))
- {
- return true;
- }
- if (MainNetBitcoinCorePort != config.MainNetBitcoinCorePort)
- {
- return true;
- }
- if (TestNetBitcoinCorePort != config.TestNetBitcoinCorePort)
- {
- return true;
- }
- if (RegTestBitcoinCorePort != config.RegTestBitcoinCorePort)
- {
- return true;
- }
+ var newConfig = JsonConvert.DeserializeObject<JObject>(jsonString);
+ var currentConfig = JObject.FromObject(this);
- return false;
+ return !JToken.DeepEquals(newConfig, currentConfig);
}
/// <inheritdoc />

MODIFY
WalletWasabi.Gui/Config.cs
WalletWasabi.Gui/Config.cs
using NBitcoin;
using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
using System;
using System.IO;
using System.Net;
@@ -421,95 +422,10 @@ namespace WalletWasabi.Gui
}
string jsonString = await File.ReadAllTextAsync(FilePath, Encoding.UTF8);
- var config = JsonConvert.DeserializeObject<Config>(jsonString);
-
- if (Network != config.Network)
- {
- return true;
- }
-
- if (!MainNetBackendUriV3.Equals(config.MainNetBackendUriV3, StringComparison.OrdinalIgnoreCase))
- {
- return true;
- }
- if (!TestNetBackendUriV3.Equals(config.TestNetBackendUriV3, StringComparison.OrdinalIgnoreCase))
- {
- return true;
- }
- if (!MainNetFallbackBackendUri.Equals(config.MainNetFallbackBackendUri, StringComparison.OrdinalIgnoreCase))
- {
- return true;
- }
- if (!TestNetFallbackBackendUri.Equals(config.TestNetFallbackBackendUri, StringComparison.OrdinalIgnoreCase))
- {
- return true;
- }
- if (!RegTestBackendUriV3.Equals(config.RegTestBackendUriV3, StringComparison.OrdinalIgnoreCase))
- {
- return true;
- }
- if (UseTor != config.UseTor)
- {
- return true;
- }
-
- if (!TorHost.Equals(config.TorHost, StringComparison.Ordinal))
- {
- return true;
- }
- if (TorSocks5Port != config.TorSocks5Port)
- {
- return true;
- }
-
- if (!MainNetBitcoinCoreHost.Equals(config.MainNetBitcoinCoreHost, StringComparison.OrdinalIgnoreCase))
- {
- return true;
- }
- if (!TestNetBitcoinCoreHost.Equals(config.TestNetBitcoinCoreHost, StringComparison.OrdinalIgnoreCase))
- {
- return true;
- }
- if (!RegTestBitcoinCoreHost.Equals(config.RegTestBitcoinCoreHost, StringComparison.OrdinalIgnoreCase))
- {
- return true;
- }
- if (MainNetBitcoinCorePort != config.MainNetBitcoinCorePort)
- {
- return true;
- }
- if (TestNetBitcoinCorePort != config.TestNetBitcoinCorePort)
- {
- return true;
- }
- if (RegTestBitcoinCorePort != config.RegTestBitcoinCorePort)
- {
- return true;
- }
-
- if (MixUntilAnonymitySet != config.MixUntilAnonymitySet)
- {
- return true;
- }
- if (PrivacyLevelSome != config.PrivacyLevelSome)
- {
- return true;
- }
- if (PrivacyLevelFine != config.PrivacyLevelFine)
- {
- return true;
- }
- if (PrivacyLevelStrong != config.PrivacyLevelStrong)
- {
- return true;
- }
-
- if (DustThreshold != config.DustThreshold)
- {
- return true;
- }
+ var newConfig = JsonConvert.DeserializeObject<JObject>(jsonString);
+ var currentConfig = JObject.FromObject(this);
- return false;
+ return !JToken.DeepEquals(newConfig, currentConfig);
}
/// <inheritdoc />

MODIFY
WalletWasabi/Models/ChaumianCoinJoin/CcjRoundConfig.cs
WalletWasabi/Models/ChaumianCoinJoin/CcjRoundConfig.cs
using NBitcoin;
using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
using System;
using System.IO;
using System.Text;
@@ -157,62 +158,10 @@ namespace WalletWasabi.Models.ChaumianCoinJoin
}
string jsonString = await File.ReadAllTextAsync(FilePath, Encoding.UTF8);
- var config = JsonConvert.DeserializeObject<CcjRoundConfig>(jsonString);
-
- if (Denomination != config.Denomination)
- {
- return true;
- }
- if (ConfirmationTarget != config.ConfirmationTarget)
- {
- return true;
- }
- if (ConfirmationTargetReductionRate != config.ConfirmationTargetReductionRate)
- {
- return true;
- }
- if (CoordinatorFeePercent != config.CoordinatorFeePercent)
- {
- return true;
- }
- if (AnonymitySet != config.AnonymitySet)
- {
- return true;
- }
- if (InputRegistrationTimeout != config.InputRegistrationTimeout)
- {
- return true;
- }
- if (ConnectionConfirmationTimeout != config.ConnectionConfirmationTimeout)
- {
- return true;
- }
- if (OutputRegistrationTimeout != config.OutputRegistrationTimeout)
- {
- return true;
- }
- if (SigningTimeout != config.SigningTimeout)
- {
- return true;
- }
- if (DosSeverity != config.DosSeverity)
- {
- return true;
- }
- if (DosDurationHours != config.DosDurationHours)
- {
- return true;
- }
- if (DosNoteBeforeBan != config.DosNoteBeforeBan)
- {
- return true;
- }
- if (MaximumMixingLevelCount != config.MaximumMixingLevelCount)
- {
- return true;
- }
+ var newConfig = JsonConvert.DeserializeObject<JObject>(jsonString);
+ var currentConfig = JObject.FromObject(this);
- return false;
+ return !JToken.DeepEquals(newConfig, currentConfig);
}
/// <inheritdoc />

Use DeepEquals for config file change detection