MCPcopy Create free account
hub / github.com/ElementsProject/elements / GetKeyFromPool

Method GetKeyFromPool

src/wallet/scriptpubkeyman.cpp:1390–1411  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1388}
1389
1390bool LegacyScriptPubKeyMan::GetKeyFromPool(CPubKey& result, const OutputType type, bool internal)
1391{
1392 assert(type != OutputType::BECH32M);
1393 if (!CanGetAddresses(internal)) {
1394 return false;
1395 }
1396
1397 CKeyPool keypool;
1398 {
1399 LOCK(cs_KeyStore);
1400 int64_t nIndex;
1401 if (!ReserveKeyFromKeyPool(nIndex, keypool, internal) && !m_storage.IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS)) {
1402 if (m_storage.IsLocked()) return false;
1403 WalletBatch batch(m_storage.GetDatabase());
1404 result = GenerateNewKey(batch, m_hd_chain, internal);
1405 return true;
1406 }
1407 KeepDestination(nIndex, type);
1408 result = keypool.vchPubKey;
1409 }
1410 return true;
1411}
1412
1413bool LegacyScriptPubKeyMan::ReserveKeyFromKeyPool(int64_t& nIndex, CKeyPool& keypool, bool fRequestedInternal)
1414{

Callers

nothing calls this directly

Calls 2

IsWalletFlagSetMethod · 0.80
IsLockedMethod · 0.80

Tested by

no test coverage detected