make fix more secure
MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Send/LabelSelectionViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Send/LabelSelectionViewModel.cs
@@ -228,7 +228,7 @@ public partial class LabelSelectionViewModel : ViewModelBase
OnSelectionChanged();
}
- private void OnSelectionChanged()
+ private void OnSelectionChanged(bool forceIncludePrivatePocket = false)
{
Money sumOfWhiteList =
NonPrivatePockets
@@ -240,12 +240,14 @@ public partial class LabelSelectionViewModel : ViewModelBase
EnoughSelected = true;
_includePrivatePocket = false;
}
- else if (!LabelsBlackList.Any() && sumOfWhiteList + _privatePocket.Amount >= _targetAmount)
+ else if ((!LabelsBlackList.Any() || forceIncludePrivatePocket) &&
+ sumOfWhiteList + _privatePocket.Amount >= _targetAmount)
{
EnoughSelected = true;
_includePrivatePocket = true;
}
- else if (!LabelsWhiteList.Any() && _privatePocket.Amount >= _targetAmount)
+ else if ((!LabelsWhiteList.Any() || forceIncludePrivatePocket) &&
+ _privatePocket.Amount >= _targetAmount)
{
EnoughSelected = true;
_includePrivatePocket = true;
@@ -256,11 +258,6 @@ public partial class LabelSelectionViewModel : ViewModelBase
_includePrivatePocket = false;
}
- UpdateLists();
- }
-
- private void UpdateLists()
- {
this.RaisePropertyChanged(nameof(LabelsWhiteList));
this.RaisePropertyChanged(nameof(LabelsBlackList));
}
@@ -274,9 +271,7 @@ public partial class LabelSelectionViewModel : ViewModelBase
usedCoins = usedCoins.ToImmutableArray();
- _includePrivatePocket = usedCoins.Any(coin => coin.HdPubKey.AnonymitySet >= privateThreshold);
- EnoughSelected = usedCoins.Sum(x => x.Amount) >= _targetAmount;
-
+ var isPrivatePocketUsed = usedCoins.Any(coin => coin.HdPubKey.AnonymitySet >= privateThreshold);
var usedLabels = SmartLabel.Merge(usedCoins.Select(x => x.GetLabels(privateThreshold)));
var usedLabelViewModels = AllLabelsViewModel.Where(x => usedLabels.Contains(x.Value, StringComparer.OrdinalIgnoreCase)).ToArray();
var notUsedLabelViewModels = AllLabelsViewModel.Except(usedLabelViewModels);
@@ -286,6 +281,6 @@ public partial class LabelSelectionViewModel : ViewModelBase
label.Swap();
}
- UpdateLists();
+ OnSelectionChanged(isPrivatePocketUsed);
}
}

MODIFY
WalletWasabi.Tests/UnitTests/UserInterfaceTest/PocketSelectionTests.cs
WalletWasabi.Tests/UnitTests/UserInterfaceTest/PocketSelectionTests.cs
@@ -724,8 +724,9 @@ internal static class LabelTestExtensions
public static void AddPocket(this List<Pocket> pockets, decimal amount, out Pocket pocket, params string[] labels)
{
- var coinsView = new CoinsView(new[] { BitcoinFactory.CreateSmartCoin(NewKey(), amount) });
- pocket = new Pocket((new SmartLabel(labels), coinsView));
+ var label = new SmartLabel(labels);
+ var coinsView = new CoinsView(new[] { BitcoinFactory.CreateSmartCoin(NewKey(label), amount) });
+ pocket = new Pocket((label, coinsView));
pockets.Add(pocket);
}
@@ -733,6 +734,8 @@ internal static class LabelTestExtensions
{
var key = KeyManager.GenerateNewKey(label, KeyState.Used, true, false);
key.SetAnonymitySet(anonymitySet);
+ key.SetLabel(label);
+
return key;
}
}

make fix more secure