Fix coin confirmation problems.
Fixes:
Fixes:
MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/CoinJoinTabViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/CoinJoinTabViewModel.cs
@@ -85,14 +85,6 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
EnqueueCommand = ReactiveCommand.Create(async () =>
{
- Console.WriteLine();
- Console.WriteLine("UNSPENT COINS:");
- foreach (var coin in Global.WalletService.Coins.Where(x => x.Unspent))
- {
- Console.WriteLine($"{coin.Amount.ToString(false, true)} {coin.Confirmed} {coin.CoinJoinInProgress}");
- }
- Console.WriteLine();
-
var selectedCoins = AvailableCoinsList.Coins.Where(c => c.IsSelected).ToList();
if (!selectedCoins.Any())

MODIFY
WalletWasabi.Tests/RegTests.cs
WalletWasabi.Tests/RegTests.cs
@@ -2569,22 +2569,22 @@ namespace WalletWasabi.Tests
roundConfig = new CcjRoundConfig(denomination, 140, coordinatorFeePercent, anonymitySet, 240, connectionConfirmationTimeout, 50, 50, 1);
coordinator.UpdateRoundConfig(roundConfig);
coordinator.FailAllRoundsInInputRegistration();
- Assert.NotEmpty(chaumianClient1.State.GetAllCoins());
+ Assert.NotEmpty(chaumianClient1.State.GetAllQueuedCoins());
await chaumianClient1.DequeueAllCoinsFromMixAsync();
- Assert.Empty(chaumianClient1.State.GetAllCoins());
+ Assert.Empty(chaumianClient1.State.GetAllQueuedCoins());
await chaumianClient1.QueueCoinsToMixAsync(password, smartCoin4);
- Assert.NotEmpty(chaumianClient1.State.GetAllCoins());
+ Assert.NotEmpty(chaumianClient1.State.GetAllQueuedCoins());
Assert.NotEmpty(chaumianClient1.State.GetAllWaitingCoins());
Assert.Empty(chaumianClient1.State.GetAllRegisteredCoins());
while (chaumianClient1.State.GetAllWaitingCoins().Any())
{
await Task.Delay(1000);
}
- Assert.NotEmpty(chaumianClient1.State.GetAllCoins());
+ Assert.NotEmpty(chaumianClient1.State.GetAllQueuedCoins());
Assert.Empty(chaumianClient1.State.GetAllWaitingCoins());
Assert.NotEmpty(chaumianClient1.State.GetAllRegisteredCoins());
await Task.Delay(3000); // Make sure to wait until times out.
- Assert.NotEmpty(chaumianClient1.State.GetAllCoins());
+ Assert.NotEmpty(chaumianClient1.State.GetAllQueuedCoins());
Assert.NotEmpty(chaumianClient1.State.GetAllWaitingCoins());
Assert.Empty(chaumianClient1.State.GetAllRegisteredCoins());
}

MODIFY
WalletWasabi/Models/ChaumianCoinJoin/CcjClientState.cs
WalletWasabi/Models/ChaumianCoinJoin/CcjClientState.cs
@@ -23,6 +23,35 @@ namespace WalletWasabi.Models.ChaumianCoinJoin
Rounds = new List<CcjClientRound>();
}
+ public void UpdateCoin(SmartCoin coin)
+ {
+ lock (StateLock)
+ {
+ SmartCoin found = WaitingList.Concat(Rounds.SelectMany(x => x.CoinsRegistered)).FirstOrDefault(x => x == coin);
+ if (found != default)
+ {
+ if (WaitingList.Contains(coin))
+ {
+ coin.CoinJoinInProgress = true;
+ WaitingList.Remove(found);
+ WaitingList.Add(coin);
+ return;
+ }
+
+ foreach (CcjClientRound round in Rounds)
+ {
+ if (round.CoinsRegistered.Contains(coin))
+ {
+ coin.CoinJoinInProgress = true;
+ round.CoinsRegistered.Remove(found);
+ round.CoinsRegistered.Add(coin);
+ return;
+ }
+ }
+ }
+ }
+ }
+
public void AddCoinToWaitingList(SmartCoin coin)
{
lock (StateLock)
@@ -95,7 +124,7 @@ namespace WalletWasabi.Models.ChaumianCoinJoin
}
}
- public IEnumerable<(uint256 txid, uint index)> GetAllCoins()
+ public IEnumerable<(uint256 txid, uint index)> GetAllQueuedCoins()
{
lock (StateLock)
{

MODIFY
WalletWasabi/Services/CcjClient.cs
WalletWasabi/Services/CcjClient.cs
@@ -604,13 +604,13 @@ namespace WalletWasabi.Services
{
using (await MixLock.LockAsync())
{
- await DequeueCoinsFromMixNoLockAsync(State.GetAllCoins().ToArray());
+ await DequeueCoinsFromMixNoLockAsync(State.GetAllQueuedCoins().ToArray());
}
}
private async Task DequeueAllCoinsFromMixNoLockAsync()
{
- await DequeueCoinsFromMixNoLockAsync(State.GetAllCoins().ToArray());
+ await DequeueCoinsFromMixNoLockAsync(State.GetAllQueuedCoins().ToArray());
}
private async Task DequeueCoinsFromMixNoLockAsync(params (uint256 txid, uint index)[] coins)
@@ -717,7 +717,7 @@ namespace WalletWasabi.Services
SatoshiClient?.Dispose();
State.DisposeAllAliceClients();
- IEnumerable<(uint256 txid, uint index)> allCoins = State.GetAllCoins();
+ IEnumerable<(uint256 txid, uint index)> allCoins = State.GetAllQueuedCoins();
foreach (var coinReference in allCoins)
{
try

MODIFY
WalletWasabi/Services/WalletService.cs
WalletWasabi/Services/WalletService.cs
@@ -504,7 +504,8 @@ namespace WalletWasabi.Services
{
mixin += spentOwnCoins.Min(x => x.Mixin);
}
- var coin = new SmartCoin(tx.GetHash(), i, output.ScriptPubKey, output.Value, tx.Transaction.Inputs.ToTxoRefs().ToArray(), tx.Height, tx.Transaction.RBF, mixin, foundKey.Label, spenderTransactionId: null, coinJoinInProgress: false); // Don't inherit locked status from key, that's different.
+ var coin = new SmartCoin(tx.GetHash(), i, output.ScriptPubKey, output.Value, tx.Transaction.Inputs.ToTxoRefs().ToArray(), tx.Height, tx.Transaction.RBF, mixin, foundKey.Label, spenderTransactionId: null, false); // Don't inherit locked status from key, that's different.
+ ChaumianClient.State.UpdateCoin(coin);
Coins.TryAdd(coin);
TransactionCache.Add(tx);
if (coin.Unspent && coin.Label == "ZeroLink Change" && ChaumianClient.OnePiece != null)

Fix coin confirmation problems.
Fixes: https://github.com/zkSNACKs/WalletWasabi/issues/579
Fixes: https://github.com/zkSNACKs/WalletWasabi/issues/585