Add comments to explain anonset calculation.
MODIFY
WalletWasabi/Blockchain/TransactionProcessing/TransactionProcessor.cs
WalletWasabi/Blockchain/TransactionProcessing/TransactionProcessor.cs
@@ -180,10 +180,19 @@ namespace WalletWasabi.Blockchain.TransactionProcessing
}
spentOwnCoins ??= Coins.OutPoints(tx.Transaction.Inputs).ToList();
+
+ // Get the anonymity set of i-th output in the transaction.
var anonset = tx.Transaction.GetAnonymitySet(i);
+ // If we provided inputs to the transaction.
if (spentOwnCoins.Count != 0)
{
- anonset += spentOwnCoins.Min(x => x.AnonymitySet) - 1; // Minus 1, because do not count own.
+ // Take the input that we provided with the the smallest anonset.
+ // And add that to the base anonset from the tx.
+ // Our smallest anonset input is the relevant here, because this way the common input ownership heuristic is considered.
+ // Take minus 1, because we do not want to count own into the anonset, so...
+ // If the anonset of our UTXO would be 1, and the smallest anonset of our inputs would be 1, too, then we don't make...
+ // The new UTXO's anonset 2, but only 1.
+ anonset += spentOwnCoins.Min(x => x.AnonymitySet) - 1;
}
SmartCoin newCoin = new SmartCoin(txId, i, output.ScriptPubKey, output.Value, tx.Transaction.Inputs.ToOutPoints().ToArray(), tx.Height, tx.IsRBF, anonset, foundKey.Label, spenderTransactionId: null, false, pubKey: foundKey); // Do not inherit locked status from key, that's different.

Add comments to explain anonset calculation.