Skip to content

Commit

Permalink
RPC: Add help details for the bls RPC (#2403)
Browse files Browse the repository at this point in the history
* RPC: Add help details for the bls RPC

* RPC: Refactor to match gobject RPC behavior

* RPC: Use command instead of strCommand for consistency within file

* RPC: BLS help cleanup

* RCP: Remove leading underscore on bls_help
  • Loading branch information
thephez authored and UdjinM6 committed Nov 1, 2018
1 parent 30a2b28 commit 7011fec
Showing 1 changed file with 34 additions and 4 deletions.
38 changes: 34 additions & 4 deletions src/rpc/rpcevo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -875,8 +875,27 @@ UniValue protx(const JSONRPCRequest& request)
}
#endif//ENABLE_WALLET

void bls_generate_help()
{
throw std::runtime_error(
"bls generate\n"
"\nReturns a BLS secret/public key pair.\n"
"\nResult:\n"
"{\n"
" \"secret\": \"xxxx\", (string) BLS secret key\n"
" \"public\": \"xxxx\", (string) BLS public key\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("bls generate", "")
);
}

UniValue bls_generate(const JSONRPCRequest& request)
{
if (request.fHelp || request.params.size() != 1) {
bls_generate_help();
}

CBLSSecretKey sk;
sk.MakeNewKey();

Expand All @@ -886,20 +905,31 @@ UniValue bls_generate(const JSONRPCRequest& request)
return ret;
}

void bls_help()
{
throw std::runtime_error(
"bls \"command\" ...\n"
"Set of commands to execute BLS related actions.\n"
"To get help on individual commands, use \"help bls command\".\n"
"\nArguments:\n"
"1. \"command\" (string, required) The command to execute\n"
"\nAvailable commands:\n"
" generate - Create a BLS secret/public key pair\n"
);
}

UniValue _bls(const JSONRPCRequest& request)
{
if (request.params.empty()) {
throw std::runtime_error(
"bls \"command\" ...\n"
);
bls_help();
}

std::string command = request.params[0].get_str();

if (command == "generate") {
return bls_generate(request);
} else {
throw std::runtime_error("invalid command: " + command);
bls_help();
}
}

Expand Down

0 comments on commit 7011fec

Please sign in to comment.