Add PlebsDontPay configurable
MODIFY
WalletWasabi.Tests/Helpers/WabiSabiFactory.cs
WalletWasabi.Tests/Helpers/WabiSabiFactory.cs
@@ -52,7 +52,7 @@ namespace WalletWasabi.Tests.Helpers
Network.Main,
new InsecureRandom(),
new FeeRate(100m),
- new CoordinationFeeRate(0.003m)));
+ new CoordinationFeeRate(0.003m, Money.Zero)));
round.MaxVsizeAllocationPerAlice = 11 + 31 + MultipartyTransactionParameters.SharedOverhead;
return round;
}

MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Client/AmountDecomposerTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Client/AmountDecomposerTests.cs
@@ -31,7 +31,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Client
{
var availableVsize = maxAvailableOutputs * Constants.P2wpkhOutputSizeInBytes;
var feeRate = new FeeRate(feeRateDecimal);
- var coordinationFeeRate = new CoordinationFeeRate(0.01m);
+ var coordinationFeeRate = new CoordinationFeeRate(0.01m, Money.Zero);
var feePerOutput = feeRate.GetFee(Constants.P2wpkhOutputSizeInBytes);
var registeredCoins = GenerateRandomCoins().Take(3).ToList();
var theirCoins = GenerateRandomCoins().Take(30).ToList();

MODIFY
WalletWasabi/Crypto/StrobeProtocol/StrobeHasher.cs
WalletWasabi/Crypto/StrobeProtocol/StrobeHasher.cs
@@ -69,6 +69,10 @@ namespace WalletWasabi.Crypto.StrobeProtocol
return this;
}
+ public StrobeHasher Append(string fieldName, CoordinationFeeRate coordinationFeeRate)
+ => Append($"{fieldName}.Rate", coordinationFeeRate.Rate)
+ .Append($"{fieldName}.PlebsDontPayThreshold", coordinationFeeRate.PlebsDontPayThreshold);
+
public uint256 GetHash()
{
return new uint256(_strobe.Prf(32, false));

MODIFY
WalletWasabi/JsonConverters/CoordinationFeeRateJsonConverter.cs
WalletWasabi/JsonConverters/CoordinationFeeRateJsonConverter.cs
using NBitcoin;
using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
using WalletWasabi.WabiSabi.Models;
namespace WalletWasabi.JsonConverters
@@ -7,15 +8,24 @@ namespace WalletWasabi.JsonConverters
public class CoordinationFeeRateJsonConverter : JsonConverter<CoordinationFeeRate>
{
/// <inheritdoc />
- public override CoordinationFeeRate ReadJson(JsonReader reader, Type objectType, CoordinationFeeRate existingValue, bool hasExistingValue, JsonSerializer serializer) =>
- reader.Value switch
+ public override CoordinationFeeRate ReadJson(JsonReader reader, Type objectType, CoordinationFeeRate existingValue, bool hasExistingValue, JsonSerializer serializer)
{
- double rate => new CoordinationFeeRate((decimal)rate),
- _ => throw new JsonSerializationException("CoordinationFeeRate is null.")
- };
+ JObject item = JObject.Load(reader);
+
+ var rate = item.GetValue("Rate", StringComparison.OrdinalIgnoreCase)?.Value<decimal>() ?? throw new JsonSerializationException("Rate is null.");
+ var plebsDontPayThreshold = item.GetValue("PlebsDontPayThreshold", StringComparison.OrdinalIgnoreCase)?.Value<long>() ?? throw new JsonSerializationException("PlebsDontPayThreshold is null.");
+ return new CoordinationFeeRate(rate, Money.Satoshis(plebsDontPayThreshold));
+ }
/// <inheritdoc />
- public override void WriteJson(JsonWriter writer, CoordinationFeeRate value, JsonSerializer serializer) =>
+ public override void WriteJson(JsonWriter writer, CoordinationFeeRate value, JsonSerializer serializer)
+ {
+ writer.WriteStartObject();
+ writer.WritePropertyName("Rate");
writer.WriteValue(value.Rate);
+ writer.WritePropertyName("PlebsDontPayThreshold");
+ writer.WriteValue(value.PlebsDontPayThreshold);
+ writer.WriteEndObject();
+ }
}
}

MODIFY
WalletWasabi/JsonConverters/DefaultValueCoordinatorFeeRateAttribute.cs
WalletWasabi/JsonConverters/DefaultValueCoordinatorFeeRateAttribute.cs
+using NBitcoin;
using System.ComponentModel;
using WalletWasabi.WabiSabi.Models;
@@ -5,7 +6,8 @@ namespace WalletWasabi.JsonConverters
{
public class DefaultValueCoordinationFeeRateAttribute : DefaultValueAttribute
{
- public DefaultValueCoordinationFeeRateAttribute(double value) : base(new CoordinationFeeRate((decimal)value))
+ public DefaultValueCoordinationFeeRateAttribute(double feeRate, double plebsDontPayThreshold)
+ : base(new CoordinationFeeRate((decimal)feeRate, Money.Coins((decimal)plebsDontPayThreshold)))
{
}
}

MODIFY
WalletWasabi/WabiSabi/Backend/Rounds/Round.cs
WalletWasabi/WabiSabi/Backend/Rounds/Round.cs
@@ -11,6 +11,7 @@ namespace WalletWasabi.WabiSabi.Backend.Rounds
public class Round
{
private uint256 _id;
+
public Round(RoundParameters roundParameters)
{
RoundParameters = roundParameters;
@@ -135,7 +136,7 @@ namespace WalletWasabi.WabiSabi.Backend.Rounds
CoinjoinState.Parameters.AllowedOutputTypes,
CoinjoinState.Parameters.Network,
CoinjoinState.Parameters.FeeRate.FeePerK,
- CoinjoinState.Parameters.CoordinationFeeRate.Rate,
+ CoinjoinState.Parameters.CoordinationFeeRate,
CoinjoinState.Parameters.MaxTransactionSize,
CoinjoinState.Parameters.MinRelayTxFee.FeePerK,
MaxAmountCredentialValue,

MODIFY
WalletWasabi/WabiSabi/Backend/WabiSabiConfig.cs
WalletWasabi/WabiSabi/Backend/WabiSabiConfig.cs
@@ -87,10 +87,14 @@ namespace WalletWasabi.WabiSabi.Backend
public int MinInputCountByRound => Math.Max(1, (int)(MaxInputCountByRound * MinInputCountByRoundMultiplier));
- [DefaultValueCoordinationFeeRate(0.003)]
+ [DefaultValueCoordinationFeeRate(0.003, 0.01)]
[JsonProperty(PropertyName = "CoordinationFeeRate", DefaultValueHandling = DefaultValueHandling.Populate)]
[JsonConverter(typeof(CoordinationFeeRateJsonConverter))]
- public CoordinationFeeRate CoordinationFeeRate { get; set; } = new CoordinationFeeRate(0.003m);
+ public CoordinationFeeRate CoordinationFeeRate { get; set; } = new CoordinationFeeRate(0.003m, Money.Coins(0.01m));
+
+ [DefaultValue(0.01)]
+ [JsonProperty(PropertyName = "PlebsDontPayThreshold", DefaultValueHandling = DefaultValueHandling.Populate)]
+ public double PlebsDontPayThreshold { get; set; } = 0.01;
[JsonProperty(PropertyName = "CoordinatorExtPubKey")]
[JsonConverter(typeof(ExtPubKeyJsonConverter))]

MODIFY
WalletWasabi/WabiSabi/Crypto/RoundHasher.cs
WalletWasabi/WabiSabi/Crypto/RoundHasher.cs
@@ -20,7 +20,7 @@ namespace WalletWasabi.WabiSabi.Crypto
ImmutableSortedSet<ScriptType> allowedOutputTypes,
Network network,
long feePerK,
- decimal coordinationFeRate,
+ CoordinationFeeRate coordinationFeRate,
int maxTransactionSize,
long minRelayTxFeePerK,
long maxAmountCredentialValue,

MODIFY
WalletWasabi/WabiSabi/Models/CoordinationFeeRate.cs
WalletWasabi/WabiSabi/Models/CoordinationFeeRate.cs
@@ -5,19 +5,21 @@ namespace WalletWasabi.WabiSabi.Models
{
public struct CoordinationFeeRate
{
- public static readonly CoordinationFeeRate Zero = new(0);
+ public static readonly CoordinationFeeRate Zero = new(0, 0);
- public CoordinationFeeRate(decimal rate)
+ public CoordinationFeeRate(decimal rate, Money plebsDontPayThreshold)
{
Rate = Guard.InRangeAndNotNull(nameof(rate), rate, 0m, 0.01m);
+ PlebsDontPayThreshold = plebsDontPayThreshold;
}
public decimal Rate { get; }
+ public Money PlebsDontPayThreshold { get; }
public Money GetFee(Money amount)
{
// Under 100 000 satoshis plebs don't have to pay.
- if (amount <= Money.Coins(0.001m))
+ if (amount <= PlebsDontPayThreshold)
{
return Money.Zero;
}

MODIFY
WalletWasabi/WabiSabi/Models/RoundState.cs
WalletWasabi/WabiSabi/Models/RoundState.cs
@@ -76,7 +76,7 @@ namespace WalletWasabi.WabiSabi.Models
CoinjoinState.Parameters.AllowedOutputTypes,
CoinjoinState.Parameters.Network,
CoinjoinState.Parameters.FeeRate.FeePerK,
- CoinjoinState.Parameters.CoordinationFeeRate.Rate,
+ CoinjoinState.Parameters.CoordinationFeeRate,
CoinjoinState.Parameters.MaxTransactionSize,
CoinjoinState.Parameters.MinRelayTxFee.FeePerK,
MaxAmountCredentialValue,

Add PlebsDontPay configurable