Introduce GetSanityFeeRate
MODIFY
WalletWasabi.Tests/UnitTests/CoordinatorRoundTests.cs
WalletWasabi.Tests/UnitTests/CoordinatorRoundTests.cs
@@ -13,7 +13,7 @@ namespace WalletWasabi.Tests.UnitTests
public class CoordinatorRoundTests
{
[Fact]
- public async Task ssAsync()
+ public async Task SsAsync()
{
var rpc = new MockRpcClient();
var roundConfig = new CoordinatorRoundConfig();
@@ -62,7 +62,7 @@ namespace WalletWasabi.Tests.UnitTests
}
[Fact]
- public async Task xxAsync()
+ public async Task XxAsync()
{
const double DefaultMinMemPoolFee = 0.00001000; // 1 s/b (default value)
const double HighertMinMemPoolFee = 0.00200000; // 200 s/b

MODIFY
WalletWasabi/CoinJoin/Coordinator/Rounds/CoordinatorRound.cs
WalletWasabi/CoinJoin/Coordinator/Rounds/CoordinatorRound.cs
@@ -823,9 +823,8 @@ namespace WalletWasabi.CoinJoin.Coordinator.Rounds
if (optimalFeeRate is { } && optimalFeeRate != FeeRate.Zero && currentFeeRate is { } && currentFeeRate != FeeRate.Zero) // This would be really strange if it'd happen.
{
MemPoolInfo mempoolInfo = await RpcClient.GetMempoolInfoAsync().ConfigureAwait(false);
- FeeRate minMempoolFee = new FeeRate(Money.Coins((decimal)mempoolInfo.MemPoolMinFee));
- var sanityFeeRate = FeeRate.Max(minMempoolFee, new FeeRate(2m)); // 2 s/b
+ var sanityFeeRate = mempoolInfo.GetSanityFeeRate();
optimalFeeRate = optimalFeeRate < sanityFeeRate ? sanityFeeRate : optimalFeeRate;
if (optimalFeeRate < currentFeeRate)
{
@@ -900,8 +899,7 @@ namespace WalletWasabi.CoinJoin.Coordinator.Rounds
try
{
var mempoolInfo = await rpc.GetMempoolInfoAsync().ConfigureAwait(false);
- var minMempoolFee = new FeeRate(Money.Coins((decimal)mempoolInfo.MemPoolMinFee));
- var sanityFeeRate = FeeRate.Max(minMempoolFee, new FeeRate(2m));
+ var sanityFeeRate = mempoolInfo.GetSanityFeeRate();
var estimateSmartFeeResponse = await rpc.EstimateSmartFeeAsync(confirmationTarget, EstimateSmartFeeMode.Conservative, simulateIfRegTest: true).ConfigureAwait(false);

MODIFY
WalletWasabi/Extensions/NBitcoinExtensions.cs
WalletWasabi/Extensions/NBitcoinExtensions.cs
@@ -461,5 +461,16 @@ namespace NBitcoin
}
}
}
+
+ public static FeeRate GetSanityFeeRate(this MemPoolInfo me)
+ {
+ var mempoolMinFee = (decimal)me.MemPoolMinFee;
+
+ // Make sure to be prepare for mempool spikes.
+ var spikeSanity = mempoolMinFee * 1.5m;
+
+ var sanityFee = FeeRate.Max(new FeeRate(Money.Coins(spikeSanity)), new FeeRate(2m));
+ return sanityFee;
+ }
}
}

Introduce GetSanityFeeRate