Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcdump.cpp
Show First 20 Lines • Show All 101 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() < 1 || request.params.size() > 3) | ||||
HelpExampleRpc("importprivkey", "\"mykey\", \"testing\", false")); | HelpExampleRpc("importprivkey", "\"mykey\", \"testing\", false")); | ||||
LOCK2(cs_main, pwallet->cs_wallet); | LOCK2(cs_main, pwallet->cs_wallet); | ||||
EnsureWalletIsUnlocked(pwallet); | EnsureWalletIsUnlocked(pwallet); | ||||
std::string strSecret = request.params[0].get_str(); | std::string strSecret = request.params[0].get_str(); | ||||
std::string strLabel = ""; | std::string strLabel = ""; | ||||
if (request.params.size() > 1) { | if (!request.params[1].isNull()) { | ||||
strLabel = request.params[1].get_str(); | strLabel = request.params[1].get_str(); | ||||
} | } | ||||
// Whether to perform rescan after import | // Whether to perform rescan after import | ||||
bool fRescan = true; | bool fRescan = true; | ||||
if (request.params.size() > 2) { | if (!request.params[2].isNull()) { | ||||
fRescan = request.params[2].get_bool(); | fRescan = request.params[2].get_bool(); | ||||
} | } | ||||
if (fRescan && fPruneMode) { | if (fRescan && fPruneMode) { | ||||
throw JSONRPCError(RPC_WALLET_ERROR, | throw JSONRPCError(RPC_WALLET_ERROR, | ||||
"Rescan is disabled in pruned mode"); | "Rescan is disabled in pruned mode"); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 143 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() < 1 || | ||||
"\nImport using a label without rescan\n" + | "\nImport using a label without rescan\n" + | ||||
HelpExampleCli("importaddress", "\"myscript\" \"testing\" false") + | HelpExampleCli("importaddress", "\"myscript\" \"testing\" false") + | ||||
"\nAs a JSON-RPC call\n" + | "\nAs a JSON-RPC call\n" + | ||||
HelpExampleRpc("importaddress", | HelpExampleRpc("importaddress", | ||||
"\"myscript\", \"testing\", false")); | "\"myscript\", \"testing\", false")); | ||||
} | } | ||||
std::string strLabel = ""; | std::string strLabel = ""; | ||||
if (request.params.size() > 1) { | if (!request.params[1].isNull()) { | ||||
strLabel = request.params[1].get_str(); | strLabel = request.params[1].get_str(); | ||||
} | } | ||||
// Whether to perform rescan after import | // Whether to perform rescan after import | ||||
bool fRescan = true; | bool fRescan = true; | ||||
if (request.params.size() > 2) { | if (!request.params[2].isNull()) { | ||||
fRescan = request.params[2].get_bool(); | fRescan = request.params[2].get_bool(); | ||||
} | } | ||||
if (fRescan && fPruneMode) { | if (fRescan && fPruneMode) { | ||||
throw JSONRPCError(RPC_WALLET_ERROR, | throw JSONRPCError(RPC_WALLET_ERROR, | ||||
"Rescan is disabled in pruned mode"); | "Rescan is disabled in pruned mode"); | ||||
} | } | ||||
// Whether to import a p2sh version, too | // Whether to import a p2sh version, too | ||||
bool fP2SH = false; | bool fP2SH = false; | ||||
if (request.params.size() > 3) { | if (!request.params[3].isNull()) { | ||||
fP2SH = request.params[3].get_bool(); | fP2SH = request.params[3].get_bool(); | ||||
} | } | ||||
LOCK2(cs_main, pwallet->cs_wallet); | LOCK2(cs_main, pwallet->cs_wallet); | ||||
CTxDestination dest = | CTxDestination dest = | ||||
DecodeDestination(request.params[0].get_str(), config.GetChainParams()); | DecodeDestination(request.params[0].get_str(), config.GetChainParams()); | ||||
if (IsValidDestination(dest)) { | if (IsValidDestination(dest)) { | ||||
▲ Show 20 Lines • Show All 174 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() < 1 || | ||||
HelpExampleCli("importpubkey", "\"mypubkey\"") + | HelpExampleCli("importpubkey", "\"mypubkey\"") + | ||||
"\nImport using a label without rescan\n" + | "\nImport using a label without rescan\n" + | ||||
HelpExampleCli("importpubkey", "\"mypubkey\" \"testing\" false") + | HelpExampleCli("importpubkey", "\"mypubkey\" \"testing\" false") + | ||||
"\nAs a JSON-RPC call\n" + | "\nAs a JSON-RPC call\n" + | ||||
HelpExampleRpc("importpubkey", "\"mypubkey\", \"testing\", false")); | HelpExampleRpc("importpubkey", "\"mypubkey\", \"testing\", false")); | ||||
} | } | ||||
std::string strLabel = ""; | std::string strLabel = ""; | ||||
if (request.params.size() > 1) { | if (!request.params[1].isNull()) { | ||||
strLabel = request.params[1].get_str(); | strLabel = request.params[1].get_str(); | ||||
} | } | ||||
// Whether to perform rescan after import | // Whether to perform rescan after import | ||||
bool fRescan = true; | bool fRescan = true; | ||||
if (request.params.size() > 2) { | if (!request.params[2].isNull()) { | ||||
fRescan = request.params[2].get_bool(); | fRescan = request.params[2].get_bool(); | ||||
} | } | ||||
if (fRescan && fPruneMode) { | if (fRescan && fPruneMode) { | ||||
throw JSONRPCError(RPC_WALLET_ERROR, | throw JSONRPCError(RPC_WALLET_ERROR, | ||||
"Rescan is disabled in pruned mode"); | "Rescan is disabled in pruned mode"); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 798 Lines • ▼ Show 20 Lines | UniValue importmulti(const Config &config, const JSONRPCRequest &mainRequest) { | ||||
RPCTypeCheck(mainRequest.params, {UniValue::VARR, UniValue::VOBJ}); | RPCTypeCheck(mainRequest.params, {UniValue::VARR, UniValue::VOBJ}); | ||||
const UniValue &requests = mainRequest.params[0]; | const UniValue &requests = mainRequest.params[0]; | ||||
// Default options | // Default options | ||||
bool fRescan = true; | bool fRescan = true; | ||||
if (mainRequest.params.size() > 1) { | if (!mainRequest.params[1].isNull()) { | ||||
const UniValue &options = mainRequest.params[1]; | const UniValue &options = mainRequest.params[1]; | ||||
if (options.exists("rescan")) { | if (options.exists("rescan")) { | ||||
fRescan = options["rescan"].get_bool(); | fRescan = options["rescan"].get_bool(); | ||||
} | } | ||||
} | } | ||||
LOCK2(cs_main, pwallet->cs_wallet); | LOCK2(cs_main, pwallet->cs_wallet); | ||||
▲ Show 20 Lines • Show All 119 Lines • Show Last 20 Lines |