use Merge instead of + operator
MODIFY
WalletWasabi.Fluent/Models/Pocket.cs
WalletWasabi.Fluent/Models/Pocket.cs
@@ -24,13 +24,19 @@ public class Pocket
public Money EffectiveSumValue(FeeRate feeRate) => Coins.Sum(coin => coin.EffectiveValue(feeRate));
- public static Pocket operator +(Pocket x, Pocket y)
+ public static Pocket Merge(params Pocket[] pockets)
{
- var mergedLabels = SmartLabel.Merge(x.Labels, y.Labels);
- var mergedCoins = new CoinsView(x.Coins.Concat(y.Coins).ToHashSet());
+ var mergedLabels = SmartLabel.Merge(pockets.Select(p => p.Labels));
+ var mergedCoins = new CoinsView(pockets.SelectMany(x => x.Coins).ToHashSet());
return new Pocket((mergedLabels, mergedCoins));
}
- public static Pocket operator +(Pocket[] pockets, Pocket p) => p + pockets.Aggregate((current, pocket) => current + pocket);
+ public static Pocket Merge(Pocket[] pocketArray, params Pocket[] pockets)
+ {
+ var mergedPocketArray = pocketArray.Aggregate((current, pocket) => Merge(current, pocket));
+ var mergedPockets = pockets.Aggregate((current, pocket) => Merge(current, pocket));
+
+ return Merge(mergedPocketArray, mergedPockets);
+ }
}

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Send/LabelSelectionViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Send/LabelSelectionViewModel.cs
@@ -288,8 +288,8 @@ public partial class LabelSelectionViewModel : ViewModelBase
private bool IsPrivatePocketNeeded()
{
var isNonPrivateNotEnough = NonPrivatePockets.EffectiveSumValue(_feeRate) < _targetAmount;
- var isPrivateAndSemiPrivateNotEnough = (_privatePocket + _semiPrivatePocket).EffectiveSumValue(_feeRate) < _targetAmount;
- var isNonPrivateAndPrivateEnough = (NonPrivatePockets + _privatePocket).EffectiveSumValue(_feeRate) >= _targetAmount;
+ var isPrivateAndSemiPrivateNotEnough = Pocket.Merge(_privatePocket, _semiPrivatePocket).EffectiveSumValue(_feeRate) < _targetAmount;
+ var isNonPrivateAndPrivateEnough = Pocket.Merge(NonPrivatePockets, _privatePocket).EffectiveSumValue(_feeRate) >= _targetAmount;
var isPrivateNeededBesideNonPrivate = isNonPrivateNotEnough && isPrivateAndSemiPrivateNotEnough && isNonPrivateAndPrivateEnough;
var isOnlyPrivateNeeded = LabelsWhiteList.IsEmpty() && _privatePocket.EffectiveSumValue(_feeRate) >= _targetAmount;
@@ -299,12 +299,12 @@ public partial class LabelSelectionViewModel : ViewModelBase
private bool IsPrivateAndSemiPrivatePocketNeeded()
{
- var isNonPrivateAndPrivateNotEnough = (NonPrivatePockets + _privatePocket).EffectiveSumValue(_feeRate) < _targetAmount;
- var isNonPrivateAndPrivateAndSemiPrivateEnough = (NonPrivatePockets + _privatePocket + _semiPrivatePocket).EffectiveSumValue(_feeRate) >= _targetAmount;
+ var isNonPrivateAndPrivateNotEnough = Pocket.Merge(NonPrivatePockets, _privatePocket).EffectiveSumValue(_feeRate) < _targetAmount;
+ var isNonPrivateAndPrivateAndSemiPrivateEnough = Pocket.Merge(NonPrivatePockets, _privatePocket, _semiPrivatePocket).EffectiveSumValue(_feeRate) >= _targetAmount;
var isPrivateAndSemiPrivateNeededBesideNonPrivate = isNonPrivateAndPrivateNotEnough && isNonPrivateAndPrivateAndSemiPrivateEnough;
var isPrivateNotEnough = _privatePocket.EffectiveSumValue(_feeRate) < _targetAmount;
- var isPrivateAndSemiPrivateEnough = (_privatePocket + _semiPrivatePocket).EffectiveSumValue(_feeRate) >= _targetAmount;
+ var isPrivateAndSemiPrivateEnough = Pocket.Merge(_privatePocket, _semiPrivatePocket).EffectiveSumValue(_feeRate) >= _targetAmount;
var isOnlyPrivateAndSemiPrivateNeeded = LabelsWhiteList.IsEmpty() && isPrivateNotEnough && isPrivateAndSemiPrivateEnough;
return isPrivateAndSemiPrivateNeededBesideNonPrivate || isOnlyPrivateAndSemiPrivateNeeded;

use Merge instead of + operator