| 1475 | } |
| 1476 | |
| 1477 | std::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 | |
| 1505 | std::vector<CKeyID> GetAffectedKeys(const CScript& spk, const SigningProvider& provider) |
| 1506 | { |