| 3140 | } |
| 3141 | |
| 3142 | DBErrors CWallet::LoadWallet(bool& fFirstRunRet) |
| 3143 | { |
| 3144 | LOCK2(cs_main, cs_wallet); |
| 3145 | |
| 3146 | fFirstRunRet = false; |
| 3147 | DBErrors nLoadWalletRet = WalletBatch(*database,"cr+").LoadWallet(this); |
| 3148 | if (nLoadWalletRet == DBErrors::NEED_REWRITE) |
| 3149 | { |
| 3150 | if (database->Rewrite("\x04pool")) |
| 3151 | { |
| 3152 | setInternalKeyPool.clear(); |
| 3153 | setExternalKeyPool.clear(); |
| 3154 | m_pool_key_to_index.clear(); |
| 3155 | // Note: can't top-up keypool here, because wallet is locked. |
| 3156 | // User will be prompted to unlock wallet the next operation |
| 3157 | // that requires a new key. |
| 3158 | } |
| 3159 | } |
| 3160 | |
| 3161 | { |
| 3162 | LOCK(cs_KeyStore); |
| 3163 | // This wallet is in its first run if all of these are empty |
| 3164 | fFirstRunRet = mapKeys.empty() && mapCryptedKeys.empty() && mapWatchKeys.empty() && setWatchOnly.empty() && mapScripts.empty() && !IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS); |
| 3165 | } |
| 3166 | |
| 3167 | if (nLoadWalletRet != DBErrors::LOAD_OK) |
| 3168 | return nLoadWalletRet; |
| 3169 | |
| 3170 | return DBErrors::LOAD_OK; |
| 3171 | } |
| 3172 | |
| 3173 | DBErrors CWallet::ZapSelectTx(std::vector<uint256>& vHashIn, std::vector<uint256>& vHashOut) |
| 3174 | { |