Permalink
Browse files

Assert no accidental change equals active script happens

  • Loading branch information...
nopara73 committed Nov 3, 2018
1 parent 44a1bab commit 18fb92343d741f72b19092e6e14c532f326fbbc2
Showing with 3 additions and 3 deletions.
  1. +3 −3 WalletWasabi/Services/CcjClient.cs
@@ -466,18 +466,18 @@ private async Task TryRegisterCoinsAsync(CcjClientRound inputRegistrableRound)
{
// Find the first one that we did not try to register in the current session.
activeKey = allActiveKeys.FirstOrDefault(x => !AccessCache.ContainsKey(x));
// If there is no such a key, then use the oldest.
// If there is no such a key, then use the oldest, but make sure it's not the same as the change.
if (activeKey == default)
{
activeKey = AccessCache.Where(x => allActiveKeys.Contains(x.Key)).OrderBy(x => x.Value).First().Key;
activeKey = AccessCache.Where(x => allActiveKeys.Contains(x.Key) && changeAddress != x.Key.GetP2wpkhAddress(Network)).OrderBy(x => x.Value).First().Key;
}
activeKey.SetLabel(activeLabel);
activeKey.SetKeyState(KeyState.Locked);
activeAddress = activeKey.GetP2wpkhAddress(Network);
}
else
{
activeKey = internalNotCachedLockedKeys.RandomElement();
activeKey = internalNotCachedLockedKeys.Where(x => changeAddress != x.GetP2wpkhAddress(Network)).RandomElement();
activeKey.SetLabel(activeLabel);
}
activeAddress = activeKey.GetP2wpkhAddress(Network);

0 comments on commit 18fb923

Please sign in to comment.