remove legacy optimise privacy (change avoidance) code.
DELETE
WalletWasabi.Fluent/ViewModels/Wallets/Send/OptimisePrivacyViewModel.cs
-using NBitcoin;
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Linq;
-using System.Reactive;
-using System.Reactive.Concurrency;
-using System.Reactive.Disposables;
-using System.Reactive.Linq;
-using System.Threading.Tasks;
-using ReactiveUI;
-using WalletWasabi.Blockchain.TransactionBuilding;
-using WalletWasabi.Fluent.Helpers;
-using WalletWasabi.Fluent.Models;
-using WalletWasabi.Fluent.ViewModels.Dialogs.Base;
-using WalletWasabi.Fluent.ViewModels.Navigation;
-using WalletWasabi.Wallets;
-
-namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
-{
- [NavigationMetaData(Title = "Optimise your privacy")]
- public partial class OptimisePrivacyViewModel : DialogViewModelBase<BuildTransactionResult>
- {
- private readonly TransactionInfo _transactionInfo;
- private readonly Wallet _wallet;
- private readonly BuildTransactionResult _requestedTransaction;
-
- [AutoNotify] private ObservableCollection<PrivacySuggestionControlViewModel> _privacySuggestions;
- [AutoNotify] private PrivacySuggestionControlViewModel? _selectedPrivacySuggestion;
- [AutoNotify] private bool _exactAmountWarningVisible;
- private PrivacySuggestionControlViewModel? _defaultSelection;
-
- public OptimisePrivacyViewModel(Wallet wallet,
- TransactionInfo transactionInfo, BuildTransactionResult requestedTransaction)
- {
- _wallet = wallet;
- _requestedTransaction = requestedTransaction;
- _transactionInfo = transactionInfo;
-
- this.WhenAnyValue(x => x.SelectedPrivacySuggestion)
- .Where(x => x is { })
- .Subscribe(x => ExactAmountWarningVisible = x != _defaultSelection);
-
- _privacySuggestions = new ObservableCollection<PrivacySuggestionControlViewModel>();
-
- SetupCancel(enableCancel: false, enableCancelOnEscape: true, enableCancelOnPressed: false);
- EnableBack = true;
-
- Tuple<bool, string> s = new Tuple<bool, string>(false, "");
- var h = s.Item1;
-
- NextCommand = ReactiveCommand.Create(
- Complete,
- this.WhenAnyValue(x => x.SelectedPrivacySuggestion).Select(x => x is { }));
- }
-
- private void Complete()
- {
- Close(DialogResultKind.Normal, SelectedPrivacySuggestion!.TransactionResult);
- }
-
- protected override void OnNavigatedTo(bool inHistory, CompositeDisposable disposables)
- {
- base.OnNavigatedTo(inHistory, disposables);
-
- if (!inHistory)
- {
- RxApp.MainThreadScheduler.Schedule(async () =>
- {
- IsBusy = true;
-
- var intent = new PaymentIntent(
- _transactionInfo.Address,
- MoneyRequest.CreateAllRemaining(subtractFee: true),
- _transactionInfo.UserLabels);
-
- PrivacySuggestionControlViewModel? smallerSuggestion = null;
-
- if (_requestedTransaction.SpentCoins.Count() > 1)
- {
- var smallerTransaction = await Task.Run(() => _wallet.BuildTransaction(
- _wallet.Kitchen.SaltSoup(),
- intent,
- FeeStrategy.CreateFromFeeRate(_transactionInfo.FeeRate),
- allowUnconfirmed: true,
- _requestedTransaction
- .SpentCoins
- .OrderBy(x => x.Amount)
- .Skip(1)
- .Select(x => x.OutPoint)));
-
- smallerSuggestion = new PrivacySuggestionControlViewModel(
- _transactionInfo.Amount.ToDecimal(MoneyUnit.BTC), smallerTransaction,
- PrivacyOptimisationLevel.Better, _wallet.Synchronizer.UsdExchangeRate, new PrivacySuggestionBenefit(true, "Improved Privacy"));
- }
-
- _defaultSelection = new PrivacySuggestionControlViewModel(
- _transactionInfo.Amount.ToDecimal(MoneyUnit.BTC), _requestedTransaction,
- PrivacyOptimisationLevel.Standard, _wallet.Synchronizer.UsdExchangeRate, new PrivacySuggestionBenefit(false, "As Requested"));
-
- var largerTransaction = await Task.Run(() => _wallet.BuildTransaction(
- _wallet.Kitchen.SaltSoup(),
- intent,
- FeeStrategy.CreateFromFeeRate(_transactionInfo.FeeRate),
- true,
- _requestedTransaction.SpentCoins.Select(x => x.OutPoint)));
-
- var largerSuggestion = new PrivacySuggestionControlViewModel(
- _transactionInfo.Amount.ToDecimal(MoneyUnit.BTC), largerTransaction,
- PrivacyOptimisationLevel.Better, _wallet.Synchronizer.UsdExchangeRate, new PrivacySuggestionBenefit(true, "Improved Privacy"));
-
- // There are several scenarios, both the alternate suggestions are <, or >, or 1 < and 1 >.
- // We sort them and add the suggestions accordingly.
- var suggestions = new List<PrivacySuggestionControlViewModel> { _defaultSelection, largerSuggestion };
-
- if (smallerSuggestion is { })
- {
- suggestions.Add(smallerSuggestion);
- }
-
- foreach (var suggestion in NormalizeSuggestions(suggestions, _defaultSelection))
- {
- _privacySuggestions.Add(suggestion);
- }
-
- SelectedPrivacySuggestion = _defaultSelection;
-
- IsBusy = false;
- });
- }
- }
-
- private IEnumerable<PrivacySuggestionControlViewModel> NormalizeSuggestions(
- IEnumerable<PrivacySuggestionControlViewModel> suggestions, PrivacySuggestionControlViewModel defaultSuggestion)
- {
- var normalized = suggestions
- .OrderBy(x => x.TransactionResult.CalculateDestinationAmount())
- .ToList();
-
- if (normalized.Count == 3)
- {
- var index = normalized.IndexOf(defaultSuggestion);
-
- switch (index)
- {
- case 1:
- break;
-
- case 0:
- normalized = normalized.Take(2).ToList();
- break;
-
- case 2:
- normalized = normalized.Skip(1).ToList();
- break;
- }
- }
-
- return normalized;
- }
- }
-}

DELETE
WalletWasabi.Fluent/ViewModels/Wallets/Send/PrivacySuggestionControlViewModel.cs
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using DynamicData;
-using NBitcoin;
-using WalletWasabi.Blockchain.TransactionBuilding;
-using WalletWasabi.Fluent.Helpers;
-using WalletWasabi.Fluent.Models;
-
-namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
-{
- public enum PrivacyOptimisationLevel
- {
- Standard,
- Better
- }
-
- public partial class PrivacySuggestionControlViewModel : ViewModelBase
- {
- [AutoNotify] private string _amount;
- [AutoNotify] private string _amountFiat;
- [AutoNotify] private List<PrivacySuggestionBenefit> _benefits;
- [AutoNotify] private PrivacyOptimisationLevel _optimisationLevel;
- [AutoNotify] private bool _optimisationLevelGood;
-
- public PrivacySuggestionControlViewModel(
- decimal originalAmount,
- BuildTransactionResult transactionResult,
- PrivacyOptimisationLevel optimisationLevel,
- decimal fiatExchangeRate,
- params PrivacySuggestionBenefit[] benefits)
- {
- TransactionResult = transactionResult;
- _optimisationLevel = optimisationLevel;
- _benefits = benefits.ToList();
-
- decimal total = transactionResult.CalculateDestinationAmount().ToDecimal(MoneyUnit.BTC);
-
- var fiatTotal = total * fiatExchangeRate;
-
- _amountFiat = total.GenerateFiatText(fiatExchangeRate, "USD");
- _optimisationLevelGood = optimisationLevel == PrivacyOptimisationLevel.Better;
-
- if (_optimisationLevelGood)
- {
- var fiatOriginal = originalAmount * fiatExchangeRate;
- var fiatDifference = fiatTotal - fiatOriginal;
-
- var difference = (fiatDifference > 0
- ? $"{fiatDifference.GenerateFiatText("USD")} More"
- : $"{Math.Abs(fiatDifference).GenerateFiatText("USD")} Less")
- .Replace("(", "").Replace(")", "");
-
- _benefits.Add(new(false, difference));
- }
- else
- {
- // This is just to pad the control.
- _benefits.Add(new(false, " "));
- }
-
- _amount = $"{total}";
- }
-
- public BuildTransactionResult TransactionResult { get; }
- }
-}
\ No newline at end of file

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Send/TransactionPreviewViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Send/TransactionPreviewViewModel.cs
@@ -31,6 +31,12 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
public BuildTransactionResult TransactionResult { get; protected set; }
}
+ public enum PrivacyOptimisationLevel
+ {
+ Standard,
+ Better
+ }
+
public partial class ChangeAvoidanceSuggestionViewModel : SuggestionViewModel
{
[AutoNotify] private string _amount;
@@ -351,8 +357,6 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
AdjustFeeCommand = ReactiveCommand.CreateFromTask(OnAdjustFeeAsync);
- AvoidChangeCommand = ReactiveCommand.CreateFromTask(OnAvoidChangeAsync);
-
ChangePocketsCommand = ReactiveCommand.CreateFromTask(OnChangePocketsAsync);
}
@@ -368,8 +372,6 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
public ICommand AdjustFeeCommand { get; }
- public ICommand AvoidChangeCommand { get; }
-
public ICommand ChangePocketsCommand { get; }
private async Task OnExportPsbtAsync()
@@ -412,17 +414,6 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
}
}
- private async Task OnAvoidChangeAsync()
- {
- var optimisePrivacyDialog =
- await NavigateDialogAsync(new OptimisePrivacyViewModel(_wallet, _info, _transaction!));
-
- if (optimisePrivacyDialog.Kind == DialogResultKind.Normal && optimisePrivacyDialog.Result is { })
- {
- UpdateTransaction(CurrentTransactionSummary, optimisePrivacyDialog.Result);
- }
- }
-
private async Task OnChangePocketsAsync()
{
var selectPocketsDialog =

DELETE
WalletWasabi.Fluent/Views/Wallets/Send/OptimisePrivacyView.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:i="clr-namespace:Avalonia.Xaml.Interactivity;assembly=Avalonia.Xaml.Interactivity"
- xmlns:behaviors="using:WalletWasabi.Fluent.Behaviors"
- xmlns:c="using:WalletWasabi.Fluent.Controls"
- xmlns:local="using:WalletWasabi.Fluent.Views.Wallets.Send"
- xmlns:vm="using:WalletWasabi.Fluent.ViewModels.Wallets.Send"
- xmlns:converters="clr-namespace:WalletWasabi.Fluent.Converters"
- mc:Ignorable="d"
- x:DataType="vm:OptimisePrivacyViewModel"
- x:CompileBindings="True"
- x:Class="WalletWasabi.Fluent.Views.Wallets.Send.OptimisePrivacyView">
-
- <DockPanel>
- <Panel DockPanel.Dock="Bottom" Height="25">
- <c:InfoMessage
- Opacity="{Binding ExactAmountWarningVisible, Converter={x:Static converters:BoolOpacityConverters.BoolToOpacity}}"
- VerticalAlignment="Bottom" HorizontalAlignment="Center"
- Content="Some services only accept the exact amount that was requested."
- Foreground="{DynamicResource PrivacyLevelMediumBrush}" />
- </Panel>
- <ListBox DockPanel.Dock="Top" Background="Transparent" VerticalAlignment="Center" HorizontalAlignment="Center"
- Items="{Binding PrivacySuggestions}" SelectedItem="{Binding SelectedPrivacySuggestion}">
- <ListBox.Styles>
- <Style Selector="ListBoxItem">
- <Setter Property="Cursor" Value="Hand" />
- </Style>
- <Style Selector="ListBoxItem /template/ ContentPresenter#PART_ContentPresenter">
- <Setter Property="Background" Value="Transparent" />
- </Style>
- <Style Selector="ListBoxItem:pointerover /template/ ContentPresenter#PART_ContentPresenter">
- <Setter Property="Background" Value="Transparent" />
- </Style>
- <Style Selector="ListBoxItem:selected /template/ ContentPresenter#PART_ContentPresenter">
- <Setter Property="Background" Value="Transparent" />
- </Style>
-
- <Style Selector="ListBoxItem Border#PART_MainContentBorder">
- <Setter Property="Padding" Value="30,45,30,40" />
- <Setter Property="CornerRadius" Value="4" />
- <Setter Property="Margin" Value="5" />
- </Style>
-
- <Style Selector="ListBoxItem Border#PART_DecorationBorder">
- <Setter Property="Padding" Value="15 30 15 30" />
- <Setter Property="CornerRadius" Value="4" />
- <Setter Property="Margin" Value="14" />
-
- <Setter Property="BorderBrush" Value="#14FFFFFF" />
- <Setter Property="BorderThickness" Value="1" />
- <Setter Property="Background" Value="{StaticResource OptimizePrivacyOptionSelectedColor}" />
- <Setter Property="BoxShadow" Value="{StaticResource OptimizePrivacyOptionBoxShadow1}" />
-
- <Setter Property="Opacity" Value="0" />
-
- <Setter Property="Transitions">
- <Transitions>
- <DoubleTransition Property="Opacity"
- Easing="{StaticResource FluentEasing}"
- Duration="0:0:0.25" />
- </Transitions>
- </Setter>
- </Style>
-
- <Style Selector="ListBoxItem:selected Border#PART_DecorationBorder">
- <Setter Property="Opacity" Value="1" />
- </Style>
- </ListBox.Styles>
- <ListBox.ItemsPanel>
- <ItemsPanelTemplate>
- <WrapPanel Orientation="Horizontal" />
- </ItemsPanelTemplate>
- </ListBox.ItemsPanel>
- <ListBox.ItemTemplate>
- <DataTemplate>
- <local:PrivacySuggestionControl />
- </DataTemplate>
- </ListBox.ItemTemplate>
- </ListBox>
- </DockPanel>
-</UserControl>
\ No newline at end of file

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

remove legacy optimise privacy (change avoidance) code.