src/wallet/scriptpubkeyman.cpp
bool LegacyScriptPubKeyMan::NewKeyPool()
{
    if (m_storage.IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS)) {
        return false;
    }
    {
        LOCK(cs_KeyStore);
        WalletBatch batch(m_storage.GetDatabase());

        for (const int64_t nIndex : setInternalKeyPool) {
            batch.ErasePool(nIndex);
        }
        setInternalKeyPool.clear();

        for (const int64_t nIndex : setExternalKeyPool) {
            batch.ErasePool(nIndex);
        }
        setExternalKeyPool.clear();

        for (const int64_t nIndex : set_pre_split_keypool) {
            batch.ErasePool(nIndex);
        }
        set_pre_split_keypool.clear();

        m_pool_key_to_index.clear();

        if (!TopUp()) {
            return false;
        }
        WalletLogPrintf("LegacyScriptPubKeyMan::NewKeyPool rewrote keypool\n");
    }
    return true;
}
/**
 * Mark old keypool keys as used,
 * and generate all new keys
 */
Mark old keypool keys as used,
and generate all new keys
Mark old keypool keys as used and generate all new keys
bool LegacyScriptPubKeyMan::NewKeyPool()
{
    if (m_storage.IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS)) {
        return false;
    }
    {
        LOCK(cs_KeyStore);
        WalletBatch batch(m_storage.GetDatabase());
        for (const int64_t nIndex : setInternalKeyPool) {
            batch.ErasePool(nIndex);
        }
        setInternalKeyPool.clear();
        for (const int64_t nIndex : setExternalKeyPool) {
            batch.ErasePool(nIndex);
        }
        setExternalKeyPool.clear();
        for (const int64_t nIndex : set_pre_split_keypool) {
            batch.ErasePool(nIndex);
        }
        set_pre_split_keypool.clear();
        m_pool_key_to_index.clear();
        if (!TopUp()) {
            return false;
        }
        WalletLogPrintf("LegacyScriptPubKeyMan::NewKeyPool rewrote keypool\n");
    }
    return true;
}
bool LegacyScriptPubKeyMan :: NewKeyPool ( ) { if ( m_storage . IsWalletFlagSet ( WALLET_FLAG_DISABLE_PRIVATE_KEYS ) ) { return false ; } { LOCK ( cs_KeyStore ) ; WalletBatch batch ( m_storage . GetDatabase ( ) ) ; for ( const int64_t nIndex : setInternalKeyPool ) { batch . ErasePool ( nIndex ) ; } setInternalKeyPool . clear ( ) ; for ( const int64_t nIndex : setExternalKeyPool ) { batch . ErasePool ( nIndex ) ; } setExternalKeyPool . clear ( ) ; for ( const int64_t nIndex : set_pre_split_keypool ) { batch . ErasePool ( nIndex ) ; } set_pre_split_keypool . clear ( ) ; m_pool_key_to_index . clear ( ) ; if ( ! TopUp ( ) ) { return false ; } WalletLogPrintf ( " \n " ) ; } return true ; }
Mark old keypool keys as used,
 and generate all new keys
Mark old keypool keys as used and generate all new keys