diff --git a/src/cpp/ripple/CallRPC.cpp b/src/cpp/ripple/CallRPC.cpp index e288fadae7..37d480b945 100644 --- a/src/cpp/ripple/CallRPC.cpp +++ b/src/cpp/ripple/CallRPC.cpp @@ -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 }, diff --git a/src/cpp/ripple/CallRPC.h b/src/cpp/ripple/CallRPC.h index f799ce93cb..411a7496d6 100644 --- a/src/cpp/ripple/CallRPC.h +++ b/src/cpp/ripple/CallRPC.h @@ -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: diff --git a/src/cpp/ripple/RPCHandler.cpp b/src/cpp/ripple/RPCHandler.cpp index fac30b7d96..8ca5ac9ac0 100644 --- a/src/cpp/ripple/RPCHandler.cpp +++ b/src/cpp/ripple/RPCHandler.cpp @@ -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: , +// 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 }, diff --git a/src/cpp/ripple/RPCHandler.h b/src/cpp/ripple/RPCHandler.h index 4867955a7f..080defe65f 100644 --- a/src/cpp/ripple/RPCHandler.h +++ b/src/cpp/ripple/RPCHandler.h @@ -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 diff --git a/src/js/remote.js b/src/js/remote.js index be7614bd4a..aff05c2439 100644 --- a/src/js/remote.js +++ b/src/js/remote.js @@ -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)