Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcdump.cpp
// Copyright (c) 2009-2016 The Bitcoin Core developers | // Copyright (c) 2009-2016 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include "base58.h" | #include "base58.h" | ||||
#include "chain.h" | #include "chain.h" | ||||
#include "config.h" | #include "config.h" | ||||
#include "core_io.h" | #include "core_io.h" | ||||
#include "dstencode.h" | #include "dstencode.h" | ||||
#include "init.h" | #include "init.h" | ||||
#include "merkleblock.h" | #include "merkleblock.h" | ||||
#include "rpc/safemode.h" | |||||
#include "rpc/server.h" | #include "rpc/server.h" | ||||
#include "rpcwallet.h" | #include "rpcwallet.h" | ||||
#include "script/script.h" | #include "script/script.h" | ||||
#include "script/standard.h" | #include "script/standard.h" | ||||
#include "sync.h" | #include "sync.h" | ||||
#include "util.h" | #include "util.h" | ||||
#include "utiltime.h" | #include "utiltime.h" | ||||
#include "validation.h" | #include "validation.h" | ||||
▲ Show 20 Lines • Show All 162 Lines • ▼ Show 20 Lines | if (request.fHelp || request.params.size() > 0) { | ||||
"\nImport a private key\n" + | "\nImport a private key\n" + | ||||
HelpExampleCli("importprivkey", "\"mykey\"") + | HelpExampleCli("importprivkey", "\"mykey\"") + | ||||
"\nAbort the running wallet rescan\n" + | "\nAbort the running wallet rescan\n" + | ||||
HelpExampleCli("abortrescan", "") + | HelpExampleCli("abortrescan", "") + | ||||
"\nAs a JSON-RPC call\n" + | "\nAs a JSON-RPC call\n" + | ||||
HelpExampleRpc("abortrescan", "")); | HelpExampleRpc("abortrescan", "")); | ||||
} | } | ||||
ObserveSafeMode(); | |||||
if (!pwallet->IsScanning() || pwallet->IsAbortingRescan()) { | if (!pwallet->IsScanning() || pwallet->IsAbortingRescan()) { | ||||
return false; | return false; | ||||
} | } | ||||
pwallet->AbortRescan(); | pwallet->AbortRescan(); | ||||
return true; | return true; | ||||
} | } | ||||
void ImportAddress(CWallet *, const CTxDestination &dest, | void ImportAddress(CWallet *, const CTxDestination &dest, | ||||
const std::string &strLabel); | const std::string &strLabel); | ||||
void ImportScript(CWallet *const pwallet, const CScript &script, | void ImportScript(CWallet *const pwallet, const CScript &script, | ||||
const std::string &strLabel, bool isRedeemScript) { | const std::string &strLabel, bool isRedeemScript) { | ||||
▲ Show 20 Lines • Show All 1,156 Lines • ▼ Show 20 Lines | if (fRescan && fRunScan && requests.size()) { | ||||
} | } | ||||
} | } | ||||
return response; | return response; | ||||
} | } | ||||
// clang-format off | // clang-format off | ||||
static const ContextFreeRPCCommand commands[] = { | static const ContextFreeRPCCommand commands[] = { | ||||
// category name actor (function) okSafeMode | // category name actor (function) argNames | ||||
// ------------------- ------------------------ ---------------------- ---------- | // ------------------- ------------------------ ---------------------- ---------- | ||||
{ "wallet", "abortrescan", abortrescan, false, {} }, | { "wallet", "abortrescan", abortrescan, {} }, | ||||
{ "wallet", "dumpprivkey", dumpprivkey, true, {"address"} }, | { "wallet", "dumpprivkey", dumpprivkey, {"address"} }, | ||||
{ "wallet", "dumpwallet", dumpwallet, true, {"filename"} }, | { "wallet", "dumpwallet", dumpwallet, {"filename"} }, | ||||
{ "wallet", "importmulti", importmulti, true, {"requests","options"} }, | { "wallet", "importmulti", importmulti, {"requests","options"} }, | ||||
{ "wallet", "importprivkey", importprivkey, true, {"privkey","label","rescan"} }, | { "wallet", "importprivkey", importprivkey, {"privkey","label","rescan"} }, | ||||
{ "wallet", "importwallet", importwallet, true, {"filename"} }, | { "wallet", "importwallet", importwallet, {"filename"} }, | ||||
{ "wallet", "importaddress", importaddress, true, {"address","label","rescan","p2sh"} }, | { "wallet", "importaddress", importaddress, {"address","label","rescan","p2sh"} }, | ||||
{ "wallet", "importprunedfunds", importprunedfunds, true, {"rawtransaction","txoutproof"} }, | { "wallet", "importprunedfunds", importprunedfunds, {"rawtransaction","txoutproof"} }, | ||||
{ "wallet", "importpubkey", importpubkey, true, {"pubkey","label","rescan"} }, | { "wallet", "importpubkey", importpubkey, {"pubkey","label","rescan"} }, | ||||
{ "wallet", "removeprunedfunds", removeprunedfunds, true, {"txid"} }, | { "wallet", "removeprunedfunds", removeprunedfunds, {"txid"} }, | ||||
}; | }; | ||||
// clang-format on | // clang-format on | ||||
void RegisterDumpRPCCommands(CRPCTable &t) { | void RegisterDumpRPCCommands(CRPCTable &t) { | ||||
if (gArgs.GetBoolArg("-disablewallet", false)) { | if (gArgs.GetBoolArg("-disablewallet", false)) { | ||||
return; | return; | ||||
} | } | ||||
for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++) { | for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++) { | ||||
t.appendCommand(commands[vcidx].name, &commands[vcidx]); | t.appendCommand(commands[vcidx].name, &commands[vcidx]); | ||||
} | } | ||||
} | } |