Log when an import is being skipped because we already have it
Behavior Changes: * Those pubkeys being imported with add_keypool set and are already in the wallet will no longer be added to the keypool
This commit is contained in:
parent
ab28e31c95
commit
fae7a5befd
1 changed files with 18 additions and 3 deletions
|
@ -1665,7 +1665,12 @@ bool CWallet::ImportScripts(const std::set<CScript> scripts)
|
|||
{
|
||||
WalletBatch batch(*database);
|
||||
for (const auto& entry : scripts) {
|
||||
if (!HaveCScript(CScriptID(entry)) && !AddCScriptWithDB(batch, entry)) {
|
||||
CScriptID id(entry);
|
||||
if (HaveCScript(id)) {
|
||||
WalletLogPrintf("Already have script %s, skipping\n", HexStr(entry));
|
||||
continue;
|
||||
}
|
||||
if (!AddCScriptWithDB(batch, entry)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1680,9 +1685,14 @@ bool CWallet::ImportPrivKeys(const std::map<CKeyID, CKey>& privkey_map, const in
|
|||
CPubKey pubkey = key.GetPubKey();
|
||||
const CKeyID& id = entry.first;
|
||||
assert(key.VerifyPubKey(pubkey));
|
||||
// Skip if we already have the key
|
||||
if (HaveKey(id)) {
|
||||
WalletLogPrintf("Already have key with pubkey %s, skipping\n", HexStr(pubkey));
|
||||
continue;
|
||||
}
|
||||
mapKeyMetadata[id].nCreateTime = timestamp;
|
||||
// If the private key is not present in the wallet, insert it.
|
||||
if (!HaveKey(id) && !AddKeyPubKeyWithDB(batch, key, pubkey)) {
|
||||
if (!AddKeyPubKeyWithDB(batch, key, pubkey)) {
|
||||
return false;
|
||||
}
|
||||
UpdateTimeFirstKey(timestamp);
|
||||
|
@ -1703,7 +1713,12 @@ bool CWallet::ImportPubKeys(const std::vector<CKeyID>& ordered_pubkeys, const st
|
|||
}
|
||||
const CPubKey& pubkey = entry->second;
|
||||
CPubKey temp;
|
||||
if (!GetPubKey(id, temp) && !AddWatchOnlyWithDB(batch, GetScriptForRawPubKey(pubkey), timestamp)) {
|
||||
if (GetPubKey(id, temp)) {
|
||||
// Already have pubkey, skipping
|
||||
WalletLogPrintf("Already have pubkey %s, skipping\n", HexStr(temp));
|
||||
continue;
|
||||
}
|
||||
if (!AddWatchOnlyWithDB(batch, GetScriptForRawPubKey(pubkey), timestamp)) {
|
||||
return false;
|
||||
}
|
||||
mapKeyMetadata[id].nCreateTime = timestamp;
|
||||
|
|
Loading…
Reference in a new issue