Read obsolate config values and set new ones according,
MODIFY
WalletWasabi.Gui/Config.cs
WalletWasabi.Gui/Config.cs
@@ -50,7 +50,7 @@ namespace WalletWasabi.Gui
[JsonProperty(PropertyName = "MainNetBitcoinP2pEndPoint")]
[JsonConverter(typeof(EndPointJsonConverter), Constants.DefaultMainNetBintcoinP2pPort)]
- public EndPoint MainNetBitcoinP2PEndPoint { get; internal set; }
+ public EndPoint MainNetBitcoinP2pEndPoint { get; internal set; }
[JsonProperty(PropertyName = "TestNetBitcoinP2pEndPoint")]
[JsonConverter(typeof(EndPointJsonConverter), Constants.DefaultTestNetBintcoinP2pPort)]
@@ -342,10 +342,62 @@ namespace WalletWasabi.Gui
await ToFileAsync();
}
+ private EndPoint StringToEndPoint(string endPointString, int port = 0)
+ {
+ if (IPAddress.TryParse(endPointString, out IPAddress ipAddress))
+ {
+ return new IPEndPoint(ipAddress, port);
+ }
+
+ return new DnsEndPoint(endPointString, port);
+ }
+
public async Task LoadFileAsync()
{
string jsonString = await File.ReadAllTextAsync(FilePath, Encoding.UTF8);
+ var res = JsonConvert.DeserializeObject<JObject>(jsonString);
+
+ if (res.TryGetValue("TorHost", out JToken jTorHost))
+ {
+ int port = Constants.DefaultTorSocksPort; //TODO: check this if it is OK
+ if (res.TryGetValue("TorSocks5Port", out JToken jTorSocks5Port))
+ {
+ port = int.Parse(jTorSocks5Port.ToString());
+ }
+ TorSocks5EndPoint = StringToEndPoint(jTorHost.ToString(), port);
+ }
+
+ if (res.TryGetValue("MainNetBitcoinCoreHost", out JToken jMainNetBitcoinCoreHost))
+ {
+ int port = Constants.DefaultMainNetBintcoinP2pPort;
+ if (res.TryGetValue("MainNetBitcoinCorePort", out JToken jMainNetBitcoinCorePort))
+ {
+ port = int.Parse(jMainNetBitcoinCorePort.ToString());
+ }
+ MainNetBitcoinP2pEndPoint = StringToEndPoint(jMainNetBitcoinCoreHost.ToString(), port);
+ }
+
+ if (res.TryGetValue("TestNetBitcoinCoreHost", out JToken jTestNetBitcoinCoreHost))
+ {
+ int port = Constants.DefaultTestNetBintcoinP2pPort;
+ if (res.TryGetValue("TestNetBitcoinCorePort", out JToken jTestNetBitcoinCorePort))
+ {
+ port = int.Parse(jTestNetBitcoinCorePort.ToString());
+ }
+ TestNetBitcoinP2pEndPoint = StringToEndPoint(jTestNetBitcoinCoreHost.ToString(), port);
+ }
+
+ if (res.TryGetValue("RegTestBitcoinCoreHost", out JToken jRegTestBitcoinCoreHost))
+ {
+ int port = Constants.DefaultRegTestBintcoinP2pPort;
+ if (res.TryGetValue("RegTestBitcoinCorePort", out JToken jRegTestBitcoinCorePort))
+ {
+ port = int.Parse(jRegTestBitcoinCorePort.ToString());
+ }
+ RegTestBitcoinP2pEndPoint = StringToEndPoint(jRegTestBitcoinCoreHost.ToString(), port);
+ }
+
var config = JsonConvert.DeserializeObject<Config>(jsonString);
Network = config.Network ?? Network;

Read obsolate config values and set new ones according,