mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-24 13:05:53 +00:00
Improve RPC random.
This commit is contained in:
@@ -47,6 +47,7 @@ Json::Value rpcError(int iError, Json::Value jvResult)
|
||||
{ rpcNO_PATH, "noPath", "Unable to find a ripple path." },
|
||||
{ rpcNO_PERMISSION, "noPermission", "You don't have permission for this command." },
|
||||
{ rpcNOT_STANDALONE, "notStandAlone", "Operation valid in debug mode only." },
|
||||
{ rpcNOT_SUPPORTED, "notSupported", "Operation not supported." },
|
||||
{ rpcPASSWD_CHANGED, "passwdChanged", "Wrong key, password changed." },
|
||||
{ rpcPAYS_ACT_MALFORMED, "paysActMalformed", "Pays account malformed." },
|
||||
{ rpcPAYS_AMT_MALFORMED, "paysAmtMalformed", "Pays amount malformed." },
|
||||
|
||||
@@ -67,6 +67,7 @@ enum {
|
||||
rpcINTERNAL, // Generic internal error.
|
||||
rpcFAIL_GEN_DECRPYT,
|
||||
rpcNOT_IMPL,
|
||||
rpcNOT_SUPPORTED,
|
||||
rpcNO_GEN_DECRPYT,
|
||||
};
|
||||
|
||||
|
||||
@@ -697,13 +697,25 @@ Json::Value RPCHandler::doRandom(Json::Value jvRequest)
|
||||
{
|
||||
uint160 uRandom;
|
||||
|
||||
RAND_bytes(uRandom.begin(), uRandom.size());
|
||||
|
||||
switch (RAND_pseudo_bytes(uRandom.begin(), uRandom.size()))
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
{
|
||||
Json::Value jvResult;
|
||||
|
||||
jvResult["random"] = uRandom.ToString();
|
||||
|
||||
return jvResult;
|
||||
}
|
||||
break;
|
||||
|
||||
case -1:
|
||||
return rpcError(rpcNOT_SUPPORTED);
|
||||
|
||||
default:
|
||||
return rpcError(rpcINTERNAL);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO:
|
||||
|
||||
Reference in New Issue
Block a user