Define TimeFrames in Constants
MODIFY
WalletWasabi.Fluent/ViewModels/Dialogs/ManualCoinJoinProfileDialogViewModel.cs
WalletWasabi.Fluent/ViewModels/Dialogs/ManualCoinJoinProfileDialogViewModel.cs
@@ -3,6 +3,7 @@ using System.Linq;
using WalletWasabi.Fluent.Validation;
using WalletWasabi.Fluent.ViewModels.CoinJoinProfiles;
using WalletWasabi.Fluent.ViewModels.Dialogs.Base;
+using WalletWasabi.Helpers;
using WalletWasabi.Models;
namespace WalletWasabi.Fluent.ViewModels.Dialogs;
@@ -22,9 +23,9 @@ public partial class ManualCoinJoinProfileDialogViewModel : DialogViewModelBase<
_timeFrames = new[]
{
new TimeFrameItem("None", TimeSpan.Zero),
- new TimeFrameItem("Daily", TimeSpan.FromDays(1)),
- new TimeFrameItem("Weekly", TimeSpan.FromDays(7)),
- new TimeFrameItem("Monthly", TimeSpan.FromDays(30))
+ new TimeFrameItem("Daily", TimeSpan.FromHours(Constants.CoinJoinFeeRateAverageTimeFrames[0])),
+ new TimeFrameItem("Weekly", TimeSpan.FromHours(Constants.CoinJoinFeeRateAverageTimeFrames[1])),
+ new TimeFrameItem("Monthly", TimeSpan.FromHours(Constants.CoinJoinFeeRateAverageTimeFrames[2]))
};
_selectedTimeFrame = _timeFrames.FirstOrDefault(tf => tf.TimeFrame == TimeSpan.FromHours(current.FeeRateAverageTimeFrameHours)) ?? _timeFrames.First();

MODIFY
WalletWasabi/Blockchain/Keys/KeyManager.cs
WalletWasabi/Blockchain/Keys/KeyManager.cs
@@ -715,6 +715,11 @@ public class KeyManager
public void SetFeeRateAverageTimeFrame(int hours, bool toFile = true)
{
+ if (hours != 0 && !Constants.CoinJoinFeeRateAverageTimeFrames.Contains(hours))
+ {
+ throw new ArgumentOutOfRangeException(nameof(hours), $"Hours can be only on of {string.Join(",", Constants.CoinJoinFeeRateAverageTimeFrames)}.");
+ }
+
FeeRateAverageTimeFrameHours = hours;
if (toFile)
{

MODIFY
WalletWasabi/Helpers/Constants.cs
WalletWasabi/Helpers/Constants.cs
@@ -62,6 +62,9 @@ public static class Constants
public static readonly Version BitcoinCoreVersion = new("21.2");
public static readonly Version LegalDocumentsVersion = new(2, 0);
+ // Defined in hours. Do not modify these values or the order!
+ public static readonly int[] CoinJoinFeeRateAverageTimeFrames = new[] { 24, 168, 720 };
+
public static readonly NodeRequirement NodeRequirements = new()
{
RequiredServices = NodeServices.NODE_WITNESS,

MODIFY
WalletWasabi/WabiSabi/Backend/Statistics/CoinJoinFeeRateStatStore.cs
WalletWasabi/WabiSabi/Backend/Statistics/CoinJoinFeeRateStatStore.cs
@@ -7,6 +7,7 @@ using System.Threading;
using System.Threading.Tasks;
using WalletWasabi.Bases;
using WalletWasabi.BitcoinCore.Rpc;
+using WalletWasabi.Helpers;
using WalletWasabi.WabiSabi.Models;
namespace WalletWasabi.WabiSabi.Backend.Statistics;
@@ -26,12 +27,7 @@ public class CoinJoinFeeRateStatStore : PeriodicRunner
{
}
- private static TimeSpan[] TimeFrames { get; } = new[]
- {
- TimeSpan.FromDays(1),
- TimeSpan.FromDays(7),
- TimeSpan.FromDays(30),
- };
+ private static TimeSpan[] TimeFrames { get; } = Constants.CoinJoinFeeRateAverageTimeFrames.Select(tf => TimeSpan.FromHours(tf)).ToArray();
private static TimeSpan MaximumTimeToStore { get; } = TimeFrames.Max();

Define TimeFrames in Constants