Anonymity set cannot be larger than the number of inputs.
MODIFY
WalletWasabi/Extensions/NBitcoinExtensions.cs
WalletWasabi/Extensions/NBitcoinExtensions.cs
@@ -73,8 +73,14 @@ namespace NBitcoin
public static int GetAnonymitySet(this Transaction me, int outputIndex)
{
+ // 1. Get the output corresponting to the output index.
var output = me.Outputs[outputIndex];
- return me.GetIndistinguishableOutputs(includeSingle: true).Single(x => x.value == output.Value).count;
+ // 2. Get the number of equal outputs.
+ int equalOutputs = me.GetIndistinguishableOutputs(includeSingle: true).Single(x => x.value == output.Value).count;
+ // 3. Anonymity set cannot be larger than the number of inputs.
+ var inputCount = me.Inputs.Count;
+ var anonSet = Math.Min(equalOutputs, inputCount);
+ return equalOutputs;
}
public static int GetAnonymitySet(this Transaction me, uint outputIndex) => GetAnonymitySet(me, (int)outputIndex);

Anonymity set cannot be larger than the number of inputs.