mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-28 06:55:50 +00:00
Refactor RPC submit and submit_json.
This commit is contained in:
@@ -113,6 +113,26 @@ Json::Value RPCParser::parseAccountTransactions(const Json::Value& jvParams)
|
||||
return jvRequest;
|
||||
}
|
||||
|
||||
// submit any transaction to the network
|
||||
// submit private_key json
|
||||
Json::Value RPCParser::parseSubmit(const Json::Value& jvParams)
|
||||
{
|
||||
Json::Value txJSON;
|
||||
Json::Reader reader;
|
||||
|
||||
if (reader.parse(jvParams[1u].asString(), txJSON))
|
||||
{
|
||||
Json::Value jvRequest;
|
||||
|
||||
jvRequest["secret"] = params[0u].asString();
|
||||
jvRequest["tx_json"] = txJSON;
|
||||
|
||||
return jvRequest;
|
||||
}
|
||||
|
||||
return rpcError(rpcINVALID_PARAMS);
|
||||
}
|
||||
|
||||
Json::Value RPCParser::parseEvented(const Json::Value& jvParams)
|
||||
{
|
||||
return rpcError(rpcNO_EVENTS);
|
||||
@@ -156,8 +176,7 @@ Json::Value RPCParser::parseCommand(std::string strMethod, Json::Value jvParams)
|
||||
// { "profile", &RPCParser::doProfile, 1, 9, false, false, optCurrent },
|
||||
// { "ripple_lines_get", &RPCParser::doRippleLinesGet, 1, 2, false, false, optCurrent },
|
||||
// { "ripple_path_find", &RPCParser::doRipplePathFind, -1, -1, false, false, optCurrent },
|
||||
// { "submit", &RPCParser::doSubmit, 2, 2, false, false, optCurrent },
|
||||
// { "submit_json", &RPCParser::doSubmitJson, -1, -1, false, false, optCurrent },
|
||||
{ "submit", &RPCParser::parseSubmit, 2, 2 },
|
||||
{ "server_info", &RPCParser::parseAsIs, 0, 0 },
|
||||
{ "stop", &RPCParser::parseAsIs, 0, 0 },
|
||||
// { "transaction_entry", &RPCParser::doTransactionEntry, -1, -1, false, false, optCurrent },
|
||||
|
||||
@@ -15,6 +15,7 @@ protected:
|
||||
Json::Value parseAccountInfo(const Json::Value& jvParams);
|
||||
Json::Value parseAccountTransactions(const Json::Value& jvParams);
|
||||
|
||||
Json::Value parseSubmit(const Json::Value& jvParams);
|
||||
Json::Value parseEvented(const Json::Value& jvParams);
|
||||
|
||||
public:
|
||||
|
||||
@@ -801,39 +801,21 @@ Json::Value RPCHandler::doRipplePathFind(Json::Value jvRequest)
|
||||
return jvResult;
|
||||
}
|
||||
|
||||
// submit any transaction to the network
|
||||
// submit private_key json
|
||||
Json::Value RPCHandler::doSubmit(Json::Value params)
|
||||
{
|
||||
Json::Value txJSON;
|
||||
Json::Reader reader;
|
||||
|
||||
//std::string hello=params[1u].asString();
|
||||
|
||||
if (reader.parse(params[1u].asString(), txJSON))
|
||||
{
|
||||
Json::Value jvRequest;
|
||||
|
||||
jvRequest["secret"] = params[0u].asString();
|
||||
jvRequest["tx_json"] = txJSON;
|
||||
|
||||
return handleJSONSubmit(jvRequest);
|
||||
}
|
||||
|
||||
return rpcError(rpcINVALID_PARAMS);
|
||||
}
|
||||
|
||||
Json::Value RPCHandler::doSubmitJson(Json::Value jvRequest)
|
||||
{
|
||||
return handleJSONSubmit(jvRequest);
|
||||
}
|
||||
|
||||
|
||||
Json::Value RPCHandler::handleJSONSubmit(Json::Value jvRequest)
|
||||
// {
|
||||
// tx_json: <object>,
|
||||
// secret: <secret>
|
||||
// }
|
||||
Json::Value RPCHandler::doSubmit(Json::Value jvRequest)
|
||||
{
|
||||
Json::Value jvResult;
|
||||
RippleAddress naSeed;
|
||||
RippleAddress raSrcAddressID;
|
||||
|
||||
if (!jvRequest.isMember("secret") || !jvRequest.isMember("tx_json"))
|
||||
{
|
||||
return rpcError(rpcINVALID_PARAMS);
|
||||
}
|
||||
|
||||
Json::Value txJSON = jvRequest["tx_json"];
|
||||
|
||||
if (!naSeed.setSeedGeneric(jvRequest["secret"].asString()))
|
||||
@@ -2215,8 +2197,7 @@ Json::Value RPCHandler::doCommand(Json::Value& jvParams, int iRole)
|
||||
{ "profile", &RPCHandler::doProfile, 1, 9, false, false, optCurrent },
|
||||
{ "ripple_lines_get", &RPCHandler::doRippleLinesGet, 1, 2, false, false, optCurrent },
|
||||
{ "ripple_path_find", &RPCHandler::doRipplePathFind, -1, -1, false, false, optCurrent },
|
||||
{ "submit", &RPCHandler::doSubmit, 2, 2, false, false, optCurrent },
|
||||
{ "submit_json", &RPCHandler::doSubmitJson, -1, -1, false, false, optCurrent },
|
||||
{ "submit", &RPCHandler::doSubmit, -1, -1, false, false, optCurrent },
|
||||
{ "server_info", &RPCHandler::doServerInfo, 0, 0, true, false, optNone },
|
||||
{ "stop", &RPCHandler::doStop, 0, 0, true, false, optNone },
|
||||
{ "transaction_entry", &RPCHandler::doTransactionEntry, -1, -1, false, false, optCurrent },
|
||||
|
||||
@@ -61,7 +61,6 @@ class RPCHandler
|
||||
Json::Value doLogLevel(Json::Value params);
|
||||
Json::Value doStop(Json::Value params);
|
||||
Json::Value doSubmit(Json::Value params);
|
||||
Json::Value doSubmitJson(Json::Value jvRequest);
|
||||
Json::Value doTx(Json::Value params);
|
||||
Json::Value doTxHistory(Json::Value params);
|
||||
|
||||
@@ -108,8 +107,6 @@ public:
|
||||
|
||||
Json::Value doCommand(Json::Value& jvRequest, int role);
|
||||
Json::Value doRpcCommand(const std::string& strCommand, Json::Value& jvParams, int iRole);
|
||||
|
||||
Json::Value handleJSONSubmit(Json::Value jvRequest);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -773,7 +773,7 @@ Remote.prototype.submit = function (transaction) {
|
||||
else {
|
||||
// Convert the transaction into a request and submit it.
|
||||
|
||||
(new Request(this, 'submit_json'))
|
||||
(new Request(this, 'submit'))
|
||||
.build_path(transaction._build_path)
|
||||
.tx_json(transaction.tx_json)
|
||||
.secret(transaction._secret)
|
||||
|
||||
Reference in New Issue
Block a user