Put `vsize` limitation back in place
MODIFY
WalletWasabi/WabiSabi/Client/AmountDecomposer.cs
WalletWasabi/WabiSabi/Client/AmountDecomposer.cs
@@ -9,11 +9,12 @@ namespace WalletWasabi.WabiSabi.Client
{
public class AmountDecomposer
{
- public AmountDecomposer(FeeRate feeRate, MoneyRange allowedOutputAmount, int outputSize)
+ public AmountDecomposer(FeeRate feeRate, Money minAllowedOutputAmount, int outputSize, int availableVsize)
{
OutputSize = outputSize;
FeeRate = feeRate;
- MinimumAmountPlusFee = allowedOutputAmount.Min + OutputFee;
+ AvailableVsize = availableVsize;
+ MinimumAmountPlusFee = minAllowedOutputAmount + OutputFee;
StandardDenominationsPlusFee = StandardDenomination.Values
.Select(x => x + OutputFee)
.OrderByDescending(x => x)
@@ -21,7 +22,7 @@ namespace WalletWasabi.WabiSabi.Client
}
public FeeRate FeeRate { get; }
-
+ public int AvailableVsize { get; }
public Money MinimumAmountPlusFee { get; }
public Money OutputFee => FeeRate.GetFee(OutputSize);
public int OutputSize { get; }
@@ -41,6 +42,7 @@ namespace WalletWasabi.WabiSabi.Client
.ToArray();
List<Money> outputAmounts = new();
+ var remainingVsize = AvailableVsize;
foreach (var denom in denoms.Where(x => x <= remaining))
{
@@ -48,11 +50,16 @@ namespace WalletWasabi.WabiSabi.Client
{
break;
}
+ if (remainingVsize < 2 * OutputSize)
+ {
+ break;
+ }
while (denom <= remaining)
{
outputAmounts.Add(denom);
remaining -= denom;
+ remainingVsize -= OutputSize;
}
}
@@ -61,7 +68,7 @@ namespace WalletWasabi.WabiSabi.Client
outputAmounts.Add(remaining);
}
- return outputAmounts.Select(x => x - OutputFee);
+ return outputAmounts;
}
private Dictionary<Money, uint> GetDenominationProbabilities(IEnumerable<Coin> allInputCoins)

MODIFY
WalletWasabi/WabiSabi/Client/CoinJoinClient.cs
WalletWasabi/WabiSabi/Client/CoinJoinClient.cs
@@ -106,8 +106,9 @@ namespace WalletWasabi.WabiSabi.Client
// Calculate outputs values
roundState = await RoundStatusUpdater.CreateRoundAwaiter(rs => rs.Id == roundState.Id, cancellationToken).ConfigureAwait(false);
constructionState = roundState.Assert<ConstructionState>();
- AmountDecomposer amountDecomposer = new(roundState.FeeRate, roundState.CoinjoinState.Parameters.AllowedOutputAmounts, Constants.OutputSizeInBytes); // OutputSizeInBytes is 33?
- var outputValues = amountDecomposer.Decompose(smartCoins.Select(sm => sm.Coin), constructionState.Inputs);
+ AmountDecomposer amountDecomposer = new(roundState.FeeRate, roundState.CoinjoinState.Parameters.AllowedOutputAmounts.Min, Constants.P2WPKHOutputSizeInBytes, (int)availableVsize);
+ var theirCoins = constructionState.Inputs.Except(registeredCoins);
+ var outputValues = amountDecomposer.Decompose(registeredCoins, theirCoins);
// Get all locked internal keys we have and assert we have enough.
Keymanager.AssertLockedInternalKeysIndexed(howMany: outputValues.Count());

Put `vsize` limitation back in place