Don't acquire lock when queue or dequeue is empty
MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/SendTabViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/SendTabViewModel.cs
@@ -135,9 +135,11 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
try
{
(uint256 TransactionId, uint Index)[] toDequeue = selectedCoinViewModels.Where(x => x.CoinJoinInProgress).Select(x => (x.Model.TransactionId, x.Model.Index)).ToArray();
- if (toDequeue!=null && toDequeue.Length!=0)
+ if (toDequeue != null && toDequeue.Any())
+ {
await Global.ChaumianClient.DequeueCoinsFromMixAsync(toDequeue);
}
+ }
catch
{
SetWarningMessage("Spending coins those are being actively mixed is not allowed.");

MODIFY
WalletWasabi/Services/CcjClient.cs
WalletWasabi/Services/CcjClient.cs
@@ -662,6 +662,8 @@ namespace WalletWasabi.Services
public async Task<IEnumerable<SmartCoin>> QueueCoinsToMixAsync(string password, params SmartCoin[] coins)
{
+ if (coins is null || !coins.Any()) return Enumerable.Empty<SmartCoin>();
+
var successful = new List<SmartCoin>();
using (await MixLock.LockAsync())
{
@@ -710,6 +712,8 @@ namespace WalletWasabi.Services
public async Task DequeueCoinsFromMixAsync(params SmartCoin[] coins)
{
+ if (coins is null || !coins.Any()) return;
+
using (var cts = new CancellationTokenSource(TimeSpan.FromSeconds(3)))
{
try
@@ -732,7 +736,7 @@ namespace WalletWasabi.Services
public async Task DequeueCoinsFromMixAsync(params (uint256 txid, uint index)[] coins)
{
- if (coins == null || coins.Length == 0) return;
+ if (coins is null || !coins.Any()) return;
using (var cts = new CancellationTokenSource(TimeSpan.FromSeconds(3)))
{
@@ -779,6 +783,8 @@ namespace WalletWasabi.Services
private async Task DequeueCoinsFromMixNoLockAsync(params (uint256 txid, uint index)[] coins)
{
+ if (coins is null || !coins.Any()) return;
+
List<Exception> exceptions = new List<Exception>();
foreach (var coinReference in coins)

Don't acquire lock when queue or dequeue is empty