Fix overcharging network fees after basedenomination and distributing the difference among active denomination.
MODIFY
WalletWasabi.Backend/Controllers/ChaumianCoinJoinController.cs
WalletWasabi.Backend/Controllers/ChaumianCoinJoinController.cs
@@ -292,7 +292,7 @@ namespace WalletWasabi.Backend.Controllers
}
// Make sure Alice checks work.
- var alice = new Alice(inputs, networkFeeToPay, request.ChangeOutputAddress, acceptedBlindedOutputScripts);
+ var alice = new Alice(inputs, networkFeeToPayAfterBaseDenomination, request.ChangeOutputAddress, acceptedBlindedOutputScripts);
foreach (Guid aliceToRemove in alicesToRemove)
{
@@ -393,10 +393,6 @@ namespace WalletWasabi.Backend.Controllers
int takeBlindCount = round.EstimateBestMixingLevel(alice);
var prevBlindCount = alice.BlindedOutputScripts.Length;
- for (int i = 0; i < prevBlindCount - takeBlindCount; i++)
- {
- alice.NetworkFeeToPay -= round.FeePerOutputs;
- }
alice.BlindedOutputScripts = alice.BlindedOutputScripts.Take(takeBlindCount).ToArray();
alice.BlindedOutputSignatures = alice.BlindedOutputSignatures.Take(takeBlindCount).ToArray();
resp.BlindedOutputSignatures = alice.BlindedOutputSignatures; // Don't give back more mixing levels than we'll use.

MODIFY
WalletWasabi/Models/ChaumianCoinJoin/Alice.cs
WalletWasabi/Models/ChaumianCoinJoin/Alice.cs
@@ -15,7 +15,7 @@ namespace WalletWasabi.Models.ChaumianCoinJoin
public Money InputSum { get; }
- public Money NetworkFeeToPay { get; set; }
+ public Money NetworkFeeToPayAfterBaseDenomination { get; }
public IEnumerable<Coin> Inputs { get; }
@@ -27,10 +27,10 @@ namespace WalletWasabi.Models.ChaumianCoinJoin
public uint256[] BlindedOutputSignatures { get; set; }
- public Alice(IEnumerable<Coin> inputs, Money networkFeeToPay, BitcoinAddress changeOutputAddress, IEnumerable<uint256> blindedOutputScripts)
+ public Alice(IEnumerable<Coin> inputs, Money networkFeeToPayAfterBaseDenomination, BitcoinAddress changeOutputAddress, IEnumerable<uint256> blindedOutputScripts)
{
Inputs = Guard.NotNullOrEmpty(nameof(inputs), inputs);
- NetworkFeeToPay = Guard.NotNull(nameof(networkFeeToPay), networkFeeToPay);
+ NetworkFeeToPayAfterBaseDenomination = Guard.NotNull(nameof(networkFeeToPayAfterBaseDenomination), networkFeeToPayAfterBaseDenomination);
BlindedOutputScripts = blindedOutputScripts?.ToArray() ?? new uint256[0];

MODIFY
WalletWasabi/Models/ChaumianCoinJoin/CcjRound.cs
WalletWasabi/Models/ChaumianCoinJoin/CcjRound.cs
@@ -322,7 +322,7 @@ namespace WalletWasabi.Models.ChaumianCoinJoin
}
Money changeAmount = alice.InputSum;
- changeAmount -= alice.NetworkFeeToPay;
+ changeAmount -= alice.NetworkFeeToPayAfterBaseDenomination;
changeAmount -= newDenomination;
changeAmount -= coordinatorBaseFeePerAlice;
@@ -519,7 +519,7 @@ namespace WalletWasabi.Models.ChaumianCoinJoin
private Money CalculateNewDenomination()
{
// 1. Set new denomination: minor optimization.
- return Alices.Min(x => x.InputSum - x.NetworkFeeToPay);
+ return Alices.Min(x => x.InputSum - x.NetworkFeeToPayAfterBaseDenomination);
}
public async Task ProgressToOutputRegistrationOrFailAsync(params Alice[] additionalAlicesToBan)

MODIFY
WalletWasabi/Services/CcjClient.cs
WalletWasabi/Services/CcjClient.cs
@@ -367,7 +367,7 @@ namespace WalletWasabi.Services
minAmountBack -= minimumChangeAmount; // Minus coordinator protections (so it won't create bad coinjoins.)
}
- if (amountBack < minAmountBack && !amountBack.Almost(minAmountBack, Money.Satoshis(10000))) // Just in case.
+ if (amountBack < minAmountBack && !amountBack.Almost(minAmountBack, Money.Satoshis(1000))) // Just in case. Rounding error maybe?
{
Money diff = minAmountBack - amountBack;
throw new NotSupportedException($"Coordinator did not add enough value to our outputs in the coinjoin. Missing: {diff.Satoshi} satoshis.");

Fix overcharging network fees after basedenomination and distributing the difference among active denomination.