Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcdump.cpp
Show First 20 Lines • Show All 192 Lines • ▼ Show 20 Lines | bool fRescan = true; | ||||
// label was passed. | // label was passed. | ||||
for (const auto &dest : GetAllDestinationsForKey(pubkey)) { | for (const auto &dest : GetAllDestinationsForKey(pubkey)) { | ||||
if (!request.params[1].isNull() || | if (!request.params[1].isNull() || | ||||
pwallet->mapAddressBook.count(dest) == 0) { | pwallet->mapAddressBook.count(dest) == 0) { | ||||
pwallet->SetAddressBook(dest, strLabel, "receive"); | pwallet->SetAddressBook(dest, strLabel, "receive"); | ||||
} | } | ||||
} | } | ||||
// Don't throw error in case a key is already there | // Use timestamp of 1 to scan the whole chain | ||||
if (pwallet->HaveKey(vchAddress)) { | if (!pwallet->ImportPrivKeys({{vchAddress, key}}, 1)) { | ||||
return NullUniValue; | |||||
} | |||||
pwallet->LearnAllRelatedScripts(pubkey); | |||||
// whenever a key is imported, we need to scan the whole chain | |||||
pwallet->UpdateTimeFirstKey(1); | |||||
pwallet->mapKeyMetadata[vchAddress].nCreateTime = 1; | |||||
if (!pwallet->AddKeyPubKey(key, pubkey)) { | |||||
throw JSONRPCError(RPC_WALLET_ERROR, | throw JSONRPCError(RPC_WALLET_ERROR, | ||||
"Error adding key to wallet"); | "Error adding key to wallet"); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
if (fRescan) { | if (fRescan) { | ||||
RescanWallet(*pwallet, reserver); | RescanWallet(*pwallet, reserver); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,658 Lines • Show Last 20 Lines |