Add sanity check to ensure ExposedKeys are cleaned up before usage.
MODIFY
WalletWasabi/CoinJoin/Client/Clients/CoinJoinClient.cs
WalletWasabi/CoinJoin/Client/Clients/CoinJoinClient.cs
@@ -608,6 +608,7 @@ namespace WalletWasabi.CoinJoin.Client.Clients
}
}
+ CleanNonLockedExposedKeys();
var keysToSurelyRegister = ExposedLinks.Where(x => coinsToRegister.Contains(x.Key)).SelectMany(x => x.Value).Select(x => x.Key).ToArray();
var keysTryNotToRegister = ExposedLinks.SelectMany(x => x.Value).Select(x => x.Key).Except(keysToSurelyRegister).ToArray();
@@ -685,6 +686,19 @@ namespace WalletWasabi.CoinJoin.Client.Clients
return (change, actives);
}
+ private void CleanNonLockedExposedKeys()
+ {
+ // Remove non-locked exposed keys.
+ foreach (var key in ExposedLinks.Keys.ToArray())
+ {
+ ExposedLinks[key] = ExposedLinks[key].Where(x => x.Key.KeyState == KeyState.Locked).ToArray();
+ if (!ExposedLinks[key].Any())
+ {
+ ExposedLinks.TryRemove(key, out _);
+ }
+ }
+ }
+
public async Task QueueCoinsToMixAsync(params SmartCoin[] coins)
=> await QueueCoinsToMixAsync(coins as IEnumerable<SmartCoin>).ConfigureAwait(false);

Add sanity check to ensure ExposedKeys are cleaned up before usage.