Speed up enqueue process
MODIFY
WalletWasabi/KeyManagement/KeyManager.cs
WalletWasabi/KeyManagement/KeyManager.cs
@@ -270,6 +270,11 @@ namespace WalletWasabi.KeyManagement
}
public IEnumerable<ExtKey> GetSecrets(string password, params Script[] scripts)
+ {
+ return GetSecretsAndPubKeyPairs(password, scripts).Select(x => x.secret);
+ }
+
+ public IEnumerable<(ExtKey secret, HdPubKey pubKey)> GetSecretsAndPubKeyPairs(string password, params Script[] scripts)
{
Key secret;
try
@@ -281,7 +286,7 @@ namespace WalletWasabi.KeyManagement
throw new SecurityException("Invalid password.", ex);
}
var extKey = new ExtKey(secret, ChainCode);
- var extKeys = new List<ExtKey>();
+ var extKeysAndPubs = new List<(ExtKey secret, HdPubKey pubKey)>();
lock (HdPubKeysLock)
{
@@ -292,9 +297,9 @@ namespace WalletWasabi.KeyManagement
|| scripts.Contains(x.GetP2pkScript())))
{
ExtKey ek = extKey.Derive(key.FullKeyPath);
- extKeys.Add(ek);
+ extKeysAndPubs.Add((ek, key));
}
- return extKeys;
+ return extKeysAndPubs;
}
}

MODIFY
WalletWasabi/Services/CcjClient.cs
WalletWasabi/Services/CcjClient.cs
@@ -681,23 +681,32 @@ namespace WalletWasabi.Services
await DequeueCoinsFromMixNoLockAsync(State.GetSpentCoins().ToArray());
var successful = new List<SmartCoin>();
+ var except = new List<SmartCoin>();
foreach (SmartCoin coin in coins)
{
if (State.Contains(coin))
{
successful.Add(coin);
+ except.Add(coin);
continue;
}
if (coin.SpentOrCoinJoinInProgress)
{
+ except.Add(coin);
continue;
}
+ }
- coin.Secret = KeyManager.GetSecrets(password, coin.ScriptPubKey).Single();
+ var coinsExcept = coins.Except(except);
+ var secPubs = KeyManager.GetSecretsAndPubKeyPairs(password, coinsExcept.Select(x => x.ScriptPubKey).ToArray());
OnePiece = OnePiece ?? password;
+ foreach (SmartCoin coin in coinsExcept)
+ {
+ coin.Secret = secPubs.Single(x => x.pubKey.GetP2wpkhScript() == coin.ScriptPubKey).secret;
+
coin.CoinJoinInProgress = true;
State.AddCoinToWaitingList(coin);

Speed up enqueue process