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

Method MarkReserveKeysAsUsed

src/wallet/scriptpubkeyman.cpp:1477–1503  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1475}
1476
1477std::vector<CKeyPool> LegacyScriptPubKeyMan::MarkReserveKeysAsUsed(int64_t keypool_id)
1478{
1479 AssertLockHeld(cs_KeyStore);
1480 bool internal = setInternalKeyPool.count(keypool_id);
1481 if (!internal) assert(setExternalKeyPool.count(keypool_id) || set_pre_split_keypool.count(keypool_id));
1482 std::set<int64_t> *setKeyPool = internal ? &setInternalKeyPool : (set_pre_split_keypool.empty() ? &setExternalKeyPool : &set_pre_split_keypool);
1483 auto it = setKeyPool->begin();
1484
1485 std::vector<CKeyPool> result;
1486 WalletBatch batch(m_storage.GetDatabase());
1487 while (it != std::end(*setKeyPool)) {
1488 const int64_t& index = *(it);
1489 if (index > keypool_id) break; // set*KeyPool is ordered
1490
1491 CKeyPool keypool;
1492 if (batch.ReadPool(index, keypool)) { //TODO: This should be unnecessary
1493 m_pool_key_to_index.erase(keypool.vchPubKey.GetID());
1494 }
1495 LearnAllRelatedScripts(keypool.vchPubKey);
1496 batch.ErasePool(index);
1497 WalletLogPrintf("keypool index %d removed\n", index);
1498 it = setKeyPool->erase(it);
1499 result.push_back(std::move(keypool));
1500 }
1501
1502 return result;
1503}
1504
1505std::vector<CKeyID> GetAffectedKeys(const CScript& spk, const SigningProvider& provider)
1506{

Callers

nothing calls this directly

Calls 9

endFunction · 0.85
countMethod · 0.80
ReadPoolMethod · 0.80
ErasePoolMethod · 0.80
emptyMethod · 0.45
beginMethod · 0.45
eraseMethod · 0.45
GetIDMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected