Add CoinHelpers for privacy status
ADD
WalletWasabi/Helpers/CoinHelpers.cs
+using WalletWasabi.Blockchain.TransactionOutputs;
+
+namespace WalletWasabi.Helpers;
+
+public static class CoinHelpers
+{
+ public static bool IsPrivate<TCoin>(this TCoin coin, int privateThreshold)
+ where TCoin : class, ISmartCoin, IEquatable<TCoin>
+ {
+ return coin.AnonymitySet >= privateThreshold;
+ }
+
+ public static bool IsSemiPrivate<TCoin>(this TCoin coin, int privateThreshold, int semiPrivateThreshold = Constants.SemiPrivateThreshold)
+ where TCoin : class, ISmartCoin, IEquatable<TCoin>
+ {
+ var anonymitySet = coin.AnonymitySet;
+ return anonymitySet >= semiPrivateThreshold && anonymitySet < privateThreshold;
+ }
+
+ public static bool IsRedCoin<TCoin>(this TCoin coin, int semiPrivateThreshold = Constants.SemiPrivateThreshold)
+ where TCoin : class, ISmartCoin, IEquatable<TCoin>
+ {
+ return coin.AnonymitySet < semiPrivateThreshold;
+ }
+}
\ No newline at end of file

MODIFY
WalletWasabi/WabiSabi/Client/CoinJoinClient.cs
WalletWasabi/WabiSabi/Client/CoinJoinClient.cs
@@ -680,13 +680,13 @@ public class CoinJoinClient
.ToArray();
var privateCoins = filteredCoins
- .Where(x => x.AnonymitySet >= anonScoreTarget)
+ .Where(x => x.IsPrivate(anonScoreTarget))
.ToArray();
var semiPrivateCoins = filteredCoins
- .Where(x => x.AnonymitySet < anonScoreTarget && x.AnonymitySet >= semiPrivateThreshold)
+ .Where(x => x.IsSemiPrivate(anonScoreTarget, semiPrivateThreshold))
.ToArray();
var redCoins = filteredCoins
- .Where(x => x.AnonymitySet < semiPrivateThreshold)
+ .Where(x => x.IsRedCoin(semiPrivateThreshold))
.ToArray();
if (semiPrivateCoins.Length + redCoins.Length == 0)

MODIFY
WalletWasabi/Wallets/Wallet.cs
WalletWasabi/Wallets/Wallet.cs
@@ -112,8 +112,8 @@ public class Wallet : BackgroundService, IWallet
private double GetPrivacyPercentage(CoinsView coins, int privateThreshold)
{
- var privateAmount = coins.FilterBy(x => x.HdPubKey.AnonymitySet >= privateThreshold).TotalAmount();
- var normalAmount = coins.FilterBy(x => x.HdPubKey.AnonymitySet < privateThreshold).TotalAmount();
+ var privateAmount = coins.FilterBy(x => x.IsPrivate(privateThreshold)).TotalAmount();
+ var normalAmount = coins.FilterBy(x => !x.IsPrivate(privateThreshold)).TotalAmount();
var privateDecimalAmount = privateAmount.ToDecimal(MoneyUnit.BTC);
var normalDecimalAmount = normalAmount.ToDecimal(MoneyUnit.BTC);

Add CoinHelpers for privacy status