aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/request.h
diff options
context:
space:
mode:
authorKarl-Johan Alm <karljohan-alm@garage.co.jp>2019-06-20 02:39:38 +0900
committerKarl-Johan Alm <karljohan-alm@garage.co.jp>2019-07-05 11:22:02 +0900
commit5c5e32bbe3dfa790dd8bb421fbd6301ae10b09f5 (patch)
tree8dcdcbeae96f2a7fb03b36bfa50d269b6bc68749 /src/rpc/request.h
parent0ab8ba1ac65b70f044a5e323b13d098cef33695a (diff)
downloadbitcoin-5c5e32bbe3dfa790dd8bb421fbd6301ae10b09f5.tar.xz
rpc: migrate JSONRPCRequest functionality into request.cpp
Diffstat (limited to 'src/rpc/request.h')
-rw-r--r--src/rpc/request.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/rpc/request.h b/src/rpc/request.h
new file mode 100644
index 0000000000..99eb4f9354
--- /dev/null
+++ b/src/rpc/request.h
@@ -0,0 +1,42 @@
+// Copyright (c) 2010 Satoshi Nakamoto
+// Copyright (c) 2009-2019 The Bitcoin Core developers
+// Distributed under the MIT software license, see the accompanying
+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+#ifndef BITCOIN_RPC_REQUEST_H
+#define BITCOIN_RPC_REQUEST_H
+
+#include <string>
+
+#include <univalue.h>
+
+UniValue JSONRPCRequestObj(const std::string& strMethod, const UniValue& params, const UniValue& id);
+UniValue JSONRPCReplyObj(const UniValue& result, const UniValue& error, const UniValue& id);
+std::string JSONRPCReply(const UniValue& result, const UniValue& error, const UniValue& id);
+UniValue JSONRPCError(int code, const std::string& message);
+
+/** Generate a new RPC authentication cookie and write it to disk */
+bool GenerateAuthCookie(std::string *cookie_out);
+/** Read the RPC authentication cookie from disk */
+bool GetAuthCookie(std::string *cookie_out);
+/** Delete RPC authentication cookie from disk */
+void DeleteAuthCookie();
+/** Parse JSON-RPC batch reply into a vector */
+std::vector<UniValue> JSONRPCProcessBatchReply(const UniValue &in, size_t num);
+
+class JSONRPCRequest
+{
+public:
+ UniValue id;
+ std::string strMethod;
+ UniValue params;
+ bool fHelp;
+ std::string URI;
+ std::string authUser;
+ std::string peerAddr;
+
+ JSONRPCRequest() : id(NullUniValue), params(NullUniValue), fHelp(false) {}
+ void parse(const UniValue& valRequest);
+};
+
+#endif // BITCOIN_RPC_REQUEST_H