MCPcopy Create free account
hub / github.com/ElementsProject/elements / ImportPrivKeys

Method ImportPrivKeys

src/wallet/scriptpubkeyman.cpp:1586–1607  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1584}
1585
1586bool LegacyScriptPubKeyMan::ImportPrivKeys(const std::map<CKeyID, CKey>& privkey_map, const int64_t timestamp)
1587{
1588 WalletBatch batch(m_storage.GetDatabase());
1589 for (const auto& entry : privkey_map) {
1590 const CKey& key = entry.second;
1591 CPubKey pubkey = key.GetPubKey();
1592 const CKeyID& id = entry.first;
1593 assert(key.VerifyPubKey(pubkey));
1594 // Skip if we already have the key
1595 if (HaveKey(id)) {
1596 WalletLogPrintf("Already have key with pubkey %s, skipping\n", HexStr(pubkey));
1597 continue;
1598 }
1599 mapKeyMetadata[id].nCreateTime = timestamp;
1600 // If the private key is not present in the wallet, insert it.
1601 if (!AddKeyPubKeyWithDB(batch, key, pubkey)) {
1602 return false;
1603 }
1604 UpdateTimeFirstKey(timestamp);
1605 }
1606 return true;
1607}
1608
1609bool LegacyScriptPubKeyMan::ImportPubKeys(const std::vector<CKeyID>& ordered_pubkeys, const std::map<CKeyID, CPubKey>& pubkey_map, const std::map<CKeyID, std::pair<CPubKey, KeyOriginInfo>>& key_origins, const bool add_keypool, const bool internal, const int64_t timestamp)
1610{

Callers

nothing calls this directly

Calls 4

HaveKeyFunction · 0.85
VerifyPubKeyMethod · 0.80
HexStrFunction · 0.50
GetPubKeyMethod · 0.45

Tested by

no test coverage detected