mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Add RPC command validation_seed.
This commit is contained in:
@@ -1479,40 +1479,55 @@ Json::Value RPCServer::doUnlAdd(Json::Value& params)
|
|||||||
return "invalid params";
|
return "invalid params";
|
||||||
}
|
}
|
||||||
|
|
||||||
// validation_create
|
// validation_create [<pass_phrase>|<seed>|<seed_key>]
|
||||||
// validation_create <pass_phrase>
|
|
||||||
// validation_create <seed>
|
|
||||||
// validation_create <seed_key>
|
|
||||||
//
|
//
|
||||||
// NOTE: It is poor security to specify secret information on the command line. This information might be saved in the command
|
// 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).
|
// shell history file (e.g. .bash_history) and it may be leaked via the process status command (i.e. ps).
|
||||||
Json::Value RPCServer::doValidatorCreate(Json::Value& params) {
|
Json::Value RPCServer::doValidationCreate(Json::Value& params) {
|
||||||
NewcoinAddress familySeed;
|
NewcoinAddress naSeed;
|
||||||
|
Json::Value obj(Json::objectValue);
|
||||||
|
|
||||||
if (params.empty())
|
if (params.empty())
|
||||||
{
|
{
|
||||||
std::cerr << "Creating random validation seed." << std::endl;
|
std::cerr << "Creating random validation seed." << std::endl;
|
||||||
|
|
||||||
familySeed.setFamilySeedRandom(); // Get a random seed.
|
naSeed.setFamilySeedRandom(); // Get a random seed.
|
||||||
}
|
}
|
||||||
else if (!familySeed.setFamilySeedGeneric(params[0u].asString()))
|
else if (!naSeed.setFamilySeedGeneric(params[0u].asString()))
|
||||||
{
|
{
|
||||||
return RPCError(rpcBAD_SEED);
|
return RPCError(rpcBAD_SEED);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Derive generator from seed.
|
obj["validation_public_key"] = NewcoinAddress::createNodePublic(naSeed).humanNodePublic();
|
||||||
NewcoinAddress familyGenerator = NewcoinAddress::createGeneratorPublic(familySeed);
|
obj["validation_seed"] = naSeed.humanFamilySeed();
|
||||||
NewcoinAddress nodePublicKey = NewcoinAddress::createNodePublic(familySeed);
|
obj["validation_key"] = naSeed.humanFamilySeed1751();
|
||||||
NewcoinAddress nodePrivateKey = NewcoinAddress::createNodePrivate(familySeed);
|
|
||||||
|
|
||||||
// Paranoia
|
return obj;
|
||||||
assert(1 == familySeed.setFamilySeed1751(familySeed.humanFamilySeed1751()));
|
}
|
||||||
|
|
||||||
|
// validation_seed [<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 RPCServer::doValidationSeed(Json::Value& params) {
|
||||||
Json::Value obj(Json::objectValue);
|
Json::Value obj(Json::objectValue);
|
||||||
|
|
||||||
obj["validation_public_key"] = nodePublicKey.humanNodePublic();
|
if (params.empty())
|
||||||
obj["validation_seed"] = familySeed.humanFamilySeed();
|
{
|
||||||
obj["validation_key"] = familySeed.humanFamilySeed1751();
|
std::cerr << "Unset validation seed." << std::endl;
|
||||||
|
|
||||||
|
theConfig.VALIDATION_SEED.clear();
|
||||||
|
}
|
||||||
|
else if (!theConfig.VALIDATION_SEED.setFamilySeedGeneric(params[0u].asString()))
|
||||||
|
{
|
||||||
|
return RPCError(rpcBAD_SEED);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
obj["validation_public_key"] = NewcoinAddress::createNodePublic(theConfig.VALIDATION_SEED).humanNodePublic();
|
||||||
|
obj["validation_seed"] = theConfig.VALIDATION_SEED.humanFamilySeed();
|
||||||
|
obj["validation_key"] = theConfig.VALIDATION_SEED.humanFamilySeed1751();
|
||||||
|
}
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
@@ -2045,7 +2060,8 @@ Json::Value RPCServer::doCommand(const std::string& command, Json::Value& params
|
|||||||
{ "unl_reset", &RPCServer::doUnlReset, 0, 0, },
|
{ "unl_reset", &RPCServer::doUnlReset, 0, 0, },
|
||||||
{ "unl_score", &RPCServer::doUnlScore, 0, 0, },
|
{ "unl_score", &RPCServer::doUnlScore, 0, 0, },
|
||||||
|
|
||||||
{ "validation_create", &RPCServer::doValidatorCreate, 0, 1, },
|
{ "validation_create", &RPCServer::doValidationCreate, 0, 1, },
|
||||||
|
{ "validation_seed", &RPCServer::doValidationSeed, 0, 1, },
|
||||||
|
|
||||||
{ "wallet_accounts", &RPCServer::doWalletAccounts, 1, 1, optCurrent },
|
{ "wallet_accounts", &RPCServer::doWalletAccounts, 1, 1, optCurrent },
|
||||||
{ "wallet_add", &RPCServer::doWalletAdd, 3, 5, optCurrent },
|
{ "wallet_add", &RPCServer::doWalletAdd, 3, 5, optCurrent },
|
||||||
|
|||||||
@@ -138,7 +138,8 @@ private:
|
|||||||
Json::Value doUnlReset(Json::Value& params);
|
Json::Value doUnlReset(Json::Value& params);
|
||||||
Json::Value doUnlScore(Json::Value& params);
|
Json::Value doUnlScore(Json::Value& params);
|
||||||
|
|
||||||
Json::Value doValidatorCreate(Json::Value& params);
|
Json::Value doValidationCreate(Json::Value& params);
|
||||||
|
Json::Value doValidationSeed(Json::Value& params);
|
||||||
|
|
||||||
Json::Value doWalletAccounts(Json::Value& params);
|
Json::Value doWalletAccounts(Json::Value& params);
|
||||||
Json::Value doWalletAdd(Json::Value& params);
|
Json::Value doWalletAdd(Json::Value& params);
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ void printHelp(const po::options_description& desc)
|
|||||||
cout << " unl_list" << endl;
|
cout << " unl_list" << endl;
|
||||||
cout << " unl_reset" << endl;
|
cout << " unl_reset" << endl;
|
||||||
cout << " validation_create [<seed>|<pass_phrase>|<key>]" << endl;
|
cout << " validation_create [<seed>|<pass_phrase>|<key>]" << endl;
|
||||||
|
cout << " validation_seed [<seed>|<pass_phrase>|<key>]" << endl;
|
||||||
cout << " wallet_add <regular_seed> <paying_account> <master_seed> [<initial_funds>] [<account_annotation>]" << endl;
|
cout << " wallet_add <regular_seed> <paying_account> <master_seed> [<initial_funds>] [<account_annotation>]" << endl;
|
||||||
cout << " wallet_accounts <seed>" << endl;
|
cout << " wallet_accounts <seed>" << endl;
|
||||||
cout << " wallet_claim <master_seed> <regular_seed> [<source_tag>] [<account_annotation>]" << endl;
|
cout << " wallet_claim <master_seed> <regular_seed> [<source_tag>] [<account_annotation>]" << endl;
|
||||||
|
|||||||
Reference in New Issue
Block a user