Add P2P settings to backend config.
MODIFY
WalletWasabi.Backend/Config.cs
WalletWasabi.Backend/Config.cs
using Newtonsoft.Json;
using System;
using System.IO;
+using System.Net;
using System.Text;
using System.Threading.Tasks;
using WalletWasabi.Helpers;
@@ -27,6 +28,24 @@ namespace WalletWasabi.Backend
[JsonProperty(PropertyName = "BitcoinRpcPassword")]
public string BitcoinRpcPassword { get; private set; }
+ [JsonProperty(PropertyName = "MainNetBitcoinCoreHost")]
+ public string MainNetBitcoinCoreHost { get; internal set; }
+
+ [JsonProperty(PropertyName = "TestNetBitcoinCoreHost")]
+ public string TestNetBitcoinCoreHost { get; internal set; }
+
+ [JsonProperty(PropertyName = "RegTestBitcoinCoreHost")]
+ public string RegTestBitcoinCoreHost { get; internal set; }
+
+ [JsonProperty(PropertyName = "MainNetBitcoinCorePort")]
+ public int? MainNetBitcoinCorePort { get; internal set; }
+
+ [JsonProperty(PropertyName = "TestNetBitcoinCorePort")]
+ public int? TestNetBitcoinCorePort { get; internal set; }
+
+ [JsonProperty(PropertyName = "RegTestBitcoinCorePort")]
+ public int? RegTestBitcoinCorePort { get; internal set; }
+
public Config()
{
}
@@ -36,11 +55,26 @@ namespace WalletWasabi.Backend
SetFilePath(filePath);
}
- public Config(Network network, string bitcoinRpcUser, string bitcoinRpcPassword)
+ public Config(Network network,
+ string bitcoinRpcUser,
+ string bitcoinRpcPassword,
+ string mainNetBitcoinCoreHost,
+ string testNetBitcoinCoreHost,
+ string regTestBitcoinCoreHost,
+ int? mainNetBitcoinCorePort,
+ int? testNetBitcoinCorePort,
+ int? regTestBitcoinCorePort)
{
Network = Guard.NotNull(nameof(network), network);
BitcoinRpcUser = Guard.NotNullOrEmptyOrWhitespace(nameof(bitcoinRpcUser), bitcoinRpcUser);
BitcoinRpcPassword = Guard.NotNull(nameof(bitcoinRpcPassword), bitcoinRpcPassword);
+
+ MainNetBitcoinCoreHost = Guard.NotNullOrEmptyOrWhitespace(nameof(mainNetBitcoinCoreHost), mainNetBitcoinCoreHost);
+ TestNetBitcoinCoreHost = Guard.NotNullOrEmptyOrWhitespace(nameof(testNetBitcoinCoreHost), testNetBitcoinCoreHost);
+ RegTestBitcoinCoreHost = Guard.NotNullOrEmptyOrWhitespace(nameof(regTestBitcoinCoreHost), regTestBitcoinCoreHost);
+ MainNetBitcoinCorePort = Guard.NotNull(nameof(mainNetBitcoinCorePort), mainNetBitcoinCorePort);
+ TestNetBitcoinCorePort = Guard.NotNull(nameof(testNetBitcoinCorePort), testNetBitcoinCorePort);
+ RegTestBitcoinCorePort = Guard.NotNull(nameof(regTestBitcoinCorePort), regTestBitcoinCorePort);
}
/// <inheritdoc />
@@ -63,6 +97,13 @@ namespace WalletWasabi.Backend
BitcoinRpcUser = "user";
BitcoinRpcPassword = "password";
+ MainNetBitcoinCoreHost = IPAddress.Loopback.ToString();
+ TestNetBitcoinCoreHost = IPAddress.Loopback.ToString();
+ RegTestBitcoinCoreHost = IPAddress.Loopback.ToString();
+ MainNetBitcoinCorePort = Network.Main.DefaultPort;
+ TestNetBitcoinCorePort = Network.TestNet.DefaultPort;
+ RegTestBitcoinCorePort = Network.RegTest.DefaultPort;
+
if (!File.Exists(FilePath))
{
Logger.LogInfo<Config>($"{nameof(Config)} file did not exist. Created at path: `{FilePath}`.");
@@ -75,6 +116,13 @@ namespace WalletWasabi.Backend
Network = config.Network ?? Network;
BitcoinRpcUser = config.BitcoinRpcUser ?? BitcoinRpcUser;
BitcoinRpcPassword = config.BitcoinRpcPassword ?? BitcoinRpcPassword;
+
+ MainNetBitcoinCoreHost = config.MainNetBitcoinCoreHost ?? MainNetBitcoinCoreHost;
+ TestNetBitcoinCoreHost = config.TestNetBitcoinCoreHost ?? TestNetBitcoinCoreHost;
+ RegTestBitcoinCoreHost = config.RegTestBitcoinCoreHost ?? RegTestBitcoinCoreHost;
+ MainNetBitcoinCorePort = config.MainNetBitcoinCorePort ?? MainNetBitcoinCorePort;
+ TestNetBitcoinCorePort = config.TestNetBitcoinCorePort ?? TestNetBitcoinCorePort;
+ RegTestBitcoinCorePort = config.RegTestBitcoinCorePort ?? RegTestBitcoinCorePort;
}
await ToFileAsync();
@@ -106,6 +154,31 @@ namespace WalletWasabi.Backend
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;
+ }
+
return false;
}

Add P2P settings to backend config.