Minor cleanup of the code that searches for a valid transparent key.

This commit is contained in:
Kris Nuttycombe 2021-11-04 21:36:40 -05:00
parent de57da38ce
commit f65d6f63ee
1 changed files with 21 additions and 22 deletions

View File

@ -281,12 +281,13 @@ CPubKey CWallet::GenerateNewKey()
BIP44CoinType(),
ZCASH_LEGACY_ACCOUNT).value();
while (true) {
auto extKey = accountChains.DeriveExternal(hdChain.GetLegacyTKeyCounter());
std::optional<std::pair<CExtKey, HDKeyPath>> extKey = std::nullopt;
do {
extKey = accountChains.DeriveExternal(hdChain.GetLegacyTKeyCounter());
hdChain.IncrementLegacyTKeyCounter();
// if we did not successfully generate a key, try again.
if (extKey.has_value()) {
} while (!extKey.has_value());
CKey secret = extKey.value().first.key;
CPubKey pubkey = secret.GetPubKey();
assert(secret.VerifyPubKey(pubkey));
@ -309,8 +310,6 @@ CPubKey CWallet::GenerateNewKey()
return pubkey;
}
}
}
bool CWallet::AddKeyPubKey(const CKey& secret, const CPubKey &pubkey)
{