Add maxNumberOfOutputsAllowed check
MODIFY
WalletWasabi/WabiSabi/Client/AmountDecomposer.cs
WalletWasabi/WabiSabi/Client/AmountDecomposer.cs
@@ -251,7 +251,14 @@ public class AmountDecomposer
// Create many decompositions for optimization.
var stdDenoms = denoms.Where(x => x <= myInputSum).Select(x => (long)x).ToArray();
- foreach (var (sum, count, decomp) in Decomposer.Decompose((long)myInputSum, (long)Math.Max(loss, 0.5 * (ulong)MinAllowedOutputAmountPlusFee), Math.Min(8, Math.Max(5, naiveSet.Count)), stdDenoms))
+ var maxNumberOfOutputsAllowed = Math.Min(AvailableVsize / OutputSize, 8);
+ if (maxNumberOfOutputsAllowed > 1)
+ {
+ foreach (var (sum, count, decomp) in Decomposer.Decompose(
+ target: (long)myInputSum,
+ tolerance: (long)Math.Max(loss, 0.5 * (ulong)MinAllowedOutputAmountPlusFee),
+ maxCount: Math.Min(maxNumberOfOutputsAllowed, Math.Max(5, naiveSet.Count)),
+ stdDenoms: stdDenoms))
{
var currentSet = Decomposer.ToRealValuesArray(
decomp,
@@ -265,6 +272,7 @@ public class AmountDecomposer
}
setCandidates.TryAdd(hash.ToHashCode(), (currentSet, myInputSum - (ulong)currentSet.Sum() + (ulong)count * OutputFee)); // The cost is the remaining + output cost.
}
+ }
var denomHashSet = preFilteredDenoms.ToHashSet();
var finalCandidates = setCandidates.Select(x => x.Value).ToList();

Add maxNumberOfOutputsAllowed check