mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-28 23:15:52 +00:00
Refactor RPC validation_create.
This commit is contained in:
@@ -229,6 +229,20 @@ Json::Value RPCParser::parseUnlDelete(const Json::Value& jvParams)
|
|||||||
return jvRequest;
|
return jvRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// validation_create [<pass_phrase>|<seed>|<seed_key>]
|
||||||
|
//
|
||||||
|
// NOTE: It is poor security to specify secret information on the command line. This information might be saved in the command
|
||||||
|
// shell history file (e.g. .bash_history) and it may be leaked via the process status command (i.e. ps).
|
||||||
|
Json::Value RPCParser::parseValidationCreate(const Json::Value& jvParams)
|
||||||
|
{
|
||||||
|
Json::Value jvRequest;
|
||||||
|
|
||||||
|
if (jvParams.size())
|
||||||
|
jvRequest["secret"] = jvParams[0u].asString();
|
||||||
|
|
||||||
|
return jvRequest;
|
||||||
|
}
|
||||||
|
|
||||||
// wallet_accounts <seed>
|
// wallet_accounts <seed>
|
||||||
Json::Value RPCParser::parseWalletAccounts(const Json::Value& jvParams)
|
Json::Value RPCParser::parseWalletAccounts(const Json::Value& jvParams)
|
||||||
{
|
{
|
||||||
@@ -319,7 +333,7 @@ Json::Value RPCParser::parseCommand(std::string strMethod, Json::Value jvParams)
|
|||||||
{ "unl_reset", &RPCParser::parseAsIs, 0, 0 },
|
{ "unl_reset", &RPCParser::parseAsIs, 0, 0 },
|
||||||
{ "unl_score", &RPCParser::parseAsIs, 0, 0 },
|
{ "unl_score", &RPCParser::parseAsIs, 0, 0 },
|
||||||
|
|
||||||
// { "validation_create", &RPCParser::doValidationCreate, 0, 1, false, false, optNone },
|
{ "validation_create", &RPCParser::parseValidationCreate, 0, 1 },
|
||||||
// { "validation_seed", &RPCParser::doValidationSeed, 0, 1, false, false, optNone },
|
// { "validation_seed", &RPCParser::doValidationSeed, 0, 1, false, false, optNone },
|
||||||
|
|
||||||
{ "wallet_accounts", &RPCParser::parseWalletAccounts, 1, 1 },
|
{ "wallet_accounts", &RPCParser::parseWalletAccounts, 1, 1 },
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ protected:
|
|||||||
Json::Value parseSubmit(const Json::Value& jvParams);
|
Json::Value parseSubmit(const Json::Value& jvParams);
|
||||||
Json::Value parseUnlAdd(const Json::Value& jvParams);
|
Json::Value parseUnlAdd(const Json::Value& jvParams);
|
||||||
Json::Value parseUnlDelete(const Json::Value& jvParams);
|
Json::Value parseUnlDelete(const Json::Value& jvParams);
|
||||||
|
Json::Value parseValidationCreate(const Json::Value& jvParams);
|
||||||
Json::Value parseWalletAccounts(const Json::Value& jvParams);
|
Json::Value parseWalletAccounts(const Json::Value& jvParams);
|
||||||
Json::Value parseWalletPropose(const Json::Value& jvParams);
|
Json::Value parseWalletPropose(const Json::Value& jvParams);
|
||||||
Json::Value parseWalletSeed(const Json::Value& jvParams);
|
Json::Value parseWalletSeed(const Json::Value& jvParams);
|
||||||
|
|||||||
@@ -1237,28 +1237,27 @@ Json::Value RPCHandler::doAccountTransactions(Json::Value jvRequest)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// validation_create [<pass_phrase>|<seed>|<seed_key>]
|
// {
|
||||||
//
|
// secret: <string>
|
||||||
// NOTE: It is poor security to specify secret information on the command line. This information might be saved in the command
|
// }
|
||||||
// shell history file (e.g. .bash_history) and it may be leaked via the process status command (i.e. ps).
|
Json::Value RPCHandler::doValidationCreate(Json::Value jvParams) {
|
||||||
Json::Value RPCHandler::doValidationCreate(Json::Value params) {
|
RippleAddress raSeed;
|
||||||
RippleAddress naSeed;
|
|
||||||
Json::Value obj(Json::objectValue);
|
Json::Value obj(Json::objectValue);
|
||||||
|
|
||||||
if (params.empty())
|
if (!jvParams.isMember("secret"))
|
||||||
{
|
{
|
||||||
std::cerr << "Creating random validation seed." << std::endl;
|
cLog(lsDEBUG) << "Creating random validation seed.";
|
||||||
|
|
||||||
naSeed.setSeedRandom(); // Get a random seed.
|
raSeed.setSeedRandom(); // Get a random seed.
|
||||||
}
|
}
|
||||||
else if (!naSeed.setSeedGeneric(params[0u].asString()))
|
else if (!raSeed.setSeedGeneric(jvParams["secret"].asString()))
|
||||||
{
|
{
|
||||||
return rpcError(rpcBAD_SEED);
|
return rpcError(rpcBAD_SEED);
|
||||||
}
|
}
|
||||||
|
|
||||||
obj["validation_public_key"] = RippleAddress::createNodePublic(naSeed).humanNodePublic();
|
obj["validation_public_key"] = RippleAddress::createNodePublic(raSeed).humanNodePublic();
|
||||||
obj["validation_seed"] = naSeed.humanSeed();
|
obj["validation_seed"] = raSeed.humanSeed();
|
||||||
obj["validation_key"] = naSeed.humanSeed1751();
|
obj["validation_key"] = raSeed.humanSeed1751();
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
@@ -2217,7 +2216,7 @@ Json::Value RPCHandler::doCommand(Json::Value& jvParams, int iRole)
|
|||||||
{ "unl_reset", &RPCHandler::doUnlReset, -1, -1, true, false, optNone },
|
{ "unl_reset", &RPCHandler::doUnlReset, -1, -1, true, false, optNone },
|
||||||
{ "unl_score", &RPCHandler::doUnlScore, -1, -1, true, false, optNone },
|
{ "unl_score", &RPCHandler::doUnlScore, -1, -1, true, false, optNone },
|
||||||
|
|
||||||
{ "validation_create", &RPCHandler::doValidationCreate, 0, 1, false, false, optNone },
|
{ "validation_create", &RPCHandler::doValidationCreate, -1, -1, false, false, optNone },
|
||||||
{ "validation_seed", &RPCHandler::doValidationSeed, 0, 1, false, false, optNone },
|
{ "validation_seed", &RPCHandler::doValidationSeed, 0, 1, false, false, optNone },
|
||||||
|
|
||||||
{ "wallet_accounts", &RPCHandler::doWalletAccounts, -1, -1, false, false, optCurrent },
|
{ "wallet_accounts", &RPCHandler::doWalletAccounts, -1, -1, false, false, optCurrent },
|
||||||
|
|||||||
Reference in New Issue
Block a user