| 3712 | } |
| 3713 | |
| 3714 | void CWallet::MarkReserveKeysAsUsed(int64_t keypool_id) |
| 3715 | { |
| 3716 | AssertLockHeld(cs_wallet); |
| 3717 | bool internal = setInternalKeyPool.count(keypool_id); |
| 3718 | if (!internal) assert(setExternalKeyPool.count(keypool_id) || set_pre_split_keypool.count(keypool_id)); |
| 3719 | std::set<int64_t> *setKeyPool = internal ? &setInternalKeyPool : (set_pre_split_keypool.empty() ? &setExternalKeyPool : &set_pre_split_keypool); |
| 3720 | auto it = setKeyPool->begin(); |
| 3721 | |
| 3722 | WalletBatch batch(*database); |
| 3723 | while (it != std::end(*setKeyPool)) { |
| 3724 | const int64_t& index = *(it); |
| 3725 | if (index > keypool_id) break; // set*KeyPool is ordered |
| 3726 | |
| 3727 | CKeyPool keypool; |
| 3728 | if (batch.ReadPool(index, keypool)) { //TODO: This should be unnecessary |
| 3729 | m_pool_key_to_index.erase(keypool.vchPubKey.GetID()); |
| 3730 | } |
| 3731 | LearnAllRelatedScripts(keypool.vchPubKey); |
| 3732 | batch.ErasePool(index); |
| 3733 | WalletLogPrintf("keypool index %d removed\n", index); |
| 3734 | it = setKeyPool->erase(it); |
| 3735 | } |
| 3736 | } |
| 3737 | |
| 3738 | void CWallet::GetScriptForMining(std::shared_ptr<CReserveScript> &script) |
| 3739 | { |