Fix test init
MODIFY
WalletWasabi.Backend/Controllers/ChaumianCoinJoinController.cs
WalletWasabi.Backend/Controllers/ChaumianCoinJoinController.cs
@@ -23,8 +23,8 @@ namespace WalletWasabi.Backend.Controllers
/// <summary>
/// Satoshi gets various status information.
/// </summary>
- /// <returns>CurrentPhase, Denomination, RegisteredPeerCount, RequiredPeerCount, ForcedRoundStartMinutesLeft, MaximumInputCountPerPeer, FeePerInputs, FeePerOutputs, CoordinatorFee, Version</returns>
- /// <response code="200">CurrentPhase, Denomination, RegisteredPeerCount, RequiredPeerCount, ForcedRoundStartMinutesLeft, MaximumInputCountPerPeer, FeePerInputs, FeePerOutputs, CoordinatorFee, Version</response>
+ /// <returns>CurrentPhase, Denomination, RegisteredPeerCount, RequiredPeerCount, MaximumInputCountPerPeer, FeePerInputs, FeePerOutputs, CoordinatorFee, Version</returns>
+ /// <response code="200">CurrentPhase, Denomination, RegisteredPeerCount, RequiredPeerCount, MaximumInputCountPerPeer, FeePerInputs, FeePerOutputs, CoordinatorFee, Version</response>
[HttpGet("status")]
[ProducesResponseType(200)]
public IActionResult GetStatus()

MODIFY
WalletWasabi.Backend/Global.cs
WalletWasabi.Backend/Global.cs
@@ -51,6 +51,7 @@ namespace WalletWasabi.Backend
{
_dataDir = null;
+ ConfigFilePath = Path.Combine(DataDir, "Config.json");
// Initialize Config
if (network != null || rpcuser != null || rpcpassword != null)
{
@@ -58,9 +59,14 @@ namespace WalletWasabi.Backend
}
else
{
- await InitializeConfigsAsync();
+ Config = new Config();
+ await Config.LoadOrCreateDefaultFileAsync(ConfigFilePath);
}
+ RoundConfigFilePath = Path.Combine(DataDir, "CcjRoundConfig.json");
+ RoundConfig = new CcjRoundConfig();
+ await RoundConfig.LoadOrCreateDefaultFileAsync(RoundConfigFilePath);
+
// Initialize RsaKey
string rsaKeyPath = Path.Combine(DataDir, "RsaKey.json");
if (File.Exists(rsaKeyPath))
@@ -105,16 +111,6 @@ namespace WalletWasabi.Backend
RoundConfigWatcher.Start(TimeSpan.FromSeconds(10)); // Every 10 seconds check the config
}
- public static async Task InitializeConfigsAsync()
- {
- ConfigFilePath = Path.Combine(DataDir, "Config.json");
- RoundConfigFilePath = Path.Combine(DataDir, "CcjRoundConfig.json");
- Config = new Config();
- await Config.LoadOrCreateDefaultFileAsync(ConfigFilePath);
- RoundConfig = new CcjRoundConfig();
- await RoundConfig.LoadOrCreateDefaultFileAsync(RoundConfigFilePath);
- }
-
private static async Task AssertRpcNodeFullyInitializedAsync()
{
try

MODIFY
WalletWasabi/ChaumianCoinJoin/CcjRound.cs
WalletWasabi/ChaumianCoinJoin/CcjRound.cs
@@ -3,7 +3,9 @@ using NBitcoin.RPC;
using Nito.AsyncEx;
using System;
using System.Collections.Generic;
+using System.Linq;
using System.Text;
+using System.Threading;
using System.Threading.Tasks;
using WalletWasabi.Helpers;
using WalletWasabi.Logging;
@@ -12,6 +14,8 @@ namespace WalletWasabi.ChaumianCoinJoin
{
public class CcjRound
{
+ public static long RoundCount;
+
public RPCClient RpcClient { get; }
public Money Denomination { get; }
@@ -22,6 +26,13 @@ namespace WalletWasabi.ChaumianCoinJoin
public Money FeePerInputs { get; private set; }
public Money FeePerOutputs { get; private set; }
+ public string RoundHash { get; private set; }
+
+ private List<Alice> Alices { get; }
+ private AsyncLock AlicesLock { get; }
+ private List<Bob> Bobs { get; }
+ private AsyncLock BobsLock { get; }
+
public CcjRoundPhase Phase { get; private set; }
private static AsyncLock PhaseExecutionLock { get; } = new AsyncLock();
@@ -29,6 +40,8 @@ namespace WalletWasabi.ChaumianCoinJoin
public CcjRound(RPCClient rpc, Money denomination, int confirmationTarget, decimal coordinatorFeePercent, int anonymitySet)
{
+ Interlocked.Increment(ref RoundCount);
+
RpcClient = Guard.NotNull(nameof(rpc), rpc);
Denomination = Guard.NotNull(nameof(denomination), denomination);
ConfirmationTarget = confirmationTarget;
@@ -37,6 +50,13 @@ namespace WalletWasabi.ChaumianCoinJoin
Phase = CcjRoundPhase.InputRegistration;
Status = CcjRoundStatus.NotStarted;
+
+ RoundHash = null;
+
+ Alices = new List<Alice>();
+ AlicesLock = new AsyncLock();
+ Bobs = new List<Bob>();
+ BobsLock = new AsyncLock();
}
public async Task ExecuteNextPhaseAsync()
@@ -47,8 +67,7 @@ namespace WalletWasabi.ChaumianCoinJoin
{
if (Status == CcjRoundStatus.NotStarted) // So start the input registration phase
{
- Status = CcjRoundStatus.Running;
-
+ // Calculate fees
var inputSizeInBytes = (int)Math.Ceiling(((3 * Constants.P2wpkhInputSizeInBytes) + Constants.P2pkhInputSizeInBytes) / 4m);
var outputSizeInBytes = Constants.OutputSizeInBytes;
try
@@ -77,7 +96,7 @@ namespace WalletWasabi.ChaumianCoinJoin
Logger.LogError<CcjRound>(ex);
}
-
+ Status = CcjRoundStatus.Running;
}
else if (Status != CcjRoundStatus.Running) // Failed or succeeded, swallow
{
@@ -85,6 +104,8 @@ namespace WalletWasabi.ChaumianCoinJoin
}
else if (Phase == CcjRoundPhase.InputRegistration)
{
+ RoundHash = NBitcoinHelpers.HashOutpoints(Alices.SelectMany(x => x.Inputs).Select(y => y.Key));
+
Phase = CcjRoundPhase.ConnectionConfirmation;
}
else if (Phase == CcjRoundPhase.ConnectionConfirmation)
@@ -93,6 +114,8 @@ namespace WalletWasabi.ChaumianCoinJoin
}
else if (Phase == CcjRoundPhase.OutputRegistration)
{
+ // Build CoinJoin
+
Phase = CcjRoundPhase.Signing;
}
else

MODIFY
WalletWasabi/Extensions/NBitcoinExtensions.cs
WalletWasabi/Extensions/NBitcoinExtensions.cs
using WalletWasabi.Models;
using System.Collections.Generic;
+using System;
+using WalletWasabi.Helpers;
namespace NBitcoin
{
@@ -22,5 +24,16 @@ namespace NBitcoin
yield return input.PrevOut.ToTxoRef();
}
}
+
+ public static string ToHex(this IBitcoinSerializable me)
+ {
+ return ByteHelpers.ToHex(me.ToBytes());
+ }
+
+ public static void FromHex(this IBitcoinSerializable me, string hex)
+ {
+ Guard.NotNullOrEmptyOrWhitespace(nameof(hex), hex);
+ me.FromBytes(ByteHelpers.FromHex(hex));
+ }
}
}
\ No newline at end of file

Fix test init