Skip to content

Commit a00d1e5

Browse files
committed
Have importpubkey use CWallet's ImportScriptPubKeys and ImportPubKeys functions
Behavior changes: * If any scripts for the pubkey were already in the wallet, their timestamps will be set to 1 and label updated
1 parent c6a8274 commit a00d1e5

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/wallet/rpcdump.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -538,11 +538,16 @@ UniValue importpubkey(const JSONRPCRequest& request)
538538
auto locked_chain = pwallet->chain().lock();
539539
LOCK(pwallet->cs_wallet);
540540

541+
std::set<CScript> script_pub_keys;
541542
for (const auto& dest : GetAllDestinationsForKey(pubKey)) {
542-
ImportAddress(pwallet, dest, strLabel);
543+
script_pub_keys.insert(GetScriptForDestination(dest));
543544
}
544-
ImportScript(pwallet, GetScriptForRawPubKey(pubKey), strLabel, false);
545-
pwallet->LearnAllRelatedScripts(pubKey);
545+
546+
pwallet->MarkDirty();
547+
548+
pwallet->ImportScriptPubKeys(strLabel, script_pub_keys, true /* have_solving_data */, true /* apply_label */, 1 /* timestamp */);
549+
550+
pwallet->ImportPubKeys({pubKey.GetID()}, {{pubKey.GetID(), pubKey}} , {} /* key_origins */, false /* add_keypool */, false /* internal */, 1 /* timestamp */);
546551
}
547552
if (fRescan)
548553
{

0 commit comments

Comments
 (0)