Implement notification for dequeue reason
MODIFY
WalletWasabi.Gui/Global.cs
WalletWasabi.Gui/Global.cs
@@ -26,6 +26,7 @@ using WalletWasabi.Blockchain.TransactionOutputs;
using WalletWasabi.Blockchain.TransactionProcessing;
using WalletWasabi.CoinJoin.Client;
using WalletWasabi.CoinJoin.Client.Clients;
+using WalletWasabi.CoinJoin.Client.Rounds;
using WalletWasabi.Gui.Helpers;
using WalletWasabi.Helpers;
using WalletWasabi.Hwi.Models;
@@ -482,10 +483,28 @@ namespace WalletWasabi.Gui
CoinJoinProcessor.AddWalletService(WalletService);
WalletService.TransactionProcessor.WalletRelevantTransactionProcessed += TransactionProcessor_WalletRelevantTransactionProcessed;
+ ChaumianClient.CoinDequeued += ChaumianClient_CoinDequeued;
}
_cancelWalletServiceInitialization = null; // Must make it null explicitly, because dispose won't make it null.
}
+ private void ChaumianClient_CoinDequeued(object sender, DequeueCoin coin)
+ {
+ try
+ {
+ if (UiConfig?.LurkingWifeMode is true || string.IsNullOrWhiteSpace(coin.Reason))
+ {
+ return;
+ }
+
+ NotificationHelpers.Information(coin.Reason, $"Coin ({coin.Coin.Amount.ToString(false, true)}) Dequeued");
+ }
+ catch (Exception ex)
+ {
+ Logger.LogWarning(ex);
+ }
+ }
+
private void TransactionProcessor_WalletRelevantTransactionProcessed(object sender, ProcessedResult e)
{
try
@@ -499,7 +518,6 @@ namespace WalletWasabi.Gui
// ToDo
// Double spent.
- // CoinJoin?
// Anonymity set gained?
// Received dust
@@ -656,6 +674,7 @@ namespace WalletWasabi.Gui
if (walletService is { })
{
WalletService.TransactionProcessor.WalletRelevantTransactionProcessed -= TransactionProcessor_WalletRelevantTransactionProcessed;
+ ChaumianClient.CoinDequeued -= ChaumianClient_CoinDequeued;
}
try

MODIFY
WalletWasabi/CoinJoin/Client/Clients/CoinJoinClient.cs
WalletWasabi/CoinJoin/Client/Clients/CoinJoinClient.cs
@@ -50,7 +50,7 @@ namespace WalletWasabi.CoinJoin.Client.Clients
public event EventHandler<SmartCoin> CoinQueued;
- public event EventHandler<SmartCoin> CoinDequeued;
+ public event EventHandler<DequeueCoin> CoinDequeued;
private long _frequentStatusProcessingIfNotMixing;
@@ -1009,7 +1009,7 @@ namespace WalletWasabi.CoinJoin.Client.Clients
SmartCoin coinWaitingForMix = State.GetSingleOrDefaultFromWaitingList(coinToDequeue);
if (coinWaitingForMix != null) // If it is not being mixed, we can just remove it.
{
- RemoveCoin(coinWaitingForMix, reason);
+ RemoveCoin(new DequeueCoin(coinWaitingForMix, reason));
}
}
@@ -1024,15 +1024,14 @@ namespace WalletWasabi.CoinJoin.Client.Clients
}
}
- private void RemoveCoin(SmartCoin coinWaitingForMix, string reason = null)
+ private void RemoveCoin(DequeueCoin coinWaitingForMix)
{
- State.RemoveCoinFromWaitingList(coinWaitingForMix);
- coinWaitingForMix.CoinJoinInProgress = false;
- coinWaitingForMix.Secret = null;
+ State.RemoveCoinFromWaitingList(coinWaitingForMix.Coin);
+ coinWaitingForMix.Coin.CoinJoinInProgress = false;
+ coinWaitingForMix.Coin.Secret = null;
CoinDequeued?.Invoke(this, coinWaitingForMix);
- var correctReason = Guard.Correct(reason);
- var reasonText = correctReason.Length != 0 ? $" Reason: {correctReason}" : "";
- Logger.LogInfo($"Coin dequeued: {coinWaitingForMix.Index}:{coinWaitingForMix.TransactionId}.{reasonText}.");
+ var reasonText = coinWaitingForMix.HasReason ? $" Reason: {coinWaitingForMix.Reason}" : "";
+ Logger.LogInfo($"Coin dequeued: {coinWaitingForMix.Coin.Index}:{coinWaitingForMix.Coin.TransactionId}.{reasonText}.");
}
public async Task StopAsync()

ADD
WalletWasabi/CoinJoin/Client/Rounds/DequeueCoin.cs
+using System;
+using System.Collections.Generic;
+using System.Text;
+using WalletWasabi.Blockchain.TransactionOutputs;
+using WalletWasabi.Helpers;
+
+namespace WalletWasabi.CoinJoin.Client.Rounds
+{
+ public class DequeueCoin
+ {
+ public DequeueCoin(SmartCoin coin, string reason)
+ {
+ Coin = Guard.NotNull(nameof(coin), coin);
+ Reason = Guard.Correct(reason);
+ }
+
+ public SmartCoin Coin { get; }
+ public string Reason { get; }
+
+ public bool HasReason => Reason.Length != 0;
+ }
+}

Implement notification for dequeue reason