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
This commit is contained in:
parent
c6a8274247
commit
a00d1e5ec5
1 changed files with 8 additions and 3 deletions
|
@ -538,11 +538,16 @@ UniValue importpubkey(const JSONRPCRequest& request)
|
||||||
auto locked_chain = pwallet->chain().lock();
|
auto locked_chain = pwallet->chain().lock();
|
||||||
LOCK(pwallet->cs_wallet);
|
LOCK(pwallet->cs_wallet);
|
||||||
|
|
||||||
|
std::set<CScript> script_pub_keys;
|
||||||
for (const auto& dest : GetAllDestinationsForKey(pubKey)) {
|
for (const auto& dest : GetAllDestinationsForKey(pubKey)) {
|
||||||
ImportAddress(pwallet, dest, strLabel);
|
script_pub_keys.insert(GetScriptForDestination(dest));
|
||||||
}
|
}
|
||||||
ImportScript(pwallet, GetScriptForRawPubKey(pubKey), strLabel, false);
|
|
||||||
pwallet->LearnAllRelatedScripts(pubKey);
|
pwallet->MarkDirty();
|
||||||
|
|
||||||
|
pwallet->ImportScriptPubKeys(strLabel, script_pub_keys, true /* have_solving_data */, true /* apply_label */, 1 /* timestamp */);
|
||||||
|
|
||||||
|
pwallet->ImportPubKeys({pubKey.GetID()}, {{pubKey.GetID(), pubKey}} , {} /* key_origins */, false /* add_keypool */, false /* internal */, 1 /* timestamp */);
|
||||||
}
|
}
|
||||||
if (fRescan)
|
if (fRescan)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue