diff --git a/src/cpp/ripple/RPCErr.cpp b/src/cpp/ripple/RPCErr.cpp index 9c4112db12..4e1eecc127 100644 --- a/src/cpp/ripple/RPCErr.cpp +++ b/src/cpp/ripple/RPCErr.cpp @@ -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." }, diff --git a/src/cpp/ripple/RPCErr.h b/src/cpp/ripple/RPCErr.h index f2b73336e9..d77cc24355 100644 --- a/src/cpp/ripple/RPCErr.h +++ b/src/cpp/ripple/RPCErr.h @@ -67,6 +67,7 @@ enum { rpcINTERNAL, // Generic internal error. rpcFAIL_GEN_DECRPYT, rpcNOT_IMPL, + rpcNOT_SUPPORTED, rpcNO_GEN_DECRPYT, }; diff --git a/src/cpp/ripple/RPCHandler.cpp b/src/cpp/ripple/RPCHandler.cpp index 980b78e988..23579ea010 100644 --- a/src/cpp/ripple/RPCHandler.cpp +++ b/src/cpp/ripple/RPCHandler.cpp @@ -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; - Json::Value jvResult; + jvResult["random"] = uRandom.ToString(); - jvResult["random"] = uRandom.ToString(); + return jvResult; + } + break; - return jvResult; + case -1: + return rpcError(rpcNOT_SUPPORTED); + + default: + return rpcError(rpcINTERNAL); + } } // TODO: