mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-01 08:25:51 +00:00
Refactor RPC tx.
This commit is contained in:
@@ -257,6 +257,15 @@ Json::Value RPCParser::parseSubmit(const Json::Value& jvParams)
|
|||||||
return rpcError(rpcINVALID_PARAMS);
|
return rpcError(rpcINVALID_PARAMS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// tx <transaction_id>
|
||||||
|
Json::Value RPCParser::parseTx(const Json::Value& jvParams)
|
||||||
|
{
|
||||||
|
Json::Value jvRequest;
|
||||||
|
|
||||||
|
jvRequest["transaction"] = jvParams[0u].asString();
|
||||||
|
return jvRequest;
|
||||||
|
}
|
||||||
|
|
||||||
// unl_add <domain>|<node_public> [<comment>]
|
// unl_add <domain>|<node_public> [<comment>]
|
||||||
Json::Value RPCParser::parseUnlAdd(const Json::Value& jvParams)
|
Json::Value RPCParser::parseUnlAdd(const Json::Value& jvParams)
|
||||||
{
|
{
|
||||||
@@ -387,15 +396,15 @@ Json::Value RPCParser::parseCommand(std::string strMethod, Json::Value jvParams)
|
|||||||
// { "nickname_info", &RPCParser::parseNicknameInfo, 1, 1 },
|
// { "nickname_info", &RPCParser::parseNicknameInfo, 1, 1 },
|
||||||
{ "owner_info", &RPCParser::parseOwnerInfo, 1, 2 },
|
{ "owner_info", &RPCParser::parseOwnerInfo, 1, 2 },
|
||||||
{ "peers", &RPCParser::parseAsIs, 0, 0 },
|
{ "peers", &RPCParser::parseAsIs, 0, 0 },
|
||||||
// { "profile", &RPCParser::parseProfile, 1, 9, false, false, optCurrent },
|
// { "profile", &RPCParser::parseProfile, 1, 9 },
|
||||||
{ "ripple_lines_get", &RPCParser::parseRippleLinesGet, 1, 2 },
|
{ "ripple_lines_get", &RPCParser::parseRippleLinesGet, 1, 2 },
|
||||||
// { "ripple_path_find", &RPCParser::parseRipplePathFind, -1, -1 },
|
// { "ripple_path_find", &RPCParser::parseRipplePathFind, -1, -1 },
|
||||||
{ "submit", &RPCParser::parseSubmit, 2, 2 },
|
{ "submit", &RPCParser::parseSubmit, 2, 2 },
|
||||||
{ "server_info", &RPCParser::parseAsIs, 0, 0 },
|
{ "server_info", &RPCParser::parseAsIs, 0, 0 },
|
||||||
{ "stop", &RPCParser::parseAsIs, 0, 0 },
|
{ "stop", &RPCParser::parseAsIs, 0, 0 },
|
||||||
// { "transaction_entry", &RPCParser::parseTransactionEntry, -1, -1 },
|
// { "transaction_entry", &RPCParser::parseTransactionEntry, -1, -1 },
|
||||||
// { "tx", &RPCParser::parseTx, 1, 1, true, false, optNone },
|
{ "tx", &RPCParser::parseTx, 1, 1 },
|
||||||
// { "tx_history", &RPCParser::parseTxHistory, 1, 1, false, false, optNone },
|
// { "tx_history", &RPCParser::parseTxHistory, 1, 1 },
|
||||||
//
|
//
|
||||||
{ "unl_add", &RPCParser::parseUnlAdd, 1, 2 },
|
{ "unl_add", &RPCParser::parseUnlAdd, 1, 2 },
|
||||||
{ "unl_delete", &RPCParser::parseUnlDelete, 1, 1 },
|
{ "unl_delete", &RPCParser::parseUnlDelete, 1, 1 },
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ protected:
|
|||||||
Json::Value parseOwnerInfo(const Json::Value& jvParams);
|
Json::Value parseOwnerInfo(const Json::Value& jvParams);
|
||||||
Json::Value parseRippleLinesGet(const Json::Value& jvParams);
|
Json::Value parseRippleLinesGet(const Json::Value& jvParams);
|
||||||
Json::Value parseSubmit(const Json::Value& jvParams);
|
Json::Value parseSubmit(const Json::Value& jvParams);
|
||||||
|
Json::Value parseTx(const Json::Value& jvParams);
|
||||||
Json::Value parseUnlAdd(const Json::Value& jvParams);
|
Json::Value parseUnlAdd(const Json::Value& jvParams);
|
||||||
Json::Value parseUnlDelete(const Json::Value& jvParams);
|
Json::Value parseUnlDelete(const Json::Value& jvParams);
|
||||||
Json::Value parseValidationCreate(const Json::Value& jvParams);
|
Json::Value parseValidationCreate(const Json::Value& jvParams);
|
||||||
|
|||||||
@@ -514,7 +514,7 @@ Json::Value RPCHandler::doProfile(Json::Value params)
|
|||||||
|
|
||||||
boost::posix_time::ptime ptStart(boost::posix_time::microsec_clock::local_time());
|
boost::posix_time::ptime ptStart(boost::posix_time::microsec_clock::local_time());
|
||||||
|
|
||||||
for(unsigned int n=0; n<iCount; n++)
|
for(unsigned int n=0; n<iCount; n++)
|
||||||
{
|
{
|
||||||
RippleAddress naMasterGeneratorA;
|
RippleAddress naMasterGeneratorA;
|
||||||
RippleAddress naAccountPublicA;
|
RippleAddress naAccountPublicA;
|
||||||
@@ -1102,21 +1102,17 @@ Json::Value RPCHandler::doTxHistory(Json::Value params)
|
|||||||
return rpcError(rpcSRC_ACT_MALFORMED);
|
return rpcError(rpcSRC_ACT_MALFORMED);
|
||||||
}
|
}
|
||||||
|
|
||||||
Json::Value RPCHandler::doTx(Json::Value params)
|
// {
|
||||||
|
// transaction: <hex>
|
||||||
|
// }
|
||||||
|
Json::Value RPCHandler::doTx(Json::Value jvRequest)
|
||||||
{
|
{
|
||||||
// tx <txID>
|
std::string strTransaction = jvRequest["transaction"].asString();
|
||||||
// tx <account>
|
|
||||||
|
|
||||||
std::string param1, param2;
|
if (Transaction::isHexTxID(strTransaction))
|
||||||
if (!extractString(param1, params, 0))
|
|
||||||
{
|
|
||||||
return rpcError(rpcINVALID_PARAMS);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Transaction::isHexTxID(param1))
|
|
||||||
{ // transaction by ID
|
{ // transaction by ID
|
||||||
Json::Value ret;
|
Json::Value ret;
|
||||||
uint256 txid(param1);
|
uint256 txid(strTransaction);
|
||||||
|
|
||||||
Transaction::pointer txn = theApp->getMasterTransaction().fetch(txid, true);
|
Transaction::pointer txn = theApp->getMasterTransaction().fetch(txid, true);
|
||||||
|
|
||||||
@@ -2211,8 +2207,8 @@ Json::Value RPCHandler::doCommand(Json::Value& jvParams, int iRole)
|
|||||||
// Request-response methods
|
// Request-response methods
|
||||||
{ "accept_ledger", &RPCHandler::doAcceptLedger, -1, -1, true, false, optCurrent },
|
{ "accept_ledger", &RPCHandler::doAcceptLedger, -1, -1, true, false, optCurrent },
|
||||||
{ "account_info", &RPCHandler::doAccountInfo, -1, -1, false, false, optCurrent },
|
{ "account_info", &RPCHandler::doAccountInfo, -1, -1, false, false, optCurrent },
|
||||||
{ "account_tx", &RPCHandler::doAccountTransactions, -1, -1, false, false, optNetwork },
|
{ "account_tx", &RPCHandler::doAccountTransactions,-1, -1, false, false, optNetwork },
|
||||||
{ "connect", &RPCHandler::doConnect, 1, 2, true, false, optNone },
|
{ "connect", &RPCHandler::doConnect, -1, -1, true, false, optNone },
|
||||||
{ "get_counts", &RPCHandler::doGetCounts, -1, -1, true, false, optNone },
|
{ "get_counts", &RPCHandler::doGetCounts, -1, -1, true, false, optNone },
|
||||||
{ "ledger", &RPCHandler::doLedger, -1, -1, false, false, optNetwork },
|
{ "ledger", &RPCHandler::doLedger, -1, -1, false, false, optNetwork },
|
||||||
{ "ledger_accept", &RPCHandler::doLedgerAccept, -1, -1, true, false, optCurrent },
|
{ "ledger_accept", &RPCHandler::doLedgerAccept, -1, -1, true, false, optCurrent },
|
||||||
@@ -2225,14 +2221,14 @@ Json::Value RPCHandler::doCommand(Json::Value& jvParams, int iRole)
|
|||||||
// { "nickname_info", &RPCHandler::doNicknameInfo, 1, 1, false, false, optCurrent },
|
// { "nickname_info", &RPCHandler::doNicknameInfo, 1, 1, false, false, optCurrent },
|
||||||
{ "owner_info", &RPCHandler::doOwnerInfo, -1, -1, false, false, optCurrent },
|
{ "owner_info", &RPCHandler::doOwnerInfo, -1, -1, false, false, optCurrent },
|
||||||
{ "peers", &RPCHandler::doPeers, -1, -1, true, false, optNone },
|
{ "peers", &RPCHandler::doPeers, -1, -1, true, false, optNone },
|
||||||
{ "profile", &RPCHandler::doProfile, 1, 9, false, false, optCurrent },
|
// { "profile", &RPCHandler::doProfile, -1, -1, false, false, optCurrent },
|
||||||
{ "ripple_lines_get", &RPCHandler::doRippleLinesGet, -1, -1, false, false, optCurrent },
|
{ "ripple_lines_get", &RPCHandler::doRippleLinesGet, -1, -1, false, false, optCurrent },
|
||||||
{ "ripple_path_find", &RPCHandler::doRipplePathFind, -1, -1, false, false, optCurrent },
|
{ "ripple_path_find", &RPCHandler::doRipplePathFind, -1, -1, false, false, optCurrent },
|
||||||
{ "submit", &RPCHandler::doSubmit, -1, -1, false, false, optCurrent },
|
{ "submit", &RPCHandler::doSubmit, -1, -1, false, false, optCurrent },
|
||||||
{ "server_info", &RPCHandler::doServerInfo, -1, -1, true, false, optNone },
|
{ "server_info", &RPCHandler::doServerInfo, -1, -1, true, false, optNone },
|
||||||
{ "stop", &RPCHandler::doStop, -1, -1, true, false, optNone },
|
{ "stop", &RPCHandler::doStop, -1, -1, true, false, optNone },
|
||||||
{ "transaction_entry", &RPCHandler::doTransactionEntry, -1, -1, false, false, optCurrent },
|
{ "transaction_entry", &RPCHandler::doTransactionEntry, -1, -1, false, false, optCurrent },
|
||||||
{ "tx", &RPCHandler::doTx, 1, 1, true, false, optNone },
|
{ "tx", &RPCHandler::doTx, -1, -1, true, false, optNone },
|
||||||
{ "tx_history", &RPCHandler::doTxHistory, 1, 1, false, false, optNone },
|
{ "tx_history", &RPCHandler::doTxHistory, 1, 1, false, false, optNone },
|
||||||
|
|
||||||
{ "unl_add", &RPCHandler::doUnlAdd, -1, -1, true, false, optNone },
|
{ "unl_add", &RPCHandler::doUnlAdd, -1, -1, true, false, optNone },
|
||||||
|
|||||||
Reference in New Issue
Block a user