Raise events in order Spent first, Recived later
MODIFY
WalletWasabi.Tests/IntegrationTests/RegTests.cs
WalletWasabi.Tests/IntegrationTests/RegTests.cs
@@ -3446,7 +3446,8 @@ namespace WalletWasabi.Tests.IntegrationTests
{
try
{
- await wallet.ChaumianClient.DequeueAllCoinsFromMixAsync("");
+ await chaumianClient.DequeueAllCoinsFromMixAsync("");
+ await chaumianClient2.DequeueAllCoinsFromMixAsync("");
break;
}
catch (NotSupportedException)

MODIFY
WalletWasabi/Models/CoinsRegistry.cs
WalletWasabi/Models/CoinsRegistry.cs
@@ -36,9 +36,9 @@ namespace WalletWasabi.Models
LatestCoinsSnapshot = Coins.ToHashSet(); // Creates a clone
InvalidateSnapshot = false;
}
- }
return new CoinsView(LatestCoinsSnapshot);
}
+ }
public bool IsEmpty => !AsCoinsView().Any();
@@ -90,6 +90,7 @@ namespace WalletWasabi.Models
{
if (Coins.Remove(spentCoin))
{
+ InvalidateSnapshot = true;
SpentCoins.Add(spentCoin);
var createdCoins = CreatedBy(spentCoin.SpenderTransactionId);
foreach (var newCoin in createdCoins)
@@ -102,7 +103,6 @@ namespace WalletWasabi.Models
}
}
}
- InvalidateSnapshot = true;
}
}
@@ -136,7 +136,7 @@ namespace WalletWasabi.Models
{
lock (Lock)
{
- return new CoinsView(AsCoinsView().Concat(SpentCoins));
+ return new CoinsView(AsCoinsView().Concat(SpentCoins).ToList());
}
}

MODIFY
WalletWasabi/Services/TransactionProcessor.cs
WalletWasabi/Services/TransactionProcessor.cs
@@ -135,6 +135,7 @@ namespace WalletWasabi.Services
}
}
+ List<SmartCoin> newCoins = new List<SmartCoin>();
List<SmartCoin> spentOwnCoins = null;
for (var i = 0U; i < tx.Transaction.Outputs.Count; i++)
{
@@ -162,7 +163,7 @@ namespace WalletWasabi.Services
// If we did not have it.
if (Coins.TryAdd(newCoin))
{
- CoinReceived?.Invoke(this, newCoin);
+ newCoins.Add(newCoin);
// Make sure there's always 21 clean keys generated and indexed.
KeyManager.AssertCleanKeysIndexed(isInternal: foundKey.IsInternal);
@@ -212,6 +213,11 @@ namespace WalletWasabi.Services
}
}
+ foreach(var newCoin in newCoins)
+ {
+ CoinReceived?.Invoke(this, newCoin);
+ }
+
if (walletRelevant)
{
TransactionStore.AddOrUpdate(tx);

Raise events in order Spent first, Recived later