Improve IsOtherSelectionPossible
MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Send/LabelSelectionViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Send/LabelSelectionViewModel.cs
@@ -335,11 +335,26 @@ public partial class LabelSelectionViewModel : ViewModelBase
remainingUsablePockets.Remove(_privatePocket);
}
+ if (!usedPockets.Contains(_semiPrivatePocket)) // Semi private pocket hasn't been used. Don't deal with it then.
+ {
+ remainingUsablePockets.Remove(_semiPrivatePocket);
+ }
+
if (usedPockets.Length == 1 && usedPockets.First() == _privatePocket)
{
return false;
}
+ if (usedPockets.Length == 1 && usedPockets.First() == _semiPrivatePocket)
+ {
+ return false;
+ }
+
+ if (usedPockets.Length == 2 && usedPockets.Contains(_privatePocket) && usedPockets.Contains(_semiPrivatePocket))
+ {
+ return false;
+ }
+
if (!remainingUsablePockets.Any())
{
return false;

MODIFY
WalletWasabi.Tests/UnitTests/UserInterfaceTest/PocketSelectionTests.cs
WalletWasabi.Tests/UnitTests/UserInterfaceTest/PocketSelectionTests.cs
@@ -1050,6 +1050,9 @@ public class PocketSelectionTests
var selection = new LabelSelectionViewModel(Money.Parse("0.5"));
var pockets = new List<Pocket>();
+ var privatePocket = LabelTestExtensions.CreateSingleCoinPocket(1.0m, CoinPocketHelper.PrivateFundsText, anonSet: 999);
+ var semiPrivatePocket = LabelTestExtensions.CreateSingleCoinPocket(1.0m, CoinPocketHelper.SemiPrivateFundsText, anonSet: 2);
+
pockets.Add(LabelTestExtensions.CreateSingleCoinPocket(1.0m, "Dan"));
pockets.Add(LabelTestExtensions.CreateSingleCoinPocket(1.0m, "Dan, Lucas"));
selection.Reset(pockets.ToArray());
@@ -1064,13 +1067,32 @@ public class PocketSelectionTests
output = selection.AutoSelectPockets(recipient);
Assert.False(selection.IsOtherSelectionPossible(output.SelectMany(x => x.Coins), recipient));
- pockets.Add(LabelTestExtensions.CreateSingleCoinPocket(1.0m, anonSet: 999));
+ pockets.Add(privatePocket);
selection.Reset(pockets.ToArray());
// Private funds are enough for the payment, no better selection.
recipient = "Doesn't matter, it will use private coins";
output = selection.AutoSelectPockets(recipient);
Assert.False(selection.IsOtherSelectionPossible(output.SelectMany(x => x.Coins), recipient));
+
+ pockets.Remove(privatePocket);
+ pockets.Add(semiPrivatePocket);
+ selection = new LabelSelectionViewModel(Money.Parse("0.5"));
+ selection.Reset(pockets.ToArray());
+
+ // Semi funds are enough for the payment, no better selection.
+ recipient = "Doesn't matter, it will use semi private coins";
+ output = selection.AutoSelectPockets(recipient);
+ Assert.False(selection.IsOtherSelectionPossible(output.SelectMany(x => x.Coins), recipient));
+
+ pockets.Add(privatePocket);
+ selection = new LabelSelectionViewModel(Money.Parse("1.5"));
+ selection.Reset(pockets.ToArray());
+
+ // Private and semi funds are enough for the payment, no better selection.
+ recipient = "Doesn't matter, it will use semi private coins";
+ output = selection.AutoSelectPockets(recipient);
+ Assert.False(selection.IsOtherSelectionPossible(output.SelectMany(x => x.Coins), recipient));
}
}

Improve IsOtherSelectionPossible