Move privacy levels into WalletSettings
MODIFY
WalletWasabi.Fluent/ViewModels/MainViewModel.cs
WalletWasabi.Fluent/ViewModels/MainViewModel.cs
@@ -183,13 +183,6 @@ public partial class MainViewModel : ViewModelBase
return _settingsPage;
});
- PrivacySettingsTabViewModel.RegisterLazy(
- () =>
- {
- _settingsPage.SelectedTab = 1;
- return _settingsPage;
- });
-
NetworkSettingsTabViewModel.RegisterLazy(
() =>
{

DELETE
WalletWasabi.Fluent/ViewModels/Settings/PrivacySettingsTabViewModel.cs
-using System.Reactive.Linq;
-using ReactiveUI;
-
-namespace WalletWasabi.Fluent.ViewModels.Settings;
-
-[NavigationMetaData(
- Title = "Privacy",
- Caption = "Manage privacy settings",
- Order = 1,
- Category = "Settings",
- Keywords = new[] { "Settings", "Privacy", "Minimal", "Medium", "Strong", "Anonymity", "Level" },
- IconName = "settings_privacy_regular")]
-public partial class PrivacySettingsTabViewModel : SettingsTabViewModelBase
-{
- [AutoNotify] private int _minAnonScoreTarget;
- [AutoNotify] private int _maxAnonScoreTarget;
-
- public PrivacySettingsTabViewModel()
- {
- _minAnonScoreTarget = Services.Config.MinAnonScoreTarget;
- _maxAnonScoreTarget = Services.Config.MaxAnonScoreTarget;
-
- this.WhenAnyValue(
- x => x.MinAnonScoreTarget,
- x => x.MaxAnonScoreTarget)
- .ObserveOn(RxApp.TaskpoolScheduler)
- .Throttle(TimeSpan.FromMilliseconds(ThrottleTime))
- .Skip(1)
- .Subscribe(_ => Save());
-
- this.WhenAnyValue(x => x.MinAnonScoreTarget)
- .Subscribe(
- x =>
- {
- if (x >= MaxAnonScoreTarget)
- {
- MaxAnonScoreTarget = x + 1;
- }
- });
-
- this.WhenAnyValue(x => x.MaxAnonScoreTarget)
- .Subscribe(
- x =>
- {
- if (x <= MinAnonScoreTarget)
- {
- MinAnonScoreTarget = x - 1;
- }
- });
- }
-
- protected override void EditConfigOnSave(Config config)
- {
- config.MinAnonScoreTarget = MinAnonScoreTarget;
- config.MaxAnonScoreTarget = MaxAnonScoreTarget;
- }
-}

MODIFY
WalletWasabi.Fluent/ViewModels/Settings/SettingsPageViewModel.cs
WalletWasabi.Fluent/ViewModels/Settings/SettingsPageViewModel.cs
@@ -12,7 +12,7 @@ namespace WalletWasabi.Fluent.ViewModels.Settings;
Caption = "Manage appearance, privacy and other settings",
Order = 1,
Category = "General",
- Keywords = new[] { "Settings", "General", "User", "Interface", "Privacy", "Advanced" },
+ Keywords = new[] { "Settings", "General", "User", "Interface", "Advanced" },
IconName = "settings_regular",
Searchable = false,
NavBarPosition = NavBarPosition.Bottom)]
@@ -26,7 +26,6 @@ public partial class SettingsPageViewModel : NavBarItemViewModel
_selectedTab = 0;
GeneralSettingsTab = new GeneralSettingsTabViewModel();
- PrivacySettingsTab = new PrivacySettingsTabViewModel();
NetworkSettingsTab = new NetworkSettingsTabViewModel();
BitcoinTabSettings = new BitcoinTabSettingsViewModel();
@@ -36,7 +35,6 @@ public partial class SettingsPageViewModel : NavBarItemViewModel
public ICommand RestartCommand { get; }
public GeneralSettingsTabViewModel GeneralSettingsTab { get; }
- public PrivacySettingsTabViewModel PrivacySettingsTab { get; }
public NetworkSettingsTabViewModel NetworkSettingsTab { get; }
public BitcoinTabSettingsViewModel BitcoinTabSettings { get; }

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/WalletSettingsViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/WalletSettingsViewModel.cs
@@ -9,6 +9,8 @@ public partial class WalletSettingsViewModel : RoutableViewModel
{
[AutoNotify] private bool _preferPsbtWorkflow;
[AutoNotify] private bool _autoCoinJoin;
+ [AutoNotify] private int _minAnonScoreTarget;
+ [AutoNotify] private int _maxAnonScoreTarget;
public WalletSettingsViewModel(WalletViewModelBase walletViewModelBase)
{
@@ -42,6 +44,40 @@ public partial class WalletSettingsViewModel : RoutableViewModel
wallet.KeyManager.AutoCoinJoin = x;
wallet.KeyManager.ToFile();
});
+
+ _minAnonScoreTarget = wallet.KeyManager.MinAnonScoreTarget;
+ _maxAnonScoreTarget = wallet.KeyManager.MaxAnonScoreTarget;
+
+ this.WhenAnyValue(
+ x => x.MinAnonScoreTarget,
+ x => x.MaxAnonScoreTarget)
+ .ObserveOn(RxApp.TaskpoolScheduler)
+ .Throttle(TimeSpan.FromMilliseconds(1000))
+ .Skip(1)
+ .Subscribe(_ =>
+ {
+ wallet.KeyManager.SetAnonScoreTargets(MinAnonScoreTarget, MaxAnonScoreTarget);
+ });
+
+ this.WhenAnyValue(x => x.MinAnonScoreTarget)
+ .Subscribe(
+ x =>
+ {
+ if (x >= MaxAnonScoreTarget)
+ {
+ MaxAnonScoreTarget = x + 1;
+ }
+ });
+
+ this.WhenAnyValue(x => x.MaxAnonScoreTarget)
+ .Subscribe(
+ x =>
+ {
+ if (x <= MinAnonScoreTarget)
+ {
+ MinAnonScoreTarget = x - 1;
+ }
+ });
}
public bool IsHardwareWallet { get; }

DELETE
WalletWasabi.Fluent/Views/Settings/PrivacySettingsTabView.axaml
-<UserControl xmlns="https://github.com/avaloniaui"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:settings="using:WalletWasabi.Fluent.ViewModels.Settings"
- mc:Ignorable="d" d:DesignWidth="428" d:DesignHeight="371"
- x:Class="WalletWasabi.Fluent.Views.Settings.PrivacySettingsTabView"
- x:DataType="settings:PrivacySettingsTabViewModel"
- x:CompileBindings="True">
- <StackPanel Classes="settingsLayout">
-
- <StackPanel Spacing="10">
- <TextBlock Text="Minimum Anonymity Score Target" />
- <DockPanel>
- <PathIcon ToolTip.Tip="Min" DockPanel.Dock="Left" Foreground="{StaticResource PrivacyLevelMinimalBrush}"
- Data="{StaticResource privacy_minimal}" />
- <TextBlock MinWidth="24" DockPanel.Dock="Right" Text="{Binding MinAnonScoreTarget}" VerticalAlignment="Center" />
- <Slider Minimum="2" Maximum="98" Value="{Binding MinAnonScoreTarget}" Margin="10 0" />
- </DockPanel>
- </StackPanel>
-
- <StackPanel Spacing="10">
- <TextBlock Text="Maximum Anonymity Score Target" />
- <DockPanel>
- <PathIcon ToolTip.Tip="Max" DockPanel.Dock="Left" Foreground="{StaticResource PrivacyLevelMediumBrush}"
- Data="{StaticResource privacy_medium}" />
- <TextBlock MinWidth="24" DockPanel.Dock="Right" Text="{Binding MaxAnonScoreTarget}" VerticalAlignment="Center" />
- <Slider Minimum="3" Maximum="99" Value="{Binding MaxAnonScoreTarget}" Margin="10 0" />
- </DockPanel>
- </StackPanel>
- </StackPanel>
-</UserControl>

DELETE
WalletWasabi.Fluent/Views/Settings/PrivacySettingsTabView.axaml.cs
-using Avalonia.Controls;
-using Avalonia.Markup.Xaml;
-
-namespace WalletWasabi.Fluent.Views.Settings;
-
-public class PrivacySettingsTabView : UserControl
-{
- public PrivacySettingsTabView()
- {
- InitializeComponent();
- }
-
- private void InitializeComponent()
- {
- AvaloniaXamlLoader.Load(this);
- }
-}

MODIFY
WalletWasabi.Fluent/Views/Settings/SettingsPageView.axaml
WalletWasabi.Fluent/Views/Settings/SettingsPageView.axaml
<v:GeneralSettingsTabView DataContext="{Binding GeneralSettingsTab}" />
</TabItem>
- <TabItem Header="Privacy">
- <v:PrivacySettingsTabView DataContext="{Binding PrivacySettingsTab}" />
- </TabItem>
-
<TabItem Header="Network">
<v:NetworkSettingsTabView DataContext="{Binding NetworkSettingsTab}" />
</TabItem>

MODIFY
WalletWasabi.Fluent/Views/Wallets/WalletSettingsView.axaml
WalletWasabi.Fluent/Views/Wallets/WalletSettingsView.axaml
<TextBlock Text="Auto CoinJoin" />
<ToggleSwitch IsChecked="{Binding AutoCoinJoin}" />
</DockPanel>
+
+ <StackPanel Spacing="10">
+ <TextBlock Text="Minimum Anonymity Score Target" />
+ <DockPanel>
+ <PathIcon ToolTip.Tip="Min" DockPanel.Dock="Left" Foreground="{StaticResource PrivacyLevelMinimalBrush}"
+ Data="{StaticResource privacy_minimal}" />
+ <TextBlock MinWidth="24" DockPanel.Dock="Right" Text="{Binding MinAnonScoreTarget}" VerticalAlignment="Center" />
+ <Slider Minimum="2" Maximum="98" Value="{Binding MinAnonScoreTarget}" Margin="10 0" />
+ </DockPanel>
+ </StackPanel>
+ <StackPanel Spacing="10">
+ <TextBlock Text="Maximum Anonymity Score Target" />
+ <DockPanel>
+ <PathIcon ToolTip.Tip="Max" DockPanel.Dock="Left" Foreground="{StaticResource PrivacyLevelMediumBrush}"
+ Data="{StaticResource privacy_medium}" />
+ <TextBlock MinWidth="24" DockPanel.Dock="Right" Text="{Binding MaxAnonScoreTarget}" VerticalAlignment="Center" />
+ <Slider Minimum="3" Maximum="99" Value="{Binding MaxAnonScoreTarget}" Margin="10 0" />
+ </DockPanel>
+ </StackPanel>
</StackPanel>
<Separator />

MODIFY
WalletWasabi/Blockchain/Keys/KeyManager.cs
WalletWasabi/Blockchain/Keys/KeyManager.cs
@@ -158,11 +158,11 @@ public class KeyManager
public string? Icon { get; private set; }
[DefaultValue(DefaultMinAnonScoreTarget)]
- [JsonProperty(PropertyName = "MinAnonScoreTarget", DefaultValueHandling = DefaultValueHandling.Populate)]
+ [JsonProperty(Order = 13, PropertyName = "MinAnonScoreTarget", DefaultValueHandling = DefaultValueHandling.Populate)]
public int MinAnonScoreTarget { get; private set; }
[DefaultValue(DefaultMaxAnonScoreTarget)]
- [JsonProperty(PropertyName = "MaxAnonScoreTarget", DefaultValueHandling = DefaultValueHandling.Populate)]
+ [JsonProperty(Order = 14, PropertyName = "MaxAnonScoreTarget", DefaultValueHandling = DefaultValueHandling.Populate)]
public int MaxAnonScoreTarget { get; private set; }
[JsonProperty(Order = 999)]
@@ -698,6 +698,17 @@ public class KeyManager
SetIcon(type.ToString());
}
+ public void SetAnonScoreTargets(int minAnonScoreTarget, int maxAnonScoreTarget)
+ {
+ MinAnonScoreTarget = minAnonScoreTarget;
+ if (MaxAnonScoreTarget < MinAnonScoreTarget)
+ {
+ throw new ArgumentException($"{nameof(maxAnonScoreTarget)} should be greater.", nameof(maxAnonScoreTarget));
+ }
+ MaxAnonScoreTarget = maxAnonScoreTarget;
+ ToFile();
+ }
+
public void AssertNetworkOrClearBlockState(Network expectedNetwork)
{
lock (BlockchainStateLock)

Move privacy levels into WalletSettings