Added logging to the client.
MODIFY
WalletWasabi/Models/ChaumianCoinJoin/CcjClientState.cs
WalletWasabi/Models/ChaumianCoinJoin/CcjClientState.cs
@@ -5,6 +5,7 @@ using System.Linq;
using System.Text;
using WalletWasabi.Backend.Models.Responses;
using WalletWasabi.Helpers;
+using WalletWasabi.Logging;
namespace WalletWasabi.Models.ChaumianCoinJoin
{
@@ -30,6 +31,7 @@ namespace WalletWasabi.Models.ChaumianCoinJoin
if (!(WaitingList.Contains(coin) || Rounds.Any(x => x.CoinsRegistered.Contains(coin))))
{
WaitingList.Add(coin);
+ Logger.LogInfo<CcjClientState>($"Coin added to the waiting list: {coin.Index}:{coin.TransactionId}.");
}
}
}
@@ -49,6 +51,7 @@ namespace WalletWasabi.Models.ChaumianCoinJoin
if (WaitingList.Contains(coin))
{
WaitingList.Remove(coin);
+ Logger.LogInfo<CcjClientState>($"Coin removed from the waiting list: {coin.Index}:{coin.TransactionId}.");
}
}
}
@@ -187,10 +190,12 @@ namespace WalletWasabi.Models.ChaumianCoinJoin
foreach (var coin in Rounds.Where(x => roundsToRemove.Contains(x.State.RoundId)).SelectMany(y => y.CoinsRegistered))
{
WaitingList.Add(coin);
+ Logger.LogInfo<CcjClientState>($"Coin added to the waiting list: {coin.Index}:{coin.TransactionId}.");
}
foreach(var round in Rounds.Where(x=> roundsToRemove.Contains(x.State.RoundId)))
{
round.AliceClient?.Dispose();
+ Logger.LogInfo<CcjClientState>($"Round ({round.State.RoundId}) removed. Reason: It's not running anymore.");
}
Rounds.RemoveAll(x => roundsToRemove.Contains(x.State.RoundId));
@@ -208,6 +213,7 @@ namespace WalletWasabi.Models.ChaumianCoinJoin
{
var r = new CcjClientRound(state);
Rounds.Add(r);
+ Logger.LogInfo<CcjClientState>($"Round ({r.State.RoundId}) added.");
}
}
}
@@ -228,9 +234,11 @@ namespace WalletWasabi.Models.ChaumianCoinJoin
foreach (var r in Rounds.Where(x => x.State.RoundId == round.State.RoundId))
{
r.AliceClient?.Dispose();
+ Logger.LogInfo<CcjClientState>($"Round ({round.State.RoundId}) removed. Reason: It's being replaced.");
}
Rounds.RemoveAll(x => x.State.RoundId == round.State.RoundId);
Rounds.Add(round);
+ Logger.LogInfo<CcjClientState>($"Round ({round.State.RoundId}) added.");
}
}
@@ -243,8 +251,10 @@ namespace WalletWasabi.Models.ChaumianCoinJoin
foreach (var coin in round.CoinsRegistered)
{
WaitingList.Add(coin);
+ Logger.LogInfo<CcjClientState>($"Coin added to the waiting list: {coin.Index}:{coin.TransactionId}.");
}
round.ClearRegistration();
+ Logger.LogInfo<CcjClientState>($"Round ({round.State.RoundId}) registration is cleared.");
}
}
}

MODIFY
WalletWasabi/Services/CcjClient.cs
WalletWasabi/Services/CcjClient.cs
@@ -82,6 +82,8 @@ namespace WalletWasabi.Services
{
await ProcessStatusAsync();
+ Logger.LogInfo<CcjClient>($"CcjClient is successfully initialized.");
+
while (IsRunning)
{
try
@@ -277,6 +279,7 @@ namespace WalletWasabi.Services
using (var bobClient = new BobClient(CcjHostUri, TorSocks5EndPoint))
{
await bobClient.PostOutputAsync(ongoingRound.RoundHash, ongoingRound.ActiveOutput.GetP2wpkhScript(), ongoingRound.UnblindedSignature);
+ Logger.LogInfo<AliceClient>($"Round ({ongoingRound.State.RoundId})Bob Posted output.");
}
}
else if (ongoingRound.State.Phase == CcjRoundPhase.Signing)
@@ -387,6 +390,7 @@ namespace WalletWasabi.Services
State.AddCoinToWaitingList(coin);
successful.Add(coin);
+ Logger.LogInfo<CcjClient>($"Coin queued: {coin.Index}:{coin.TransactionId}.");
}
return successful;
@@ -460,6 +464,7 @@ namespace WalletWasabi.Services
State.RemoveCoinFromWaitingList(coinWaitingForMix);
coinWaitingForMix.Locked = false;
coinWaitingForMix.Secret = null;
+ Logger.LogInfo<CcjClient>($"Coin dequeued: {coinWaitingForMix.Index}:{coinWaitingForMix.TransactionId}.");
}
}

MODIFY
WalletWasabi/WebClients/ChaumianCoinJoin/AliceClient.cs
WalletWasabi/WebClients/ChaumianCoinJoin/AliceClient.cs
@@ -10,6 +10,7 @@ using System.Threading.Tasks;
using WalletWasabi.Backend.Models;
using WalletWasabi.Backend.Models.Requests;
using WalletWasabi.Backend.Models.Responses;
+using WalletWasabi.Logging;
using WalletWasabi.Models.ChaumianCoinJoin;
using WalletWasabi.TorSocks5;
@@ -54,6 +55,7 @@ namespace WalletWasabi.WebClients.ChaumianCoinJoin
client.RoundId = inputsResponse.RoundId;
client.UniqueId = inputsResponse.UniqueId;
client.BlindedOutputSignature = inputsResponse.BlindedOutputSignature;
+ Logger.LogInfo<AliceClient>($"Round ({client.RoundId}), Alice ({client.UniqueId}): Registered {request.Inputs.Count()} inputs.");
return client;
}
@@ -83,11 +85,14 @@ namespace WalletWasabi.WebClients.ChaumianCoinJoin
{
if (response.StatusCode == HttpStatusCode.NoContent)
{
+ Logger.LogInfo<AliceClient>($"Round ({RoundId}), Alice ({UniqueId}): Confirmed connection.");
return null;
}
else if (response.StatusCode == HttpStatusCode.OK)
{
- return await response.Content.ReadAsJsonAsync<string>();
+ string roundHash = await response.Content.ReadAsJsonAsync<string>();
+ Logger.LogInfo<AliceClient>($"Round ({RoundId}), Alice ({UniqueId}): Confirmed connection. Acquired roundHash: {roundHash}.");
+ return roundHash;
}
else
{
@@ -121,6 +126,7 @@ namespace WalletWasabi.WebClients.ChaumianCoinJoin
throw new HttpRequestException($"{response.StatusCode.ToReasonString()}\n{error}");
}
}
+ Logger.LogInfo<AliceClient>($"Round ({RoundId}), Alice ({UniqueId}): Unconfirmed connection.");
}
}
@@ -142,7 +148,9 @@ namespace WalletWasabi.WebClients.ChaumianCoinJoin
}
var coinjoinHex = await response.Content.ReadAsJsonAsync<string>();
- return new Transaction(coinjoinHex);
+ Transaction coinJoin = new Transaction(coinjoinHex);
+ Logger.LogInfo<AliceClient>($"Round ({RoundId}), Alice ({UniqueId}): Acquired unsigned CoinJoin: {coinJoin.GetHash()}.");
+ return coinJoin;
}
}
@@ -171,6 +179,7 @@ namespace WalletWasabi.WebClients.ChaumianCoinJoin
throw new HttpRequestException($"{response.StatusCode.ToReasonString()}\n{error}");
}
}
+ Logger.LogInfo<AliceClient>($"Round ({RoundId}), Alice ({UniqueId}): Posted {signatures.Count} signatures.");
}
}

Added logging to the client.