Reduce code redundancy.
MODIFY
WalletWasabi.Gui/Global.cs
WalletWasabi.Gui/Global.cs
@@ -180,13 +180,7 @@ namespace WalletWasabi.Gui
if (Network == Network.RegTest)
{
- Nodes = new NodesGroup(Network,
- requirements: new NodeRequirement
- {
- RequiredServices = NodeServices.NODE_WITNESS,
- MinVersion = Constants.ProtocolVersion_WITNESS_VERSION,
- MinProtocolCapabilities = Constants.MinProtocolCapabilities
- });
+ Nodes = new NodesGroup(Network, requirements: Constants.NodeRequirements);
Nodes.ConnectedNodes.Add(Node.Connect(Network.RegTest, new IPEndPoint(IPAddress.Loopback, 18444)));
RegTestMemPoolServingNode = Node.Connect(Network.RegTest, new IPEndPoint(IPAddress.Loopback, 18444));
@@ -194,13 +188,7 @@ namespace WalletWasabi.Gui
}
else
{
- Nodes = new NodesGroup(Network, connectionParameters,
- new NodeRequirement
- {
- RequiredServices = NodeServices.NODE_WITNESS,
- MinVersion = Constants.ProtocolVersion_WITNESS_VERSION,
- MinProtocolCapabilities = Constants.MinProtocolCapabilities
- });
+ Nodes = new NodesGroup(Network, connectionParameters, requirements: Constants.NodeRequirements);
RegTestMemPoolServingNode = null;
}

MODIFY
WalletWasabi.Tests/P2pTests.cs
WalletWasabi.Tests/P2pTests.cs
@@ -81,13 +81,7 @@ namespace WalletWasabi.Tests
var memPoolService = new MemPoolService();
connectionParameters.TemplateBehaviors.Add(new MemPoolBehavior(memPoolService));
- var nodes = new NodesGroup(network, connectionParameters,
- new NodeRequirement
- {
- RequiredServices = NodeServices.NODE_WITNESS,
- MinVersion = Helpers.Constants.ProtocolVersion_WITNESS_VERSION,
- MinProtocolCapabilities = Helpers.Constants.MinProtocolCapabilities
- });
+ var nodes = new NodesGroup(network, connectionParameters, requirements: Helpers.Constants.NodeRequirements);
KeyManager keyManager = KeyManager.CreateNew(out _, "password");
WalletService walletService = new WalletService(

MODIFY
WalletWasabi.Tests/RegTests.cs
WalletWasabi.Tests/RegTests.cs
@@ -402,13 +402,7 @@ namespace WalletWasabi.Tests
// Create the services.
// 1. Create connection service.
- var nodes = new NodesGroup(Global.Config.Network,
- requirements: new NodeRequirement
- {
- RequiredServices = NodeServices.NODE_WITNESS,
- MinVersion = Helpers.Constants.ProtocolVersion_WITNESS_VERSION,
- MinProtocolCapabilities = Helpers.Constants.MinProtocolCapabilities
- });
+ var nodes = new NodesGroup(Global.Config.Network, requirements: Helpers.Constants.NodeRequirements);
nodes.ConnectedNodes.Add(RegTestFixture.BackendRegTestNode.CreateNodeClient());
// 2. Create mempool service.
@@ -641,13 +635,7 @@ namespace WalletWasabi.Tests
// Create the services.
// 1. Create connection service.
- var nodes = new NodesGroup(Global.Config.Network,
- requirements: new NodeRequirement
- {
- RequiredServices = NodeServices.NODE_WITNESS,
- MinVersion = Helpers.Constants.ProtocolVersion_WITNESS_VERSION,
- MinProtocolCapabilities = Helpers.Constants.MinProtocolCapabilities
- });
+ var nodes = new NodesGroup(Global.Config.Network, requirements: Helpers.Constants.NodeRequirements);
nodes.ConnectedNodes.Add(RegTestFixture.BackendRegTestNode.CreateNodeClient());
// 2. Create mempool service.
@@ -1084,13 +1072,7 @@ namespace WalletWasabi.Tests
// Create the services.
// 1. Create connection service.
- var nodes = new NodesGroup(Global.Config.Network,
- requirements: new NodeRequirement
- {
- RequiredServices = NodeServices.NODE_WITNESS,
- MinVersion = Helpers.Constants.ProtocolVersion_WITNESS_VERSION,
- MinProtocolCapabilities = Helpers.Constants.MinProtocolCapabilities
- });
+ var nodes = new NodesGroup(Global.Config.Network, requirements: Helpers.Constants.NodeRequirements);
nodes.ConnectedNodes.Add(RegTestFixture.BackendRegTestNode.CreateNodeClient());
// 2. Create mempool service.
@@ -1255,13 +1237,7 @@ namespace WalletWasabi.Tests
// Create the services.
// 1. Create connection service.
- var nodes = new NodesGroup(Global.Config.Network,
- requirements: new NodeRequirement
- {
- RequiredServices = NodeServices.NODE_WITNESS,
- MinVersion = Helpers.Constants.ProtocolVersion_WITNESS_VERSION,
- MinProtocolCapabilities = Helpers.Constants.MinProtocolCapabilities
- });
+ var nodes = new NodesGroup(Global.Config.Network, requirements: Helpers.Constants.NodeRequirements);
nodes.ConnectedNodes.Add(RegTestFixture.BackendRegTestNode.CreateNodeClient());
// 2. Create mempool service.
@@ -1427,13 +1403,7 @@ namespace WalletWasabi.Tests
// Create the services.
// 1. Create connection service.
- var nodes = new NodesGroup(Global.Config.Network,
- requirements: new NodeRequirement
- {
- RequiredServices = NodeServices.NODE_WITNESS,
- MinVersion = Helpers.Constants.ProtocolVersion_WITNESS_VERSION,
- MinProtocolCapabilities = Helpers.Constants.MinProtocolCapabilities
- });
+ var nodes = new NodesGroup(Global.Config.Network, requirements: Helpers.Constants.NodeRequirements);
nodes.ConnectedNodes.Add(RegTestFixture.BackendRegTestNode.CreateNodeClient());
// 2. Create mempool service.
@@ -2696,22 +2666,10 @@ namespace WalletWasabi.Tests
// Create the services.
// 1. Create connection service.
- var nodes = new NodesGroup(Global.Config.Network,
- requirements: new NodeRequirement
- {
- RequiredServices = NodeServices.NODE_WITNESS,
- MinVersion = Helpers.Constants.ProtocolVersion_WITNESS_VERSION,
- MinProtocolCapabilities = Helpers.Constants.MinProtocolCapabilities
- });
+ var nodes = new NodesGroup(Global.Config.Network, requirements: Helpers.Constants.NodeRequirements);
nodes.ConnectedNodes.Add(RegTestFixture.BackendRegTestNode.CreateNodeClient());
- var nodes2 = new NodesGroup(Global.Config.Network,
- requirements: new NodeRequirement
- {
- RequiredServices = NodeServices.NODE_WITNESS,
- MinVersion = Helpers.Constants.ProtocolVersion_WITNESS_VERSION,
- MinProtocolCapabilities = Helpers.Constants.MinProtocolCapabilities
- });
+ var nodes2 = new NodesGroup(Global.Config.Network, requirements: Helpers.Constants.NodeRequirements);
nodes2.ConnectedNodes.Add(RegTestFixture.BackendRegTestNode.CreateNodeClient());
// 2. Create mempool service.

MODIFY
WalletWasabi/Helpers/Constants.cs
WalletWasabi/Helpers/Constants.cs
@@ -14,7 +14,12 @@ namespace WalletWasabi.Helpers
public const uint ProtocolVersion_WITNESS_VERSION = 70012;
- public static readonly ProtocolCapabilities MinProtocolCapabilities = new ProtocolCapabilities() { SupportGetBlock = true, SupportWitness = true, SupportMempoolQuery = true };
+ public static readonly NodeRequirement NodeRequirements = new NodeRequirement
+ {
+ RequiredServices = NodeServices.NODE_WITNESS,
+ MinVersion = ProtocolVersion_WITNESS_VERSION,
+ MinProtocolCapabilities = new ProtocolCapabilities() { SupportGetBlock = true, SupportWitness = true, SupportMempoolQuery = true }
+ };
public const int P2wpkhInputSizeInBytes = 41;
public const int P2pkhInputSizeInBytes = 145;

Reduce code redundancy.