introduce TransactionFeeHelper
ADD
WalletWasabi.Fluent/Helpers/TransactionFeeHelper.cs
+using System;
+using System.Collections.Generic;
+using NBitcoin;
+using WalletWasabi.Wallets;
+
+namespace WalletWasabi.Fluent.Helpers
+{
+ public static class TransactionFeeHelper
+ {
+ public static Dictionary<int, int> GetFeeEstimates(Wallet wallet)
+ {
+ if (wallet.FeeProvider.AllFeeEstimate is null)
+ {
+ throw new InvalidOperationException($"Not possible to get the fee estimates. {nameof(wallet.FeeProvider.AllFeeEstimate)} is null.");
+ }
+
+ return wallet.Network == Network.TestNet ? TestNetFeeEstimates : wallet.FeeProvider.AllFeeEstimate.Estimations;
+ }
+
+ private static readonly Dictionary<int, int> TestNetFeeEstimates = new()
+ {
+ [1] = 17,
+ [2] = 12,
+ [3] = 9,
+ [6] = 9,
+ [18] = 2,
+ [36] = 2,
+ [72] = 2,
+ [144] = 2,
+ [432] = 1,
+ [1008] = 1
+ };
+ }
+}

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Send/SendFeeViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Send/SendFeeViewModel.cs
@@ -8,6 +8,7 @@ using System.Threading.Tasks;
using NBitcoin;
using ReactiveUI;
using WalletWasabi.Blockchain.Analysis.FeesEstimation;
+using WalletWasabi.Fluent.Helpers;
using WalletWasabi.Fluent.ViewModels.Dialogs.Base;
using WalletWasabi.Wallets;
@@ -67,7 +68,7 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
.ObserveOn(RxApp.MainThreadScheduler)
.Subscribe(estimations =>
{
- FeeChart.UpdateFeeEstimates(_wallet.Network == Network.TestNet ? TestNetFeeEstimates : estimations);
+ FeeChart.UpdateFeeEstimates(TransactionFeeHelper.GetFeeEstimates(_wallet));
})
.DisposeWith(disposables);
@@ -78,8 +79,7 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
await Task.Delay(100);
}
- var feeEstimations = _wallet.Network == Network.TestNet ? TestNetFeeEstimates : feeProvider.AllFeeEstimate.Estimations;
- FeeChart.UpdateFeeEstimates(feeEstimations);
+ FeeChart.UpdateFeeEstimates(TransactionFeeHelper.GetFeeEstimates(_wallet));
if (_transactionInfo.FeeRate is { })
{
@@ -125,19 +125,5 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
var time = TimeSpan.FromMinutes(timeInMinutes);
return time;
}
-
- private static readonly Dictionary<int, int> TestNetFeeEstimates = new()
- {
- [1] = 17,
- [2] = 12,
- [3] = 9,
- [6] = 9,
- [18] = 2,
- [36] = 2,
- [72] = 2,
- [144] = 2,
- [432] = 1,
- [1008] = 1
- };
}
}

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Send/TransactionPreviewViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Send/TransactionPreviewViewModel.cs
@@ -35,6 +35,7 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
[AutoNotify] private string _amountText = "";
[AutoNotify] private bool _transactionHasChange;
[AutoNotify] private bool _transactionHasPockets;
+ [AutoNotify] private bool _adjustFeeAvailable;
public TransactionPreviewViewModel(Wallet wallet, TransactionInfo info)
{
@@ -69,6 +70,7 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
AvoidChangeCommand = ReactiveCommand.CreateFromTask(OnAvoidChangeAsync);
ChangePocketsCommand = ReactiveCommand.CreateFromTask(OnChangePocketsAsync);
+
}
public bool PreferPsbtWorkflow => _wallet.KeyManager.PreferPsbtWorkflow;

introduce TransactionFeeHelper