take into account the label when selection pockets
MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Send/LabelSelectionViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Send/LabelSelectionViewModel.cs
@@ -32,18 +32,30 @@ public partial class LabelSelectionViewModel : ViewModelBase
public IEnumerable<LabelViewModel> LabelsBlackList => AllLabelsViewModel.Where(x => x.IsBlackListed);
- public Pocket[] AutoSelectPockets()
+ public Pocket[] AutoSelectPockets(SmartLabel recipient)
{
var knownPockets = NonPrivatePockets.Where(x => x.Labels != CoinPocketHelper.UnlabelledFundsText).ToArray();
var unknownPockets = NonPrivatePockets.Except(knownPockets).ToArray();
var privateAndUnknownPockets = _allPockets.Except(knownPockets).ToArray();
var privateAndKnownPockets = _allPockets.Except(unknownPockets).ToArray();
+ var knownByRecipientPockets = knownPockets.Where(x => x.Labels.Any(label => recipient.Labels.Contains(label))).ToArray();
+ var onlyKnownByRecipientPockets = knownByRecipientPockets.Where(x => x.Labels.All(label => recipient.Labels.Contains(label))).ToArray();
if (_privatePocket.Amount >= _targetAmount)
{
return new[] { _privatePocket };
}
+ if (onlyKnownByRecipientPockets.Sum(x => x.Amount) >= _targetAmount)
+ {
+ return onlyKnownByRecipientPockets;
+ }
+
+ if (knownByRecipientPockets.Sum(x => x.Amount) >= _targetAmount)
+ {
+ return knownByRecipientPockets;
+ }
+
if (knownPockets.Sum(x => x.Amount) >= _targetAmount)
{
return knownPockets;

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Send/PrivacyControlViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Send/PrivacyControlViewModel.cs
@@ -16,16 +16,18 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send;
public partial class PrivacyControlViewModel : DialogViewModelBase<IEnumerable<SmartCoin>>
{
private readonly Wallet _wallet;
+ private readonly TransactionInfo _transactionInfo;
private readonly bool _isSilent;
private readonly IEnumerable<SmartCoin>? _usedCoins;
public PrivacyControlViewModel(Wallet wallet, TransactionInfo transactionInfo, IEnumerable<SmartCoin>? usedCoins, bool isSilent, Money? targetAmount = null)
{
_wallet = wallet;
+ _transactionInfo = transactionInfo;
_isSilent = isSilent;
_usedCoins = usedCoins;
- LabelSelection = new LabelSelectionViewModel(targetAmount ?? transactionInfo.Amount);
+ LabelSelection = new LabelSelectionViewModel(targetAmount ?? _transactionInfo.Amount);
SetupCancel(enableCancel: false, enableCancelOnEscape: true, enableCancelOnPressed: false);
EnableBack = true;
@@ -67,7 +69,7 @@ public partial class PrivacyControlViewModel : DialogViewModelBase<IEnumerable<S
if (_isSilent)
{
- var autoSelectedPockets = LabelSelection.AutoSelectPockets();
+ var autoSelectedPockets = LabelSelection.AutoSelectPockets(_transactionInfo.UserLabels);
Complete(autoSelectedPockets);
}

take into account the label when selection pockets