Page MenuHomePhabricator

D6411.diff
No OneTemporary

D6411.diff

diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -1759,7 +1759,13 @@
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;
}
}
@@ -1774,9 +1780,15 @@
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);
@@ -1800,8 +1812,12 @@
}
const CPubKey &pubkey = entry->second;
CPubKey temp;
- if (!GetPubKey(id, temp) &&
- !AddWatchOnlyWithDB(batch, GetScriptForRawPubKey(pubkey),
+ 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;
}

File Metadata

Mime Type
text/plain
Expires
Sat, Mar 1, 11:12 (19 h, 23 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5187536
Default Alt Text
D6411.diff (1 KB)

Event Timeline