aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.cpp1
-rw-r--r--main.h10
-rw-r--r--rpc.cpp30
3 files changed, 34 insertions, 7 deletions
diff --git a/main.cpp b/main.cpp
index 6e7cb3eac8..1d9b35b534 100644
--- a/main.cpp
+++ b/main.cpp
@@ -1953,7 +1953,6 @@ string GetWarnings(string strFor)
{
nPriority = alert.nPriority;
strStatusBar = alert.strStatusBar;
- strRPC = alert.strRPCError;
}
}
}
diff --git a/main.h b/main.h
index 0b950e8074..088e2860c3 100644
--- a/main.h
+++ b/main.h
@@ -1754,7 +1754,7 @@ public:
// Actions
string strComment;
string strStatusBar;
- string strRPCError;
+ string strReserved;
IMPLEMENT_SERIALIZE
(
@@ -1772,7 +1772,7 @@ public:
READWRITE(strComment);
READWRITE(strStatusBar);
- READWRITE(strRPCError);
+ READWRITE(strReserved);
)
void SetNull()
@@ -1790,7 +1790,7 @@ public:
strComment.clear();
strStatusBar.clear();
- strRPCError.clear();
+ strReserved.clear();
}
string ToString() const
@@ -1815,7 +1815,6 @@ public:
" nPriority = %d\n"
" strComment = \"%s\"\n"
" strStatusBar = \"%s\"\n"
- " strRPCError = \"%s\"\n"
")\n",
nVersion,
nRelayUntil,
@@ -1828,8 +1827,7 @@ public:
strSetSubVer.c_str(),
nPriority,
strComment.c_str(),
- strStatusBar.c_str(),
- strRPCError.c_str());
+ strStatusBar.c_str());
}
void print() const
diff --git a/rpc.cpp b/rpc.cpp
index 49e87e56af..b9ed61de73 100644
--- a/rpc.cpp
+++ b/rpc.cpp
@@ -1178,6 +1178,31 @@ pair<string, rpcfn_type> pCallTable[] =
};
map<string, rpcfn_type> mapCallTable(pCallTable, pCallTable + sizeof(pCallTable)/sizeof(pCallTable[0]));
+string pAllowInSafeMode[] =
+{
+ "help",
+ "stop",
+ "getblockcount",
+ "getblocknumber",
+ "getconnectioncount",
+ "getdifficulty",
+ "getgenerate",
+ "setgenerate",
+ "gethashespersec",
+ "getinfo",
+ "getnewaddress",
+ "getaccountaddress",
+ "setlabel",
+ "getaccount",
+ "getlabel", // deprecated
+ "getaddressesbyaccount",
+ "getaddressesbylabel", // deprecated
+ "backupwallet",
+ "validateaddress",
+ "getwork",
+};
+set<string> setAllowInSafeMode(pAllowInSafeMode, pAllowInSafeMode + sizeof(pAllowInSafeMode)/sizeof(pAllowInSafeMode[0]));
+
@@ -1615,6 +1640,11 @@ void ThreadRPCServer2(void* parg)
if (mi == mapCallTable.end())
throw JSONRPCError(-32601, "Method not found");
+ // Observe safe mode
+ string strWarning = GetWarnings("rpc");
+ if (strWarning != "" && !GetBoolArg("-disablesafemode") && !setAllowInSafeMode.count(strMethod))
+ throw JSONRPCError(-2, string("Safe mode: ") + strWarning);
+
try
{
// Execute