aboutsummaryrefslogtreecommitdiff
path: root/src/init.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2015-02-04 10:16:24 +0100
committerWladimir J. van der Laan <laanwj@gmail.com>2015-02-04 10:23:09 +0100
commit87ecfb0f9675ef46d360014a65886e9556d28e66 (patch)
tree8c093b395637147d1d2dc31b7582041231b04e6e /src/init.cpp
parentfcf646c9b08e7f846d6c99314f937ace50809d7a (diff)
parent5ebe0956b391cfa782fd97bb417d20b479df6a36 (diff)
Merge pull request #5711
5ebe095 Trim RPC command table (Wladimir J. van der Laan) 4401b2d Removed main.h dependency from rpcserver.cpp (Eric Lombrozo)
Diffstat (limited to 'src/init.cpp')
-rw-r--r--src/init.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/init.cpp b/src/init.cpp
index c2af23139c..c8f32d8bfd 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -234,6 +234,26 @@ bool static Bind(const CService &addr, unsigned int flags) {
return true;
}
+void OnRPCStopped()
+{
+ cvBlockChange.notify_all();
+ LogPrint("rpc", "RPC stopped.\n");
+}
+
+void OnRPCPreCommand(const CRPCCommand& cmd)
+{
+#ifdef ENABLE_WALLET
+ if (cmd.reqWallet && !pwalletMain)
+ throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Method not found (disabled)");
+#endif
+
+ // Observe safe mode
+ string strWarning = GetWarnings("rpc");
+ if (strWarning != "" && !GetBoolArg("-disablesafemode", false) &&
+ !cmd.okSafeMode)
+ throw JSONRPCError(RPC_FORBIDDEN_BY_SAFE_MODE, string("Safe mode: ") + strWarning);
+}
+
std::string HelpMessage(HelpMessageMode mode)
{
// When adding new options to the categories, please keep and ensure alphabetical ordering.
@@ -802,6 +822,8 @@ bool AppInit2(boost::thread_group& threadGroup)
if (fServer)
{
uiInterface.InitMessage.connect(SetRPCWarmupStatus);
+ RPCServer::OnStopped(&OnRPCStopped);
+ RPCServer::OnPreCommand(&OnRPCPreCommand);
StartRPCThreads();
}