Use SmartLabe instead of staring[]
MODIFY
WalletWasabi.Fluent/Helpers/CoinPocketHelper.cs
WalletWasabi.Fluent/Helpers/CoinPocketHelper.cs
@@ -10,12 +10,12 @@ namespace WalletWasabi.Fluent.Helpers
{
public static class CoinPocketHelper
{
- public static readonly string[] UnlabelledFundsText = {"Unlabelled Funds"};
- public static readonly string[] PrivateFundsText = {"Private Funds"};
+ public static readonly SmartLabel UnlabelledFundsText = new("Unlabelled Funds");
+ public static readonly SmartLabel PrivateFundsText = new("Private Funds");
- public static IEnumerable<(string[] Labels, ICoinsView Coins)> GetPockets(this ICoinsView allCoins, int privateAnonSetThreshold)
+ public static IEnumerable<(SmartLabel SmartLabel, ICoinsView Coins)> GetPockets(this ICoinsView allCoins, int privateAnonSetThreshold)
{
- List<(string[] Labels, ICoinsView Coins)> pockets = new();
+ List<(SmartLabel SmartLabel, ICoinsView Coins)> pockets = new();
var clusters = allCoins
.Where(x => x.HdPubKey.AnonymitySet < privateAnonSetThreshold)
@@ -34,7 +34,7 @@ namespace WalletWasabi.Fluent.Helpers
}
else
{
- pockets.Add(new(allLabels, new CoinsView(coins)));
+ pockets.Add(new(cluster.Key, new CoinsView(coins)));
}
}

MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Send/PocketViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Send/PocketViewModel.cs
using NBitcoin;
+using System.Linq;
+using WalletWasabi.Blockchain.Analysis.Clustering;
using WalletWasabi.Blockchain.TransactionOutputs;
namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
@@ -9,10 +11,10 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send
[AutoNotify] private decimal _totalBtc;
[AutoNotify] private string[] _labels;
- public PocketViewModel((string[] labels, ICoinsView coins) pocket)
+ public PocketViewModel((SmartLabel labels, ICoinsView coins) pocket)
{
Coins = pocket.coins;
- _labels = pocket.labels;
+ _labels = pocket.labels.Labels.ToArray();
_totalBtc = pocket.coins.TotalAmount().ToDecimal(MoneyUnit.BTC);
}

MODIFY
WalletWasabi.Tests/UnitTests/Transactions/TransactionProcessorTests.cs
WalletWasabi.Tests/UnitTests/Transactions/TransactionProcessorTests.cs
@@ -1088,26 +1088,26 @@ namespace WalletWasabi.Tests.UnitTests.Transactions
var notYetPrivateCoin = transactionProcessor.NewKey("");
transactionProcessor.Process(CreateCreditingTransaction(notYetPrivateCoin.P2wpkhScript, Money.Coins(1.0m)));
- notYetPrivateCoin.AnonymitySet = targetAnonSet - 1;
+ notYetPrivateCoin.SetAnonymitySet(targetAnonSet - 1, 0);
var privateCoin1 = transactionProcessor.NewKey("");
transactionProcessor.Process(CreateCreditingTransaction(privateCoin1.P2wpkhScript, Money.Coins(1.0m)));
- privateCoin1.AnonymitySet = targetAnonSet;
+ privateCoin1.SetAnonymitySet(targetAnonSet, 0);
var privateCoin2 = transactionProcessor.NewKey("");
transactionProcessor.Process(CreateCreditingTransaction(privateCoin2.P2wpkhScript, Money.Coins(1.0m)));
- privateCoin2.AnonymitySet = targetAnonSet;
+ privateCoin2.SetAnonymitySet(targetAnonSet, 0);
- IEnumerable<(string Labels, ICoinsView Coins)> pockets = CoinPocketHelper.GetPockets(transactionProcessor.Coins, targetAnonSet);
- (string Labels, ICoinsView Coins) aPocket = pockets.Single(x => x.Labels == "A");
+ var pockets = CoinPocketHelper.GetPockets(transactionProcessor.Coins, targetAnonSet);
+ var aPocket = pockets.Single(x => x.SmartLabel == "A");
Assert.Equal(3, aPocket.Coins.Count());
Assert.Equal(Money.Coins(3.0m), aPocket.Coins.TotalAmount());
- Assert.Single(pockets.Single(x => x.Labels == "B").Coins);
- Assert.Equal(2, pockets.Single(x => x.Labels == "C").Coins.Count());
- Assert.Single(pockets.Single(x => x.Labels == "A, B").Coins);
- Assert.Equal(4, pockets.Single(x => x.Labels == CoinPocketHelper.UnlabelledFundsText).Coins.Count());
- Assert.Equal(2, pockets.Single(x => x.Labels == CoinPocketHelper.PrivateFundsText).Coins.Count());
+ Assert.Single(pockets.Single(x => x.SmartLabel == "B").Coins);
+ Assert.Equal(2, pockets.Single(x => x.SmartLabel == "C").Coins.Count());
+ Assert.Single(pockets.Single(x => x.SmartLabel == "A, B").Coins);
+ Assert.Equal(4, pockets.Single(x => x.SmartLabel == CoinPocketHelper.UnlabelledFundsText).Coins.Count());
+ Assert.Equal(2, pockets.Single(x => x.SmartLabel == CoinPocketHelper.PrivateFundsText).Coins.Count());
}
private static SmartTransaction CreateSpendingTransaction(Coin coin, Script? scriptPubKey = null, int height = 0)

Use SmartLabe instead of staring[]