aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/rpcdump.cpp
diff options
context:
space:
mode:
authorLuke Dashjr <luke-jr+git@utopios.org>2017-01-07 19:15:22 +0000
committerLuke Dashjr <luke-jr+git@utopios.org>2017-02-27 20:45:18 +0000
commit86be48a77c584cb80b237c31dee9a06ee2aaf2f9 (patch)
tree56e3b17bb40ee39de38f58d5fdafcdddc725941c /src/wallet/rpcdump.cpp
parenta4356328e00155796cd7aa188e96c51c09562423 (diff)
More tightly couple EnsureWalletIsAvailable with GetWalletForJSONRPCRequest where appropriate
Diffstat (limited to 'src/wallet/rpcdump.cpp')
-rw-r--r--src/wallet/rpcdump.cpp24
1 files changed, 8 insertions, 16 deletions
diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp
index e4d4d6b36d..4629311095 100644
--- a/src/wallet/rpcdump.cpp
+++ b/src/wallet/rpcdump.cpp
@@ -77,11 +77,10 @@ std::string DecodeDumpString(const std::string &str) {
UniValue importprivkey(const JSONRPCRequest& request)
{
CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
-
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue;
}
-
+
if (request.fHelp || request.params.size() < 1 || request.params.size() > 3)
throw runtime_error(
"importprivkey \"bitcoinprivkey\" ( \"label\" ) ( rescan )\n"
@@ -195,11 +194,10 @@ void ImportAddress(CWallet * const pwallet, const CBitcoinAddress& address, cons
UniValue importaddress(const JSONRPCRequest& request)
{
CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
-
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue;
}
-
+
if (request.fHelp || request.params.size() < 1 || request.params.size() > 4)
throw runtime_error(
"importaddress \"address\" ( \"label\" rescan p2sh )\n"
@@ -266,7 +264,6 @@ UniValue importaddress(const JSONRPCRequest& request)
UniValue importprunedfunds(const JSONRPCRequest& request)
{
CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
-
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue;
}
@@ -328,7 +325,6 @@ UniValue importprunedfunds(const JSONRPCRequest& request)
UniValue removeprunedfunds(const JSONRPCRequest& request)
{
CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
-
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue;
}
@@ -367,7 +363,6 @@ UniValue removeprunedfunds(const JSONRPCRequest& request)
UniValue importpubkey(const JSONRPCRequest& request)
{
CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
-
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue;
}
@@ -428,11 +423,10 @@ UniValue importpubkey(const JSONRPCRequest& request)
UniValue importwallet(const JSONRPCRequest& request)
{
CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
-
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue;
}
-
+
if (request.fHelp || request.params.size() != 1)
throw runtime_error(
"importwallet \"filename\"\n"
@@ -537,11 +531,10 @@ UniValue importwallet(const JSONRPCRequest& request)
UniValue dumpprivkey(const JSONRPCRequest& request)
{
CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
-
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue;
}
-
+
if (request.fHelp || request.params.size() != 1)
throw runtime_error(
"dumpprivkey \"address\"\n"
@@ -579,11 +572,10 @@ UniValue dumpprivkey(const JSONRPCRequest& request)
UniValue dumpwallet(const JSONRPCRequest& request)
{
CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
-
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue;
}
-
+
if (request.fHelp || request.params.size() != 1)
throw runtime_error(
"dumpwallet \"filename\"\n"
@@ -1003,6 +995,9 @@ int64_t GetImportTimestamp(const UniValue& data, int64_t now)
UniValue importmulti(const JSONRPCRequest& mainRequest)
{
CWallet * const pwallet = GetWalletForJSONRPCRequest(mainRequest);
+ if (!EnsureWalletIsAvailable(pwallet, mainRequest.fHelp)) {
+ return NullUniValue;
+ }
// clang-format off
if (mainRequest.fHelp || mainRequest.params.size() < 1 || mainRequest.params.size() > 2)
@@ -1042,9 +1037,6 @@ UniValue importmulti(const JSONRPCRequest& mainRequest)
" [{ \"success\": true } , { \"success\": false, \"error\": { \"code\": -1, \"message\": \"Internal Server Error\"} }, ... ]\n");
// clang-format on
- if (!EnsureWalletIsAvailable(pwallet, mainRequest.fHelp)) {
- return NullUniValue;
- }
RPCTypeCheck(mainRequest.params, boost::assign::list_of(UniValue::VARR)(UniValue::VOBJ));