Mark keys with dust as used
MODIFY
WalletWasabi.Tests/UnitTests/Transactions/TransactionProcessorTests.cs
WalletWasabi.Tests/UnitTests/Transactions/TransactionProcessorTests.cs
@@ -645,6 +645,23 @@ namespace WalletWasabi.Tests.UnitTests.Transactions
Assert.Empty(matureTxs);
}
+ [Fact]
+ public async Task ReceiveManyConsecutiveTransactionWithDustForWalletAsync()
+ {
+ var transactionProcessor = await CreateTransactionProcessorAsync();
+ var keys = transactionProcessor.KeyManager.GetKeys();
+
+ foreach (var key in keys.Take(5))
+ {
+ transactionProcessor.Process(
+ CreateCreditingTransaction(key.P2wpkhScript, Money.Coins(0.000099m)));
+ }
+
+ // It is relevant even when all the coins can be dust.
+ Assert.All(keys.Take(5), key => Assert.Equal( KeyState.Used, key.KeyState));
+ Assert.All(keys.Skip(5), key => Assert.Equal( KeyState.Clean, key.KeyState));
+ }
+
[Fact]
public async Task ReceiveCoinJoinTransactionAsync()
{

MODIFY
WalletWasabi/Blockchain/TransactionProcessing/TransactionProcessor.cs
WalletWasabi/Blockchain/TransactionProcessing/TransactionProcessor.cs
@@ -172,13 +172,13 @@ namespace WalletWasabi.Blockchain.TransactionProcessing
HdPubKey foundKey = KeyManager.GetKeyForScriptPubKey(output.ScriptPubKey);
if (foundKey != default)
{
+ foundKey.SetKeyState(KeyState.Used, KeyManager);
if (output.Value <= DustThreshold)
{
result.ReceivedDusts.Add(output);
continue;
}
- foundKey.SetKeyState(KeyState.Used, KeyManager);
spentOwnCoins ??= Coins.OutPoints(tx.Transaction.Inputs).ToList();
var anonset = tx.Transaction.GetAnonymitySet(i);
if (spentOwnCoins.Count != 0)

Mark keys with dust as used