Use Constants.MaximumMixingLevelCount
MODIFY
WalletWasabi/Services/CcjClient.cs
WalletWasabi/Services/CcjClient.cs
@@ -413,12 +413,10 @@ namespace WalletWasabi.Services
BitcoinAddress changeAddress = null;
var activeOutputAddresses = new List<BitcoinAddress>();
- IEnumerable<HdPubKey> allUnusedInternalKeys = KeyManager.GetKeys(x => x.KeyState != KeyState.Used);
-
- if (changeAddress is null)
- {
string changeLabel = "ZeroLink Change";
- IEnumerable<HdPubKey> allChangeKeys = allUnusedInternalKeys.Where(x => x.Label == changeLabel);
+ string activeLabel = "ZeroLink Mixed Coin";
+
+ IEnumerable<HdPubKey> allChangeKeys = KeyManager.GetKeys(x => x.KeyState != KeyState.Used && x.Label == changeLabel);
HdPubKey changeKey = null;
KeyManager.AssertLockedInternalKeysIndexed(14);
@@ -443,34 +441,31 @@ namespace WalletWasabi.Services
}
changeAddress = changeKey.GetP2wpkhAddress(Network);
AccessCache.AddOrReplace(changeKey, DateTimeOffset.UtcNow);
- }
- if (!activeOutputAddresses.Any())
- {
- string activeLabel = "ZeroLink Mixed Coin";
- IEnumerable<HdPubKey> allActiveKeys = allUnusedInternalKeys.Where(x => x.Label == activeLabel);
+ IEnumerable<HdPubKey> allActiveKeys = KeyManager.GetKeys(x => x.KeyState != KeyState.Used && x.Label == activeLabel);
List<HdPubKey> activeKeys = new List<HdPubKey>();
KeyManager.AssertLockedInternalKeysIndexed(14);
- IEnumerable<HdPubKey> internalNotCachedLockedKeys = KeyManager.GetKeys(KeyState.Locked, isInternal: true).Except(AccessCache.Keys);
+
+ internalNotCachedLockedKeys = KeyManager.GetKeys(KeyState.Locked, isInternal: true).Except(AccessCache.Keys);
if (allActiveKeys.Count() >= 7 || !internalNotCachedLockedKeys.Any()) // Then don't generate new keys, because it'd bloat the wallet.
{
// Find the first one that we did not try to register in the current session.
foreach (var ac in allActiveKeys.Where(x => !AccessCache.ContainsKey(x)))
{
- if (activeKeys.Count >= 10)
+ if (activeKeys.Count >= Constants.MaximumMixingLevelCount)
{
break;
}
activeKeys.Add(ac);
}
// If there is no such a key, then use the oldest, but make sure it's not the same as the change.
- if (activeKeys.Count < 10)
+ if (activeKeys.Count < Constants.MaximumMixingLevelCount)
{
foreach (var ac in AccessCache.Where(x => allActiveKeys.Contains(x.Key) && changeAddress != x.Key.GetP2wpkhAddress(Network)).OrderBy(x => x.Value).Select(x => x.Key))
{
- if (activeKeys.Count >= 10)
+ if (activeKeys.Count >= Constants.MaximumMixingLevelCount)
{
break;
}
@@ -482,7 +477,7 @@ namespace WalletWasabi.Services
{
foreach (var ac in internalNotCachedLockedKeys.Where(x => changeAddress != x.GetP2wpkhAddress(Network)))
{
- if (activeKeys.Count >= 10)
+ if (activeKeys.Count >= Constants.MaximumMixingLevelCount)
{
break;
}
@@ -497,7 +492,6 @@ namespace WalletWasabi.Services
activeOutputAddresses.Add(ac.GetP2wpkhAddress(Network));
AccessCache.AddOrReplace(ac, DateTimeOffset.UtcNow);
}
- }
KeyManager.ToFile();

Use Constants.MaximumMixingLevelCount