Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13115485
D6411.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
D6411.diff
View Options
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
Details
Attached
Mime Type
text/plain
Expires
Sat, Mar 1, 11:12 (14 h, 48 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5187536
Default Alt Text
D6411.diff (1 KB)
Attached To
D6411: Log when an import is being skipped because we already have it
Event Timeline
Log In to Comment