Always add coord fee
MODIFY
WalletWasabi/WabiSabi/Backend/Rounds/Arena.cs
WalletWasabi/WabiSabi/Backend/Rounds/Arena.cs
@@ -174,6 +174,28 @@ namespace WalletWasabi.WabiSabi.Backend.Rounds
round.LogInfo($"{coinjoin.Inputs.Count} inputs were added.");
round.LogInfo($"{coinjoin.Outputs.Count} outputs were added.");
+ coinjoin = AddCoordinatorFee(round, coinjoin);
+
+ if (!allReady)
+ {
+ coinjoin = AddBlameScript(round, coinjoin);
+ }
+
+ round.CoinjoinState = coinjoin.Finalize();
+
+ round.SetPhase(Phase.TransactionSigning);
+ }
+ }
+ catch (Exception ex)
+ {
+ round.SetPhase(Phase.Ended);
+ round.LogError(ex.Message);
+ }
+ }
+ }
+
+ private ConstructionState AddBlameScript(Round round, ConstructionState coinjoin)
+ {
long aliceSum = round.Alices.Sum(x => x.CalculateRemainingAmountCredentials(round.FeeRate, round.CoordinationFeeRate));
long bobSum = round.Bobs.Sum(x => x.CredentialAmount);
var diff = aliceSum - bobSum;
@@ -181,12 +203,20 @@ namespace WalletWasabi.WabiSabi.Backend.Rounds
// If timeout we must fill up the outputs to build a reasonable transaction.
// This won't be signed by the alice who failed to provide output, so we know who to ban.
var diffMoney = Money.Satoshis(diff) - coinjoin.Parameters.FeeRate.GetFee(Config.BlameScript.EstimateOutputVsize());
- if (!allReady && diffMoney > coinjoin.Parameters.AllowedOutputAmounts.Min)
+ if (diffMoney > coinjoin.Parameters.AllowedOutputAmounts.Min)
{
coinjoin = round.AddOutput(new TxOut(diffMoney, Config.BlameScript));
round.LogInfo("Filled up the outputs to build a reasonable transaction because some alice failed to provide its output.");
}
else
+ {
+ round.LogWarning($"Could not add blame script, because the amount was too small: {nameof(diffMoney)}: {diffMoney}.");
+ }
+
+ return coinjoin;
+ }
+
+ private ConstructionState AddCoordinatorFee(Round round, ConstructionState coinjoin)
{
var coordinatorScriptPubKey = Config.GetNextCleanCoordinatorScript();
var coordinationFee = round.Alices.Sum(x => round.CoordinationFeeRate.GetFee(x.Coin.Amount));
@@ -198,21 +228,10 @@ namespace WalletWasabi.WabiSabi.Backend.Rounds
}
else
{
- round.LogWarning($"Coordinator fee wasn't taken, because it was too small: {nameof(diffMoney)}: {diffMoney}, {nameof(allReady)}: {allReady}.");
+ round.LogWarning($"Coordinator fee wasn't taken, because it was too small: {nameof(coordinationFee)}: {coordinationFee}.");
}
- }
-
- round.CoinjoinState = coinjoin.Finalize();
- round.SetPhase(Phase.TransactionSigning);
- }
- }
- catch (Exception ex)
- {
- round.SetPhase(Phase.Ended);
- round.LogError(ex.Message);
- }
- }
+ return coinjoin;
}
private async Task StepTransactionSigningPhaseAsync(CancellationToken cancellationToken)

MODIFY
WalletWasabi/WabiSabi/Backend/WabiSabiConfig.cs
WalletWasabi/WabiSabi/Backend/WabiSabiConfig.cs
@@ -98,7 +98,7 @@ namespace WalletWasabi.WabiSabi.Backend
[DefaultValue(1)]
[JsonProperty(PropertyName = "CoordinatorExtPubKeyCurrentDepth", DefaultValueHandling = DefaultValueHandling.Populate)]
- public int CoordinatorExtPubKeyCurrentDepth { get; private set; }
+ public int CoordinatorExtPubKeyCurrentDepth { get; private set; } = 1;
/// <summary>
/// If money comes to the blame script, then either an attacker lost money or there's a client bug.

Always add coord fee