aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/util.cpp
diff options
context:
space:
mode:
authorIvan Metlushko <metlushko@gmail.com>2021-03-03 09:32:14 +0100
committerIvan Metlushko <metlushko@gmail.com>2021-03-03 09:36:23 +0100
commit5d5a90e819d23a302f9bec6b995a3116ead6ae94 (patch)
tree92314f386805d8cd8ef1de3998c31784a8c02bfb /src/rpc/util.cpp
parente49117470b77fb7d53be122c6490ba163c6e304d (diff)
downloadbitcoin-5d5a90e819d23a302f9bec6b995a3116ead6ae94.tar.xz
rpc: Add HelpExampleRpcNamed
Diffstat (limited to 'src/rpc/util.cpp')
-rw-r--r--src/rpc/util.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/rpc/util.cpp b/src/rpc/util.cpp
index e890c0108a..b4533c14d0 100644
--- a/src/rpc/util.cpp
+++ b/src/rpc/util.cpp
@@ -124,6 +124,17 @@ std::string HelpExampleRpc(const std::string& methodname, const std::string& arg
"\"method\": \"" + methodname + "\", \"params\": [" + args + "]}' -H 'content-type: text/plain;' http://127.0.0.1:8332/\n";
}
+std::string HelpExampleRpcNamed(const std::string& methodname, const RPCArgList& args)
+{
+ UniValue params(UniValue::VOBJ);
+ for (const auto& param: args) {
+ params.pushKV(param.first, param.second);
+ }
+
+ return "> curl --user myusername --data-binary '{\"jsonrpc\": \"1.0\", \"id\": \"curltest\", "
+ "\"method\": \"" + methodname + "\", \"params\": " + params.write() + "}' -H 'content-type: text/plain;' http://127.0.0.1:8332/\n";
+}
+
// Converts a hex string to a public key if possible
CPubKey HexToPubKey(const std::string& hex_in)
{