| 538 | } |
| 539 | |
| 540 | static int64_t GetOldestKeyTimeInPool(const std::set<int64_t>& setKeyPool, WalletBatch& batch) { |
| 541 | if (setKeyPool.empty()) { |
| 542 | return GetTime(); |
| 543 | } |
| 544 | |
| 545 | CKeyPool keypool; |
| 546 | int64_t nIndex = *(setKeyPool.begin()); |
| 547 | if (!batch.ReadPool(nIndex, keypool)) { |
| 548 | throw std::runtime_error(std::string(__func__) + ": read oldest key in keypool failed"); |
| 549 | } |
| 550 | assert(keypool.vchPubKey.IsValid()); |
| 551 | return keypool.nTime; |
| 552 | } |
| 553 | |
| 554 | std::optional<int64_t> LegacyScriptPubKeyMan::GetOldestKeyPoolTime() const |
| 555 | { |