Add MaxSuggestedAmount to MultipartyTransactionParameters
MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Client/CoinJoinCoinSelectionTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Client/CoinJoinCoinSelectionTests.cs
@@ -5,6 +5,7 @@ using NBitcoin;
using WalletWasabi.Blockchain.Keys;
using WalletWasabi.Blockchain.TransactionOutputs;
using WalletWasabi.Crypto.Randomness;
+using WalletWasabi.Helpers;
using WalletWasabi.Tests.Helpers;
using WalletWasabi.WabiSabi.Client;
using WalletWasabi.WabiSabi.Models;
@@ -154,7 +155,8 @@ public class CoinJoinCoinSelectionTests
CoordinationFeeRate.Zero,
reasonableRange,
reasonableRange,
- Network.Main);
+ Network.Main,
+ Money.Coins(Constants.MaximumNumberOfBitcoins));
return txParams;
}
}

MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Models/MultipartyTransactionTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Models/MultipartyTransactionTests.cs
@@ -6,13 +6,21 @@ using WalletWasabi.WabiSabi.Models;
using WalletWasabi.WabiSabi.Models.MultipartyTransaction;
using WalletWasabi.Tests.Helpers;
using Xunit;
+using WalletWasabi.Helpers;
namespace WalletWasabi.Tests.UnitTests.WabiSabi.Models;
public class MultipartyTransactionTests
{
private static MoneyRange DefaultAllowedAmounts = new(Money.Zero, Money.Coins(1));
- private static MultipartyTransactionParameters DefaultParameters = new(FeeRate.Zero, CoordinationFeeRate.Zero, DefaultAllowedAmounts, DefaultAllowedAmounts, Network.Main);
+
+ private static MultipartyTransactionParameters DefaultParameters = new(
+ FeeRate.Zero,
+ CoordinationFeeRate.Zero,
+ DefaultAllowedAmounts,
+ DefaultAllowedAmounts,
+ Network.Main,
+ Money.Coins(Constants.MaximumNumberOfBitcoins));
private static void ThrowsProtocolException(WabiSabiProtocolErrorCode expectedError, Action action) =>
Assert.Equal(expectedError, Assert.Throws<WabiSabiProtocolException>(action).ErrorCode);

MODIFY
WalletWasabi/WabiSabi/Backend/Rounds/Round.cs
WalletWasabi/WabiSabi/Backend/Rounds/Round.cs
@@ -17,7 +17,13 @@ public class Round
RoundParameters = roundParameters;
var allowedAmounts = new MoneyRange(roundParameters.MinRegistrableAmount, RoundParameters.MaxRegistrableAmount);
- var txParams = new MultipartyTransactionParameters(roundParameters.FeeRate, roundParameters.CoordinationFeeRate, allowedAmounts, allowedAmounts, roundParameters.Network);
+ var txParams = new MultipartyTransactionParameters(
+ roundParameters.FeeRate,
+ roundParameters.CoordinationFeeRate,
+ allowedAmounts,
+ allowedAmounts,
+ roundParameters.Network,
+ roundParameters.MaxSuggestedAmount);
CoinjoinState = new ConstructionState(txParams);
InitialInputVsizeAllocation = CoinjoinState.Parameters.MaxTransactionSize - MultipartyTransactionParameters.SharedOverhead;
@@ -33,7 +39,6 @@ public class Round
ConnectionConfirmationTimeFrame = TimeFrame.Create(RoundParameters.ConnectionConfirmationTimeout);
OutputRegistrationTimeFrame = TimeFrame.Create(RoundParameters.OutputRegistrationTimeout);
TransactionSigningTimeFrame = TimeFrame.Create(RoundParameters.TransactionSigningTimeout);
- MaxSuggestedAmount = roundParameters.MaxSuggestedAmount;
}
public uint256 Id => _id ??= CalculateHash();
@@ -65,7 +70,7 @@ public class Round
protected RoundParameters RoundParameters { get; }
public Script CoordinatorScript { get; set; }
- public Money MaxSuggestedAmount { get; }
+ public Money MaxSuggestedAmount => RoundParameters.MaxSuggestedAmount;
public TState Assert<TState>() where TState : MultipartyTransactionState =>
CoinjoinState switch

MODIFY
WalletWasabi/WabiSabi/Client/CoinJoinClient.cs
WalletWasabi/WabiSabi/Client/CoinJoinClient.cs
@@ -366,6 +366,7 @@ public class CoinJoinClient
internal static ImmutableList<SmartCoin> SelectCoinsForRound(IEnumerable<SmartCoin> coins, MultipartyTransactionParameters parameters, bool consolidationMode, int minAnonScoreTarget, WasabiRandom rnd)
{
var filteredCoins = coins
+ .Where(x => x.Amount < parameters.MaxSuggestedAmount)
.Where(x => parameters.AllowedInputAmounts.Contains(x.Amount))
.Where(x => parameters.AllowedInputTypes.Any(t => x.ScriptPubKey.IsScriptType(t)))
.ToShuffled() // Preshuffle before ordering.

MODIFY
WalletWasabi/WabiSabi/Models/MultipartyTransaction/MultipartyTransactionParameters.cs
WalletWasabi/WabiSabi/Models/MultipartyTransaction/MultipartyTransactionParameters.cs
using NBitcoin;
using NBitcoin.Policy;
using System.Collections.Immutable;
+using WalletWasabi.Helpers;
namespace WalletWasabi.WabiSabi.Models.MultipartyTransaction;
@@ -18,13 +19,15 @@ public record MultipartyTransactionParameters
Models.CoordinationFeeRate coordinationFeeRate,
MoneyRange allowedInputAmounts,
MoneyRange allowedOutputAmounts,
- Network network)
+ Network network,
+ Money maxSuggestedAmount)
{
FeeRate = feeRate;
CoordinationFeeRate = coordinationFeeRate;
AllowedInputAmounts = allowedInputAmounts;
AllowedOutputAmounts = allowedOutputAmounts;
Network = network;
+ MaxSuggestedAmount = maxSuggestedAmount;
}
// These parameters need to be committed to the transcript, but we want
@@ -41,6 +44,7 @@ public record MultipartyTransactionParameters
public MoneyRange AllowedInputAmounts { get; init; }
public MoneyRange AllowedOutputAmounts { get; init; }
public Network Network { get; }
+ public Money MaxSuggestedAmount { get; }
// implied:
// segwit transaction

Add MaxSuggestedAmount to MultipartyTransactionParameters