Implement RegTest support
MODIFY
WalletWasabi.Backend/WalletWasabi.Backend.csproj
WalletWasabi.Backend/WalletWasabi.Backend.csproj
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.1.1" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.1.1" />
- <PackageReference Include="Swashbuckle.AspNetCore" Version="2.5.0" />
+ <PackageReference Include="Swashbuckle.AspNetCore" Version="3.0.0" />
</ItemGroup>
<ItemGroup>

MODIFY
WalletWasabi.Gui/Controls/StatusBar.xaml
WalletWasabi.Gui/Controls/StatusBar.xaml
<DockPanel LastChildFill="True" Margin="10 0">
<StackPanel Orientation="Horizontal" Gap="20" DockPanel.Dock="Right">
+ <StackPanel Orientation="Horizontal" Gap="4">
+ <TextBlock Text="{Binding ShowNetwork}" />
+ </StackPanel>
+
<StackPanel Orientation="Horizontal" Gap="4">
<Grid Height="10" Width="10">
<DrawingPresenter VerticalAlignment="Center" HorizontalAlignment="Center">

MODIFY
WalletWasabi.Gui/Global.cs
WalletWasabi.Gui/Global.cs
@@ -6,6 +6,7 @@ using Org.BouncyCastle.Math;
using System;
using System.Collections.Generic;
using System.IO;
+using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
@@ -37,7 +38,7 @@ namespace WalletWasabi.Gui
public static string BlocksDir => Path.Combine(DataDir, "Blocks", Config.Network.ToString());
public static Network Network => Config.Network;
- public static BlindingRsaPubKey BlindingPubKey { get; private set; }
+ public static BlindingRsaPubKey BlindingPubKey => Config.GetBlindingRsaPubKey();
public static string AddressManagerFilePath { get; private set; }
public static AddressManager AddressManager { get; private set; }
@@ -46,6 +47,7 @@ namespace WalletWasabi.Gui
public static IndexDownloader IndexDownloader { get; private set; }
public static CcjClient ChaumianClient { get; private set; }
public static WalletService WalletService { get; private set; }
+ public static Node RegTestMemPoolServingNode { get; private set; }
public static Config Config { get; private set; }
@@ -56,32 +58,19 @@ namespace WalletWasabi.Gui
Config = Guard.NotNull(nameof(config), config);
- string blindingPubKeyFile = Path.Combine(DataDir, $"BlindingPubKey{Network}.json");
- if (File.Exists(blindingPubKeyFile))
- {
- string blindingPubKeyJson = "";
- blindingPubKeyJson = File.ReadAllText(blindingPubKeyFile);
- BlindingPubKey = BlindingRsaPubKey.CreateFromJson(blindingPubKeyJson);
- }
- else
- {
- if (Network == Network.Main)
- {
- BlindingPubKey = new BlindingRsaPubKey(new BigInteger("16421152619146079007287475569112871971988560541093277613438316709041030720662622782033859387192362542996510605015506477964793447620206674394713753349543444988246276357919473682408472170521463339860947351211455351029147665615454176157348164935212551240942809518428851690991984017733153078846480521091423447691527000770982623947706172997649440619968085147635776736938871139581019988225202983052255684151711253254086264386774936200194229277914886876824852466823571396538091430866082004097086602287294474304344865162932126041736158327600847754258634325228417149098062181558798532036659383679712667027126535424484318399849"), new BigInteger("65537"));
- }
- else
- {
- BlindingPubKey = new BlindingRsaPubKey(new BigInteger("19473594448380717274202325076521698699373476167359253614775896809797414915031772455344343455269320444157176520539924715307970060890094127521516100754263825112231545354422893125394219335109864514907655429499954825469485252969706079992227103439161156022844535556626007277544637236136559868400854764962522288139619969507311597914908752685925185380735570791798593290356424409633800092336087046668579610273133131498947353719917407262847070395909920415822288443947309434039008038907229064999576278651443575362470457496666718250346530518268694562965606704838796709743032825816642704620776596590683042135764246115456630753521"), new BigInteger("65537"));
- }
- Directory.CreateDirectory(DataDir);
- File.WriteAllText(blindingPubKeyFile, BlindingPubKey.ToJson());
- }
-
var addressManagerFolderPath = Path.Combine(DataDir, "AddressManager");
AddressManagerFilePath = Path.Combine(addressManagerFolderPath, $"AddressManager{Network}.dat");
var blocksFolderPath = Path.Combine(DataDir, $"Blocks{Network}");
var connectionParameters = new NodeConnectionParameters();
AddressManager = null;
+
+ if (Network == Network.RegTest)
+ {
+ AddressManager = new AddressManager();
+ Logger.LogInfo<AddressManager>($"Fake {nameof(AddressManager)} is initialized on the RegTest.");
+ }
+ else
+ {
try
{
AddressManager = AddressManager.LoadPeerFile(AddressManagerFilePath);
@@ -99,11 +88,27 @@ namespace WalletWasabi.Gui
Logger.LogTrace<AddressManager>(ex);
AddressManager = new AddressManager();
}
+ }
connectionParameters.TemplateBehaviors.Add(new AddressManagerBehavior(AddressManager));
MemPoolService = new MemPoolService();
connectionParameters.TemplateBehaviors.Add(new MemPoolBehavior(MemPoolService));
+ if (Network == Network.RegTest)
+ {
+ Nodes = new NodesGroup(Network,
+ requirements: new NodeRequirement
+ {
+ RequiredServices = NodeServices.Network,
+ MinVersion = Constants.ProtocolVersion_WITNESS_VERSION
+ });
+ Nodes.ConnectedNodes.Add(Node.Connect(Network.RegTest, new IPEndPoint(IPAddress.Loopback, 18444)));
+
+ RegTestMemPoolServingNode = Node.Connect(Network.RegTest, new IPEndPoint(IPAddress.Loopback, 18444));
+ RegTestMemPoolServingNode.Behaviors.Add(new MemPoolBehavior(MemPoolService));
+ }
+ else
+ {
Nodes = new NodesGroup(Network, connectionParameters,
new NodeRequirement
{
@@ -111,12 +116,21 @@ namespace WalletWasabi.Gui
MinVersion = Constants.ProtocolVersion_WITNESS_VERSION
});
+ RegTestMemPoolServingNode = null;
+ }
+
var indexFilePath = Path.Combine(DataDir, $"Index{Network}.dat");
IndexDownloader = new IndexDownloader(Network, indexFilePath, Config.GetCurrentBackendUri());
Nodes.Connect();
Logger.LogInfo("Start connecting to nodes...");
+ if (RegTestMemPoolServingNode != null)
+ {
+ RegTestMemPoolServingNode.VersionHandshake();
+ Logger.LogInfo("Start connecting to mempool serving regtest node...");
+ }
+
IndexDownloader.Synchronize(requestInterval: TimeSpan.FromSeconds(21));
Logger.LogInfo("Start synchronizing filters...");
}
@@ -174,6 +188,12 @@ namespace WalletWasabi.Gui
Nodes?.Dispose();
Logger.LogInfo($"{nameof(Nodes)} are disposed.", nameof(Global));
+ if (RegTestMemPoolServingNode != null)
+ {
+ RegTestMemPoolServingNode.Disconnect();
+ Logger.LogInfo($"{nameof(RegTestMemPoolServingNode)} is disposed.", nameof(Global));
+ }
+
if (ChaumianClient != null)
{
await ChaumianClient.StopAsync();

MODIFY
WalletWasabi.Gui/ViewModels/StatusBarViewModel.cs
WalletWasabi.Gui/ViewModels/StatusBarViewModel.cs
@@ -7,6 +7,7 @@ using WalletWasabi.Services;
using Avalonia.Data.Converters;
using System.Globalization;
using WalletWasabi.Models;
+using NBitcoin;
namespace WalletWasabi.Gui.ViewModels
{
@@ -90,6 +91,14 @@ namespace WalletWasabi.Gui.ViewModels
set { this.RaiseAndSetIfChanged(ref _status, value); }
}
+ private string _showNetwork;
+
+ public string ShowNetwork
+ {
+ get { return _showNetwork; }
+ set { this.RaiseAndSetIfChanged(ref _showNetwork, value); }
+ }
+
public StatusBarViewModel(NodesCollection nodes, MemPoolService memPoolService, IndexDownloader indexDownloader)
{
Nodes = nodes;
@@ -109,6 +118,15 @@ namespace WalletWasabi.Gui.ViewModels
FiltersLeft = IndexDownloader.GetFiltersLeft();
+ if (indexDownloader.Network == Network.Main)
+ {
+ ShowNetwork = "";
+ }
+ else
+ {
+ ShowNetwork = indexDownloader.Network.ToString();
+ }
+
this.WhenAnyValue(x => x.BlocksLeft).Subscribe(blocks =>
{
SetStatus();

MODIFY
WalletWasabi.Tests/RegTests.cs
WalletWasabi.Tests/RegTests.cs
@@ -598,6 +598,9 @@ namespace WalletWasabi.Tests
// Dispose connection service.
nodes?.Dispose();
+ // Dispose mempool serving node.
+ node?.Disconnect();
+
// Dispose chaumian coinjoin client.
if (chaumianClient != null)
{
@@ -1062,6 +1065,8 @@ namespace WalletWasabi.Tests
indexDownloader?.Dispose();
// Dispose connection service.
nodes?.Dispose();
+ // Dispose mempool serving node.
+ node?.Disconnect();
// Dispose chaumian coinjoin client.
if (chaumianClient != null)
{
@@ -1236,6 +1241,8 @@ namespace WalletWasabi.Tests
indexDownloader?.Dispose();
// Dispose connection service.
nodes?.Dispose();
+ // Dispose mempool serving node.
+ node?.Disconnect();
// Dispose chaumian coinjoin client.
if (chaumianClient != null)
{
@@ -1404,6 +1411,8 @@ namespace WalletWasabi.Tests
indexDownloader?.Dispose();
// Dispose connection service.
nodes?.Dispose();
+ // Dispose mempool serving node.
+ node?.Disconnect();
// Dispose chaumian coinjoin client.
if (chaumianClient != null)
{
@@ -1556,6 +1565,8 @@ namespace WalletWasabi.Tests
indexDownloader?.Dispose();
// Dispose connection service.
nodes?.Dispose();
+ // Dispose mempool serving node.
+ node?.Disconnect();
// Dispose chaumian coinjoin client.
if (chaumianClient != null)
{
@@ -2799,6 +2810,8 @@ namespace WalletWasabi.Tests
indexDownloader?.Dispose();
// Dispose connection service.
nodes?.Dispose();
+ // Dispose mempool serving node.
+ node?.Disconnect();
// Dispose chaumian coinjoin client.
if (chaumianClient != null)
{

MODIFY
WalletWasabi/Crypto/BlindingRsaKey.cs
WalletWasabi/Crypto/BlindingRsaKey.cs
@@ -6,6 +6,7 @@ using Org.BouncyCastle.Crypto.Parameters;
using Org.BouncyCastle.Math;
using Org.BouncyCastle.Security;
using System;
+using WalletWasabi.Helpers;
namespace WalletWasabi.Crypto
{
@@ -23,7 +24,7 @@ namespace WalletWasabi.Crypto
{
// Generate a 2048-bit RSA key pair.
var generator = new RsaKeyPairGenerator();
- var RSA_F4 = BigInteger.ValueOf(65537);
+ var RSA_F4 = Constants.RsaPubKeyExponent;
generator.Init(new RsaKeyGenerationParameters(
publicExponent: RSA_F4,
random: new SecureRandom(),

Implement RegTest support