Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcdump.cpp
Show First 20 Lines • Show All 110 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() < 1 || | ||||
"may report that the imported key exists but related transactions " | "may report that the imported key exists but related transactions " | ||||
"are still missing, leading to temporarily incorrect/bogus " | "are still missing, leading to temporarily incorrect/bogus " | ||||
"balances and unspent outputs until rescan completes.\n", | "balances and unspent outputs until rescan completes.\n", | ||||
{ | { | ||||
{"privkey", RPCArg::Type::STR, /* opt */ false, | {"privkey", RPCArg::Type::STR, /* opt */ false, | ||||
/* default_val */ "", "The private key (see dumpprivkey)"}, | /* default_val */ "", "The private key (see dumpprivkey)"}, | ||||
{"label", RPCArg::Type::STR, /* opt */ true, | {"label", RPCArg::Type::STR, /* opt */ true, | ||||
/* default_val */ | /* default_val */ | ||||
"\"\"", "An optional label"}, | "current label if address exists, otherwise \"\"", | ||||
"An optional label"}, | |||||
{"rescan", RPCArg::Type::BOOL, /* opt */ true, | {"rescan", RPCArg::Type::BOOL, /* opt */ true, | ||||
/* default_val */ "true", | /* default_val */ "true", | ||||
"Rescan the wallet for transactions"}, | "Rescan the wallet for transactions"}, | ||||
}, | }, | ||||
RPCResults{}, | RPCResults{}, | ||||
RPCExamples{ | RPCExamples{ | ||||
"\nDump a private key\n" + | "\nDump a private key\n" + | ||||
HelpExampleCli("dumpprivkey", "\"myaddress\"") + | HelpExampleCli("dumpprivkey", "\"myaddress\"") + | ||||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | bool fRescan = true; | ||||
"Invalid private key encoding"); | "Invalid private key encoding"); | ||||
} | } | ||||
CPubKey pubkey = key.GetPubKey(); | CPubKey pubkey = key.GetPubKey(); | ||||
assert(key.VerifyPubKey(pubkey)); | assert(key.VerifyPubKey(pubkey)); | ||||
CKeyID vchAddress = pubkey.GetID(); | CKeyID vchAddress = pubkey.GetID(); | ||||
{ | { | ||||
pwallet->MarkDirty(); | pwallet->MarkDirty(); | ||||
// We don't know which corresponding address will be used; label | |||||
// them all | // We don't know which corresponding address will be used; | ||||
// label all new addresses, and label existing addresses if a | |||||
// label was passed. | |||||
for (const auto &dest : GetAllDestinationsForKey(pubkey)) { | for (const auto &dest : GetAllDestinationsForKey(pubkey)) { | ||||
if (!request.params[1].isNull() || | |||||
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 | // Don't throw error in case a key is already there | ||||
if (pwallet->HaveKey(vchAddress)) { | if (pwallet->HaveKey(vchAddress)) { | ||||
return NullUniValue; | return NullUniValue; | ||||
} | } | ||||
pwallet->LearnAllRelatedScripts(pubkey); | pwallet->LearnAllRelatedScripts(pubkey); | ||||
▲ Show 20 Lines • Show All 1,526 Lines • Show Last 20 Lines |