Skip to content

Commit 67be6b9

Browse files
committed
Refactor: Move SetAddressBookWithDB call out of LegacyScriptPubKeyMan::ImportScriptPubKeys
This commit does not change behavior.
1 parent fc2867f commit 67be6b9

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

src/wallet/scriptpubkeyman.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,7 +1250,7 @@ bool LegacyScriptPubKeyMan::ImportPubKeys(const std::vector<CKeyID>& ordered_pub
12501250
return true;
12511251
}
12521252

1253-
bool LegacyScriptPubKeyMan::ImportScriptPubKeys(const std::string& label, const std::set<CScript>& script_pub_keys, const bool have_solving_data, const bool apply_label, const int64_t timestamp)
1253+
bool LegacyScriptPubKeyMan::ImportScriptPubKeys(const std::set<CScript>& script_pub_keys, const bool have_solving_data, const int64_t timestamp)
12541254
{
12551255
WalletBatch batch(m_storage.GetDatabase());
12561256
for (const CScript& script : script_pub_keys) {
@@ -1259,11 +1259,6 @@ bool LegacyScriptPubKeyMan::ImportScriptPubKeys(const std::string& label, const
12591259
return false;
12601260
}
12611261
}
1262-
CTxDestination dest;
1263-
ExtractDestination(script, dest);
1264-
if (apply_label && IsValidDestination(dest)) {
1265-
m_wallet.SetAddressBookWithDB(batch, dest, label, "receive");
1266-
}
12671262
}
12681263
return true;
12691264
}

src/wallet/scriptpubkeyman.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ class LegacyScriptPubKeyMan : public ScriptPubKeyMan, public FillableSigningProv
323323
bool ImportScripts(const std::set<CScript> scripts, int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
324324
bool ImportPrivKeys(const std::map<CKeyID, CKey>& privkey_map, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
325325
bool 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) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
326-
bool ImportScriptPubKeys(const std::string& label, const std::set<CScript>& script_pub_keys, const bool have_solving_data, const bool apply_label, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
326+
bool ImportScriptPubKeys(const std::set<CScript>& script_pub_keys, const bool have_solving_data, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
327327

328328
/* Returns true if the wallet can generate new keys */
329329
bool CanGenerateKeys();

src/wallet/wallet.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1410,9 +1410,19 @@ bool CWallet::ImportScriptPubKeys(const std::string& label, const std::set<CScri
14101410
return false;
14111411
}
14121412
AssertLockHeld(spk_man->cs_wallet);
1413-
if (!spk_man->ImportScriptPubKeys(label, script_pub_keys, have_solving_data, apply_label, timestamp)) {
1413+
if (!spk_man->ImportScriptPubKeys(script_pub_keys, have_solving_data, timestamp)) {
14141414
return false;
14151415
}
1416+
if (apply_label) {
1417+
WalletBatch batch(*database);
1418+
for (const CScript& script : script_pub_keys) {
1419+
CTxDestination dest;
1420+
ExtractDestination(script, dest);
1421+
if (IsValidDestination(dest)) {
1422+
SetAddressBookWithDB(batch, dest, label, "receive");
1423+
}
1424+
}
1425+
}
14161426
return true;
14171427
}
14181428

0 commit comments

Comments
 (0)