Optimize mixing coin selection:
If only one input is to be registered, prefer the largest one, so more mixing volume is more likely.
Else prefer the lowest amount sum, so perfect mix should be more likely.
MODIFY
WalletWasabi/Models/ChaumianCoinJoin/CcjClientState.cs
WalletWasabi/Models/ChaumianCoinJoin/CcjClientState.cs
@@ -193,12 +193,23 @@ namespace WalletWasabi.Models.ChaumianCoinJoin
for (int i = 1; i <= maximumInputCountPerPeer; i++) // The smallest number of coins we can register the better it is.
{
- IEnumerable<SmartCoin> best = coins.GetPermutations(i)
- .Where(x => x.Sum(y => y.Amount) >= amountNeededExceptInputFees + (feePerInputs * i)) // If the sum reaches the minimum amount.
- .OrderBy(x => x.Count(y => y.Confirmed == false)) // Where the lowest amount of unconfirmed coins there are.
- .ThenBy(x => x.Sum(y => y.AnonymitySet)) // First try t register with the smallest anonymity set.
- .ThenBy(x => x.Sum(y => y.Amount)) // Then the lowest amount, so perfect mix should be more likely.
- .FirstOrDefault();
+ var linq = coins.GetPermutations(i);
+ linq = linq.Where(x => x.Sum(y => y.Amount) >= amountNeededExceptInputFees + (feePerInputs * i)); // If the sum reaches the minimum amount.
+
+ if (i == 1) // If only one input is to be registered, prefer the largest one, so more mixing volume is more likely.
+ {
+ linq = linq.OrderByDescending(x => x.Sum(y => y.Amount));
+ }
+ else // Else prefer the lowest amount sum, so perfect mix should be more likely.
+ {
+ linq = linq.OrderBy(x => x.Sum(y => y.Amount)); // Then the lowest amount, so perfect mix should be more likely.
+ }
+
+ linq = linq.OrderBy(x => x.Sum(y => y.AnonymitySet)); // First try t register with the smallest anonymity set.
+ linq = linq.OrderBy(x => x.Count(y => y.Confirmed == false)); // Where the lowest amount of unconfirmed coins there are.
+
+ IEnumerable<SmartCoin> best = linq.FirstOrDefault();
+
if (best != default)
{
return best.Select(x => x.GetTxoRef()).ToArray();

Optimize mixing coin selection:
If only one input is to be registered, prefer the largest one, so more mixing volume is more likely.
Else prefer the lowest amount sum, so perfect mix should be more likely.