Skip to content
Permalink
Browse files

Merge branch 'master' into xaml-formatting-4

  • Loading branch information...
yahiheb committed Jul 23, 2019
2 parents 96f0bba + a7a43cc commit 28933362870190a01800e5cda13e6fe442a0f5c0
Showing with 1,187 additions and 563 deletions.
  1. +3 −0 .editorconfig
  2. +1 −1 LICENSE.md
  3. +143 −71 WalletWasabi.Backend/Config.cs
  4. +1 −1 WalletWasabi.Backend/Global.cs
  5. +4 −1 WalletWasabi.Backend/InitConfigStartupTask.cs
  6. +51 −8 WalletWasabi.Documentation/Guides/InstallInstructions.md
  7. +34 −0 WalletWasabi.Gui/Behaviors/CommandOnLostFocusBehavior.cs
  8. +110 −82 WalletWasabi.Gui/Config.cs
  9. +2 −2 WalletWasabi.Gui/Controls/WalletExplorer/CoinListView.xaml
  10. +6 −6 WalletWasabi.Gui/Controls/WalletExplorer/CoinListViewModel.cs
  11. +1 −1 WalletWasabi.Gui/Controls/WalletExplorer/HistoryTabView.xaml
  12. +1 −0 WalletWasabi.Gui/Controls/WalletExplorer/HistoryTabViewModel.cs
  13. +1 −1 WalletWasabi.Gui/Controls/WalletExplorer/SendTabView.xaml
  14. +7 −0 WalletWasabi.Gui/Controls/WalletExplorer/TransactionInfo.cs
  15. +2 −0 WalletWasabi.Gui/Controls/WalletExplorer/TransactionViewModel.cs
  16. +10 −2 WalletWasabi.Gui/Controls/WalletExplorer/WalletInfoView.xaml
  17. +31 −0 WalletWasabi.Gui/Converters/NetworkStringConverter.cs
  18. +2 −2 WalletWasabi.Gui/Converters/StatusBarStatusStringConverter.cs
  19. +4 −4 WalletWasabi.Gui/Global.cs
  20. +4 −0 WalletWasabi.Gui/Tabs/AboutView.xaml
  21. +2 −0 WalletWasabi.Gui/Tabs/AboutViewModel.cs
  22. +108 −83 WalletWasabi.Gui/Tabs/SettingsView.xaml
  23. +75 −132 WalletWasabi.Gui/Tabs/SettingsViewModel.cs
  24. +1 −1 WalletWasabi.Gui/Tabs/WalletManager/RecoverWalletView.xaml
  25. +5 −6 WalletWasabi.Gui/Tabs/WalletManager/WalletManagerViewModel.cs
  26. +1 −1 WalletWasabi.Tests/Global.cs
  27. +22 −0 WalletWasabi.Tests/NBitcoinTests.cs
  28. +39 −36 WalletWasabi.Tests/NodeBuilding/CoreNode.cs
  29. +143 −0 WalletWasabi.Tests/ParserTests.cs
  30. +7 −1 WalletWasabi.Tests/RegTests.cs
  31. +9 −7 WalletWasabi.Tests/XunitConfiguration/RegTestFixture.cs
  32. +1 −1 WalletWasabi/Backend/Models/FilterModel.cs
  33. +3 −3 WalletWasabi/Bases/TorDisposableBase.cs
  34. +10 −0 WalletWasabi/Extensions/NBitcoinExtensions.cs
  35. +47 −0 WalletWasabi/Extensions/SystemNetExtensions.cs
  36. +1 −1 WalletWasabi/Gma/QrCodeNet/Encoding/BitList.cs
  37. +13 −0 WalletWasabi/Helpers/Constants.cs
  38. +116 −0 WalletWasabi/Helpers/EndPointParser.cs
  39. +1 −1 WalletWasabi/Helpers/Guard.cs
  40. +1 −3 WalletWasabi/Hwi/HwiProcessManager.cs
  41. +62 −0 WalletWasabi/JsonConverters/EndPointJsonConverter.cs
  42. +5 −1 WalletWasabi/Models/ChaumianCoinJoin/CcjRound.cs
  43. +2 −2 WalletWasabi/Mono/CommandSet.cs
  44. +18 −20 WalletWasabi/Mono/Option.cs
  45. +9 −9 WalletWasabi/Mono/OptionSet.cs
  46. +4 −4 WalletWasabi/Mono/OptionValueCollection.cs
  47. +4 −4 WalletWasabi/Services/CcjClient.cs
  48. +1 −1 WalletWasabi/Services/MempoolService.cs
  49. +4 −2 WalletWasabi/Services/UpdateChecker.cs
  50. +1 −5 WalletWasabi/Services/UtxoReferee.cs
  51. +5 −5 WalletWasabi/Services/WalletService.cs
  52. +2 −2 WalletWasabi/Services/WasabiSynchronizer.cs
  53. +1 −1 WalletWasabi/TorSocks5/Models/Fields/ByteArrayFields/AddrField.cs
  54. +1 −1 WalletWasabi/TorSocks5/Models/Messages/VersionMethodRequest.cs
  55. +4 −4 WalletWasabi/TorSocks5/TorHttpClient.cs
  56. +8 −12 WalletWasabi/TorSocks5/TorProcessManager.cs
  57. +18 −17 WalletWasabi/TorSocks5/TorSocks5Client.cs
  58. +5 −5 WalletWasabi/WebClients/Wasabi/ChaumianCoinJoin/AliceClient.cs
  59. +2 −2 WalletWasabi/WebClients/Wasabi/ChaumianCoinJoin/BobClient.cs
  60. +3 −3 WalletWasabi/WebClients/Wasabi/ChaumianCoinJoin/SatoshiClient.cs
  61. +2 −2 WalletWasabi/WebClients/Wasabi/WasabiClient.cs
  62. +1 −1 azure-pipelines-linux.yml
  63. +1 −1 azure-pipelines-osx.yml
  64. +1 −1 azure-pipelines-windows.yml
@@ -100,6 +100,9 @@ dotnet_style_prefer_is_null_check_over_reference_equality_method = true:error
#prefer braces
csharp_prefer_braces = true:error

#do not suggest readonly fields
dotnet_style_readonly_field = false:error


# name all constant fields using PascalCase
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = error
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2018 zkSNACKs
Copyright (c) 2019 zkSNACKs

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -1,4 +1,5 @@
using NBitcoin;
using NBitcoin.RPC;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
@@ -27,63 +28,68 @@ public class Config : IConfig
[JsonProperty(PropertyName = "BitcoinRpcConnectionString")]
public string BitcoinRpcConnectionString { get; private set; }

[JsonProperty(PropertyName = "MainNetBitcoinCoreHost")]
public string MainNetBitcoinCoreHost { get; internal set; }
[JsonProperty(PropertyName = "MainNetBitcoinP2pEndPoint")]
[JsonConverter(typeof(EndPointJsonConverter), Constants.DefaultMainNetBitcoinP2pPort)]
public EndPoint MainNetBitcoinP2pEndPoint { get; internal set; }

[JsonProperty(PropertyName = "TestNetBitcoinCoreHost")]
public string TestNetBitcoinCoreHost { get; internal set; }
[JsonProperty(PropertyName = "TestNetBitcoinP2pEndPoint")]
[JsonConverter(typeof(EndPointJsonConverter), Constants.DefaultTestNetBitcoinP2pPort)]
public EndPoint TestNetBitcoinP2pEndPoint { get; internal set; }

[JsonProperty(PropertyName = "RegTestBitcoinCoreHost")]
public string RegTestBitcoinCoreHost { get; internal set; }
[JsonProperty(PropertyName = "RegTestBitcoinP2pEndPoint")]
[JsonConverter(typeof(EndPointJsonConverter), Constants.DefaultRegTestBitcoinP2pPort)]
public EndPoint RegTestBitcoinP2pEndPoint { get; internal set; }

[JsonProperty(PropertyName = "MainNetBitcoinCorePort")]
public int? MainNetBitcoinCorePort { get; internal set; }
[JsonProperty(PropertyName = "MainNetBitcoinCoreRpcEndPoint")]
[JsonConverter(typeof(EndPointJsonConverter), Constants.DefaultMainNetBitcoinCoreRpcPort)]
public EndPoint MainNetBitcoinCoreRpcEndPoint { get; internal set; }

[JsonProperty(PropertyName = "TestNetBitcoinCorePort")]
public int? TestNetBitcoinCorePort { get; internal set; }
[JsonProperty(PropertyName = "TestNetBitcoinCoreRpcEndPoint")]
[JsonConverter(typeof(EndPointJsonConverter), Constants.DefaultTestNetBitcoinCoreRpcPort)]
public EndPoint TestNetBitcoinCoreRpcEndPoint { get; internal set; }

[JsonProperty(PropertyName = "RegTestBitcoinCorePort")]
public int? RegTestBitcoinCorePort { get; internal set; }
[JsonProperty(PropertyName = "RegTestBitcoinCoreRpcEndPoint")]
[JsonConverter(typeof(EndPointJsonConverter), Constants.DefaultRegTestBitcoinCoreRpcPort)]
public EndPoint RegTestBitcoinCoreRpcEndPoint { get; internal set; }

private EndPoint _bitcoinCoreEndPoint;

public EndPoint GetBitcoinCoreEndPoint()
public EndPoint GetBitcoinP2pEndPoint()
{
if (_bitcoinCoreEndPoint is null)
if (Network == Network.Main)
{
IPAddress ipHost;
string dnsHost = null;
int? port = null;
try
{
if (Network == Network.Main)
{
port = MainNetBitcoinCorePort;
dnsHost = MainNetBitcoinCoreHost;
ipHost = IPAddress.Parse(MainNetBitcoinCoreHost);
}
else if (Network == Network.TestNet)
{
port = TestNetBitcoinCorePort;
dnsHost = TestNetBitcoinCoreHost;
ipHost = IPAddress.Parse(TestNetBitcoinCoreHost);
}
else // if (Network == Network.RegTest)
{
port = RegTestBitcoinCorePort;
dnsHost = RegTestBitcoinCoreHost;
ipHost = IPAddress.Parse(RegTestBitcoinCoreHost);
}

_bitcoinCoreEndPoint = new IPEndPoint(ipHost, port ?? Network.DefaultPort);
}
catch
{
_bitcoinCoreEndPoint = new DnsEndPoint(dnsHost, port ?? Network.DefaultPort);
}
return MainNetBitcoinP2pEndPoint;
}
else if (Network == Network.TestNet)
{
return TestNetBitcoinP2pEndPoint;
}
else if (Network == Network.RegTest)
{
return RegTestBitcoinP2pEndPoint;
}
else
{
throw new NotSupportedException($"{nameof(Network)} not supported: {Network}.");
}
}

return _bitcoinCoreEndPoint;
public EndPoint GetBitcoinCoreRpcEndPoint()
{
if (Network == Network.Main)
{
return MainNetBitcoinCoreRpcEndPoint;
}
else if (Network == Network.TestNet)
{
return TestNetBitcoinCoreRpcEndPoint;
}
else if (Network == Network.RegTest)
{
return RegTestBitcoinCoreRpcEndPoint;
}
else
{
throw new NotSupportedException($"{nameof(Network)} not supported: {Network}.");
}
}

public Config()
@@ -97,22 +103,23 @@ public Config(string filePath)

public Config(Network network,
string bitcoinRpcConnectionString,
string mainNetBitcoinCoreHost,
string testNetBitcoinCoreHost,
string regTestBitcoinCoreHost,
int? mainNetBitcoinCorePort,
int? testNetBitcoinCorePort,
int? regTestBitcoinCorePort)
EndPoint mainNetBitcoinP2pEndPoint,
EndPoint testNetBitcoinP2pEndPoint,
EndPoint regTestBitcoinP2pEndPoint,
EndPoint mainNetBitcoinCoreRpcEndPoint,
EndPoint testNetBitcoinCoreRpcEndPoint,
EndPoint regTestBitcoinCoreRpcEndPoint)
{
Network = Guard.NotNull(nameof(network), network);
BitcoinRpcConnectionString = Guard.NotNullOrEmptyOrWhitespace(nameof(bitcoinRpcConnectionString), bitcoinRpcConnectionString);

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);
MainNetBitcoinP2pEndPoint = Guard.NotNull(nameof(mainNetBitcoinP2pEndPoint), mainNetBitcoinP2pEndPoint);
TestNetBitcoinP2pEndPoint = Guard.NotNull(nameof(testNetBitcoinP2pEndPoint), testNetBitcoinP2pEndPoint);
RegTestBitcoinP2pEndPoint = Guard.NotNull(nameof(regTestBitcoinP2pEndPoint), regTestBitcoinP2pEndPoint);

MainNetBitcoinCoreRpcEndPoint = Guard.NotNull(nameof(mainNetBitcoinCoreRpcEndPoint), mainNetBitcoinCoreRpcEndPoint);
TestNetBitcoinCoreRpcEndPoint = Guard.NotNull(nameof(testNetBitcoinCoreRpcEndPoint), testNetBitcoinCoreRpcEndPoint);
RegTestBitcoinCoreRpcEndPoint = Guard.NotNull(nameof(regTestBitcoinCoreRpcEndPoint), regTestBitcoinCoreRpcEndPoint);
}

/// <inheritdoc />
@@ -134,12 +141,14 @@ public async Task LoadOrCreateDefaultFileAsync()
Network = Network.Main;
BitcoinRpcConnectionString = "user: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;
MainNetBitcoinP2pEndPoint = new IPEndPoint(IPAddress.Loopback, Constants.DefaultMainNetBitcoinP2pPort);
TestNetBitcoinP2pEndPoint = new IPEndPoint(IPAddress.Loopback, Constants.DefaultTestNetBitcoinP2pPort);
RegTestBitcoinP2pEndPoint = new IPEndPoint(IPAddress.Loopback, Constants.DefaultRegTestBitcoinP2pPort);

MainNetBitcoinCoreRpcEndPoint = new IPEndPoint(IPAddress.Loopback, Constants.DefaultMainNetBitcoinCoreRpcPort);
TestNetBitcoinCoreRpcEndPoint = new IPEndPoint(IPAddress.Loopback, Constants.DefaultTestNetBitcoinCoreRpcPort);
RegTestBitcoinCoreRpcEndPoint = new IPEndPoint(IPAddress.Loopback, Constants.DefaultRegTestBitcoinCoreRpcPort);

if (!File.Exists(FilePath))
{
Logger.LogInfo<Config>($"{nameof(Config)} file did not exist. Created at path: `{FilePath}`.");
@@ -152,12 +161,18 @@ public async Task LoadOrCreateDefaultFileAsync()
Network = config.Network ?? Network;
BitcoinRpcConnectionString = config.BitcoinRpcConnectionString ?? BitcoinRpcConnectionString;

MainNetBitcoinCoreHost = config.MainNetBitcoinCoreHost ?? MainNetBitcoinCoreHost;
TestNetBitcoinCoreHost = config.TestNetBitcoinCoreHost ?? TestNetBitcoinCoreHost;
RegTestBitcoinCoreHost = config.RegTestBitcoinCoreHost ?? RegTestBitcoinCoreHost;
MainNetBitcoinCorePort = config.MainNetBitcoinCorePort ?? MainNetBitcoinCorePort;
TestNetBitcoinCorePort = config.TestNetBitcoinCorePort ?? TestNetBitcoinCorePort;
RegTestBitcoinCorePort = config.RegTestBitcoinCorePort ?? RegTestBitcoinCorePort;
MainNetBitcoinP2pEndPoint = config.MainNetBitcoinP2pEndPoint ?? MainNetBitcoinP2pEndPoint;
TestNetBitcoinP2pEndPoint = config.TestNetBitcoinP2pEndPoint ?? TestNetBitcoinP2pEndPoint;
RegTestBitcoinP2pEndPoint = config.RegTestBitcoinP2pEndPoint ?? RegTestBitcoinP2pEndPoint;

MainNetBitcoinCoreRpcEndPoint = config.MainNetBitcoinCoreRpcEndPoint ?? MainNetBitcoinCoreRpcEndPoint;
TestNetBitcoinCoreRpcEndPoint = config.TestNetBitcoinCoreRpcEndPoint ?? TestNetBitcoinCoreRpcEndPoint;
RegTestBitcoinCoreRpcEndPoint = config.RegTestBitcoinCoreRpcEndPoint ?? RegTestBitcoinCoreRpcEndPoint;

if (TryEnsureBackwardsCompatibility(jsonString))
{
await ToFileAsync();
}
}

await ToFileAsync();
@@ -193,5 +208,62 @@ public void AssertFilePathSet()
throw new NotSupportedException($"{nameof(FilePath)} is not set. Use {nameof(SetFilePath)} to set it.");
}
}

private bool TryEnsureBackwardsCompatibility(string jsonString)
{
try
{
var jsObject = JsonConvert.DeserializeObject<JObject>(jsonString);
bool saveIt = false;

var mainNetBitcoinCoreHost = jsObject.Value<string>("MainNetBitcoinCoreHost");
var mainNetBitcoinCorePort = jsObject.Value<int?>("MainNetBitcoinCorePort");
var testNetBitcoinCoreHost = jsObject.Value<string>("TestNetBitcoinCoreHost");
var testNetBitcoinCorePort = jsObject.Value<int?>("TestNetBitcoinCorePort");
var regTestBitcoinCoreHost = jsObject.Value<string>("RegTestBitcoinCoreHost");
var regTestBitcoinCorePort = jsObject.Value<int?>("RegTestBitcoinCorePort");

if (mainNetBitcoinCoreHost != null)
{
int port = mainNetBitcoinCorePort ?? Constants.DefaultMainNetBitcoinP2pPort;

if (EndPointParser.TryParse(mainNetBitcoinCoreHost, port, out EndPoint ep))
{
MainNetBitcoinP2pEndPoint = ep;
saveIt = true;
}
}

if (testNetBitcoinCoreHost != null)
{
int port = testNetBitcoinCorePort ?? Constants.DefaultTestNetBitcoinP2pPort;

if (EndPointParser.TryParse(testNetBitcoinCoreHost, port, out EndPoint ep))
{
TestNetBitcoinP2pEndPoint = ep;
saveIt = true;
}
}

if (regTestBitcoinCoreHost != null)
{
int port = regTestBitcoinCorePort ?? Constants.DefaultRegTestBitcoinP2pPort;

if (EndPointParser.TryParse(regTestBitcoinCoreHost, port, out EndPoint ep))
{
RegTestBitcoinP2pEndPoint = ep;
saveIt = true;
}
}

return saveIt;
}
catch (Exception ex)
{
Logger.LogWarning<Config>("Backwards compatibility couldn't be ensured.");
Logger.LogInfo<Config>(ex);
return false;
}
}
}
}
@@ -52,7 +52,7 @@ public async Task InitializeAsync(Config config, CcjRoundConfig roundConfig, RPC
await AssertRpcNodeFullyInitializedAsync();

// Make sure P2P works.
await InitializeP2pAsync(config.Network, config.GetBitcoinCoreEndPoint());
await InitializeP2pAsync(config.Network, config.GetBitcoinP2pEndPoint());

// Initialize index building
var indexBuilderServiceDir = Path.Combine(DataDir, nameof(IndexBuilderService));
@@ -6,6 +6,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using WalletWasabi.Logging;
@@ -43,8 +44,10 @@ public async Task ExecuteAsync(CancellationToken cancellationToken)
await roundConfig.LoadOrCreateDefaultFileAsync();
Logger.LogInfo<CcjRoundConfig>("RoundConfig is successfully initialized.");

string host = config.GetBitcoinCoreRpcEndPoint().ToString(config.Network.RPCPort);
var rpc = new RPCClient(
credentials: RPCCredentialString.Parse(config.BitcoinRpcConnectionString),
authenticationString: config.BitcoinRpcConnectionString,
hostOrUri: host,
network: config.Network);

await Global.InitializeAsync(config, roundConfig, rpc);

0 comments on commit 2893336

Please sign in to comment.
You can’t perform that action at this time.