Limit the maximum of the fee chart to the maximum possible fee
MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Send/FeeChartViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Send/FeeChartViewModel.cs
@@ -190,7 +190,7 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
return 0;
}
- public void UpdateFeeEstimates(Dictionary<int, int> feeEstimates)
+ public void UpdateFeeEstimates(Dictionary<int, int> feeEstimates, FeeRate? maxFee = null)
{
var correctedFeeEstimates = DistinctByValues(feeEstimates);
@@ -198,13 +198,40 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
var ys = correctedFeeEstimates.Select(x => (double)x.Value).ToArray();
GetSmoothValuesSubdivide(xs, ys, out var xts, out var yts);
+
+ if (maxFee is { })
+ {
+ for (var i = yts.Count - 1; i >= 0; i--)
+ {
+ if (yts[i] > (double)maxFee.SatoshiPerByte)
+ {
+ yts.RemoveAt(i);
+ xts.RemoveAt(i);
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ foreach (var item in correctedFeeEstimates.ToList())
+ {
+ if (item.Value > maxFee.SatoshiPerByte)
+ {
+ correctedFeeEstimates.Remove(item.Key);
+ }
+ }
+ }
+
var confirmationTargetValues = xts.ToArray();
var satoshiPerByteValues = yts.ToArray();
- var confirmationTargetLabels = correctedFeeEstimates.Select(x => x.Key)
- .Select(x => FeeTargetTimeConverter.Convert(x, "m", "h", "h", "d", "d"))
- .Reverse()
- .ToArray();
+ List<string> confirmationTargetLabels = new();
+ for (int i = 0; i < xts.Count; i += (xts.Count / 5))
+ {
+ var label = FeeTargetTimeConverter.Convert((int)xts[i], "m", "h", "h", "d", "d");
+ confirmationTargetLabels.Add(label);
+ }
_updatingCurrentValue = true;
@@ -219,7 +246,7 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
SatoshiPerByteLabels = null;
}
- ConfirmationTargetLabels = confirmationTargetLabels;
+ ConfirmationTargetLabels = confirmationTargetLabels.ToArray();
ConfirmationTargetValues = confirmationTargetValues;
SatoshiPerByteValues = satoshiPerByteValues;

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Send/SendFeeViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Send/SendFeeViewModel.cs
@@ -67,7 +67,7 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
.ObserveOn(RxApp.MainThreadScheduler)
.Subscribe(estimations =>
{
- FeeChart.UpdateFeeEstimates(_wallet.Network == Network.TestNet ? TestNetFeeEstimates : estimations);
+ FeeChart.UpdateFeeEstimates(_wallet.Network == Network.TestNet ? TestNetFeeEstimates : estimations, _transactionInfo.MaximumPossibleFeeRate);
})
.DisposeWith(disposables);
@@ -79,7 +79,7 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
}
var feeEstimations = _wallet.Network == Network.TestNet ? TestNetFeeEstimates : feeProvider.AllFeeEstimate.Estimations;
- FeeChart.UpdateFeeEstimates(feeEstimations);
+ FeeChart.UpdateFeeEstimates(feeEstimations, _transactionInfo.MaximumPossibleFeeRate);
if (_transactionInfo.FeeRate is { })
{

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Send/TransactionInfo.cs
WalletWasabi.Fluent/ViewModels/Wallets/Send/TransactionInfo.cs
@@ -27,6 +27,8 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
public FeeRate? FeeRate { get; set; }
+ public FeeRate? MaximumPossibleFeeRate { get; set; }
+
public TimeSpan ConfirmationTimeSpan { get; set; }
public IEnumerable<SmartCoin> Coins { get; set; } = Enumerable.Empty<SmartCoin>();

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Send/TransactionPreviewViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Send/TransactionPreviewViewModel.cs
@@ -210,14 +210,15 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
private void SetMaximumPossibleFee(decimal percentageOfOverpayment, Wallet wallet, TransactionInfo transactionInfo)
{
var currentFeeRate = transactionInfo.FeeRate;
- var lowestPossibleFeeRateInSatoshiPerByte = (currentFeeRate.SatoshiPerByte / percentageOfOverpayment) * 100;
- var lowestPossibleFeeRate = new FeeRate(lowestPossibleFeeRateInSatoshiPerByte);
- transactionInfo.FeeRate = lowestPossibleFeeRate;
+ var maxPossibleFeeRateInSatoshiPerByte = (currentFeeRate.SatoshiPerByte / percentageOfOverpayment) * 100;
+ var maxPossibleFeeRate = new FeeRate(maxPossibleFeeRateInSatoshiPerByte);
+ transactionInfo.FeeRate = maxPossibleFeeRate;
+ transactionInfo.MaximumPossibleFeeRate = maxPossibleFeeRate;
var feeChartViewModel = new FeeChartViewModel();
var feeEstimations = wallet.Network == Network.Main ? wallet.FeeProvider.AllFeeEstimate.Estimations : SendFeeViewModel.TestNetFeeEstimates;
feeChartViewModel.UpdateFeeEstimates(feeEstimations);
- var blockTarget = feeChartViewModel.GetConfirmationTarget(lowestPossibleFeeRate);
+ var blockTarget = feeChartViewModel.GetConfirmationTarget(maxPossibleFeeRate);
transactionInfo.ConfirmationTimeSpan = SendFeeViewModel.CalculateConfirmationTime(blockTarget);
}

Limit the maximum of the fee chart to the maximum possible fee