| 1338 | } |
| 1339 | |
| 1340 | void LegacyScriptPubKeyMan::AddKeypoolPubkeyWithDB(const CPubKey& pubkey, const bool internal, WalletBatch& batch) |
| 1341 | { |
| 1342 | LOCK(cs_KeyStore); |
| 1343 | assert(m_max_keypool_index < std::numeric_limits<int64_t>::max()); // How in the hell did you use so many keys? |
| 1344 | int64_t index = ++m_max_keypool_index; |
| 1345 | if (!batch.WritePool(index, CKeyPool(pubkey, internal))) { |
| 1346 | throw std::runtime_error(std::string(__func__) + ": writing imported pubkey failed"); |
| 1347 | } |
| 1348 | if (internal) { |
| 1349 | setInternalKeyPool.insert(index); |
| 1350 | } else { |
| 1351 | setExternalKeyPool.insert(index); |
| 1352 | } |
| 1353 | m_pool_key_to_index[pubkey.GetID()] = index; |
| 1354 | } |
| 1355 | |
| 1356 | void LegacyScriptPubKeyMan::KeepDestination(int64_t nIndex, const OutputType& type) |
| 1357 | { |