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

Method ImportPubKeys

src/wallet/scriptpubkeyman.cpp:1609–1639  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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{
1611 WalletBatch batch(m_storage.GetDatabase());
1612 for (const auto& entry : key_origins) {
1613 AddKeyOriginWithDB(batch, entry.second.first, entry.second.second);
1614 }
1615 for (const CKeyID& id : ordered_pubkeys) {
1616 auto entry = pubkey_map.find(id);
1617 if (entry == pubkey_map.end()) {
1618 continue;
1619 }
1620 const CPubKey& pubkey = entry->second;
1621 CPubKey temp;
1622 if (GetPubKey(id, temp)) {
1623 // Already have pubkey, skipping
1624 WalletLogPrintf("Already have pubkey %s, skipping\n", HexStr(temp));
1625 continue;
1626 }
1627 if (!AddWatchOnlyWithDB(batch, GetScriptForRawPubKey(pubkey), timestamp)) {
1628 return false;
1629 }
1630 mapKeyMetadata[id].nCreateTime = timestamp;
1631
1632 // Add to keypool only works with pubkeys
1633 if (add_keypool) {
1634 AddKeypoolPubkeyWithDB(pubkey, internal, batch);
1635 NotifyCanGetAddressesChanged();
1636 }
1637 }
1638 return true;
1639}
1640
1641bool LegacyScriptPubKeyMan::ImportScriptPubKeys(const std::set<CScript>& script_pub_keys, const bool have_solving_data, const int64_t timestamp)
1642{

Callers

nothing calls this directly

Calls 6

GetPubKeyFunction · 0.85
GetScriptForRawPubKeyFunction · 0.85
findMethod · 0.80
HexStrFunction · 0.50
endMethod · 0.45

Tested by

no test coverage detected