implement PrivacyOptimisationSuggestion data calculations.
MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Send/OptimisePrivacyViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Send/OptimisePrivacyViewModel.cs
@@ -58,10 +58,10 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
.Skip(1)
.Select(x => x.OutPoint));
- _privacySuggestions.Add(new PrivacySuggestionControlViewModel(smallerTransaction, PrivacyOptimisationLevel.Better, "Improved Privacy", "Save on Transaction Fee", "Send Less"));
+ _privacySuggestions.Add(new PrivacySuggestionControlViewModel(_transactionInfo.Amount.ToDecimal(MoneyUnit.BTC), smallerTransaction, PrivacyOptimisationLevel.Better, "Improved Privacy", "Save on Transaction Fee", "Send Less"));
}
- var exactSuggestion = new PrivacySuggestionControlViewModel(_requestedTransaction, PrivacyOptimisationLevel.Standard, "Send the Exact Amount");
+ var exactSuggestion = new PrivacySuggestionControlViewModel(_transactionInfo.Amount.ToDecimal(MoneyUnit.BTC), _requestedTransaction, PrivacyOptimisationLevel.Standard, "Send the Exact Amount");
_privacySuggestions.Add(exactSuggestion);
@@ -72,7 +72,7 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
allowUnconfirmed: true,
_requestedTransaction.SpentCoins.Select(x => x.OutPoint));
- _privacySuggestions.Add(new PrivacySuggestionControlViewModel(largerTransaction, PrivacyOptimisationLevel.Better, "Improved Privacy", "Save on Transaction Fee"));
+ _privacySuggestions.Add(new PrivacySuggestionControlViewModel(_transactionInfo.Amount.ToDecimal(MoneyUnit.BTC), largerTransaction, PrivacyOptimisationLevel.Better, "Improved Privacy", "Save on Transaction Fee"));
SelectedPrivacySuggestion = exactSuggestion;

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Send/PrivacySuggestionControlViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Send/PrivacySuggestionControlViewModel.cs
+using System;
using System.Linq;
+using NBitcoin;
using WalletWasabi.Blockchain.TransactionBuilding;
namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
@@ -13,18 +15,43 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
{
private readonly BuildTransactionResult _transactionResult;
- public PrivacySuggestionControlViewModel(BuildTransactionResult transactionResult, PrivacyOptimisationLevel optimisationLevel, params string[] benefits)
+ public PrivacySuggestionControlViewModel(decimal originalAmount, BuildTransactionResult transactionResult, PrivacyOptimisationLevel optimisationLevel, params string[] benefits)
{
_transactionResult = transactionResult;
_optimisationLevel = optimisationLevel;
_benefits = benefits;
- var total = transactionResult.OuterWalletOutputs.Sum(x => x.Amount);
- var fee = transactionResult.Fee;
- var feePercent = transactionResult.FeePercentOfSent;
+ decimal total;
+
+ if (optimisationLevel == PrivacyOptimisationLevel.Better)
+ {
+ total = transactionResult.OuterWalletOutputs
+ .Select(x => x.Amount)
+ .Concat(transactionResult.InnerWalletOutputs.Select(x => x.Amount))
+ .Sum().ToDecimal(MoneyUnit.BTC);
+
+ var pcDifference = ((total - originalAmount) / originalAmount) * 100;
+
+ _caption = pcDifference > 0 ? $"{pcDifference:F}% More" : $"{Math.Abs(pcDifference):F}% Less";
+ }
+ else
+ {
+ if (!transactionResult.OuterWalletOutputs.Any()) // self spend
+ {
+ total = transactionResult.InnerWalletOutputs
+ .Where(x => !x.HdPubKey.IsInternal)
+ .Select(x => x.Amount)
+ .Sum().ToDecimal(MoneyUnit.BTC);
+ }
+ else
+ {
+ total = transactionResult.OuterWalletOutputs
+ .Select(x => x.Amount)
+ .Sum().ToDecimal(MoneyUnit.BTC);
+ }
+ }
_title = $"{total} BTC";
- _caption = $"Fee: {feePercent}% ({fee})";
}
[AutoNotify] private string _title;

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Send/SendViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Send/SendViewModel.cs
@@ -45,6 +45,7 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
[AutoNotify] private double[] _xAxisValues;
[AutoNotify] private double[] _yAxisValues;
[AutoNotify] private string[] _xAxisLabels;
+ [AutoNotify] private double _xAxisCurrentValue = 36;
private string? _payJoinEndPoint;
private bool _parsingUrl;
@@ -348,8 +349,6 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
public ICommand PasteCommand { get; }
- public double XAxisCurrentValue { get; set; } = 36;
-
public double XAxisMinValue { get; set; } = 1;
public double XAxisMaxValue { get; set; } = 1008;

MODIFY
WalletWasabi.Fluent/Views/Wallets/Send/SendView.axaml
WalletWasabi.Fluent/Views/Wallets/Send/SendView.axaml
MinHeight="30"
XAxisLabels="{Binding XAxisLabels}"
XAxisValues="{Binding XAxisValues}"
- XAxisCurrentValue="{Binding XAxisCurrentValue}"
+ XAxisCurrentValue="{Binding XAxisCurrentValue, Mode=TwoWay}"
XAxisMinValue="{Binding XAxisMinValue}"
XAxisMaxValue="{Binding XAxisMaxValue}"
YAxisValues="{Binding YAxisValues}"

implement PrivacyOptimisationSuggestion data calculations.