mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-26 14:05:51 +00:00
Add framework for RPC ripple_path_find.
This commit is contained in:
@@ -526,13 +526,6 @@ Json::Value RPCHandler::doOwnerInfo(const Json::Value& params)
|
||||
}
|
||||
|
||||
|
||||
Json::Value RPCHandler::doPathFind(const Json::Value& params)
|
||||
{
|
||||
Json::Value ret(Json::objectValue);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
Json::Value RPCHandler::doPeers(const Json::Value& params)
|
||||
{
|
||||
Json::Value obj(Json::objectValue);
|
||||
@@ -702,6 +695,65 @@ Json::Value RPCHandler::doRippleLinesGet(const Json::Value ¶ms)
|
||||
return ret;
|
||||
}
|
||||
|
||||
Json::Value RPCHandler::doRipplePathFind(const Json::Value& jvRequest)
|
||||
{
|
||||
Json::Value jvResult(Json::objectValue);
|
||||
RippleAddress raSrc;
|
||||
RippleAddress raDst;
|
||||
STAmount saDst;
|
||||
|
||||
if (
|
||||
// Parse raSrc.
|
||||
!jvRequest.isMember("source_account")
|
||||
|| !jvRequest["source_account"].isString()
|
||||
|| !raSrc.setAccountID(jvRequest["source_account"].asString())
|
||||
|
||||
// Parse raDst.
|
||||
|| !jvRequest.isMember("destination_account")
|
||||
|| !jvRequest["destination_account"].isString()
|
||||
|| !raDst.setAccountID(jvRequest["destination_account"].asString())
|
||||
|
||||
|
||||
// Parse saDst.
|
||||
|| !jvRequest.isMember("destination_amount")
|
||||
|| !saDst.bSetJson("destination_amount")
|
||||
|
||||
// Checks on source_currencies.
|
||||
|| !jvRequest.isMember("source_currencies")
|
||||
|| !jvRequest["source_currencies"].isArray()
|
||||
|| jvRequest["source_currencies"].size()
|
||||
)
|
||||
{
|
||||
jvResult = rpcError(rpcINVALID_PARAMS);
|
||||
}
|
||||
else
|
||||
{
|
||||
Json::Value jvSrcCurrencies = jvRequest.isMember("source_currencies");
|
||||
Json::Value jvArray(Json::arrayValue);
|
||||
|
||||
for (unsigned int i=0; i != jvSrcCurrencies.size(); ++i) {
|
||||
Json::Value jvSource = jvSrcCurrencies[i];
|
||||
uint160 srcCurrencyID;
|
||||
uint160 srcIssuerID;
|
||||
|
||||
if (!jvSource.isMember("currency")
|
||||
|| !STAmount::currencyFromString(srcCurrencyID, jvSource["currency"].asString())
|
||||
|| ((jvSource.isMember("issuer"))
|
||||
&& (!jvSource["issuer"].isString()
|
||||
|| !STAmount::issuerFromString(srcIssuerID, jvSource["issuer"].asString()))))
|
||||
{
|
||||
return rpcError(rpcINVALID_PARAMS);
|
||||
}
|
||||
|
||||
// XXX Add some results.
|
||||
}
|
||||
|
||||
jvResult["results"] = jvArray;
|
||||
}
|
||||
|
||||
return jvResult;
|
||||
}
|
||||
|
||||
// submit any transaction to the network
|
||||
// submit private_key json
|
||||
Json::Value RPCHandler::doSubmit(const Json::Value& params)
|
||||
@@ -792,17 +844,7 @@ Json::Value RPCHandler::handleJSONSubmit(const Json::Value& jvRequest)
|
||||
|
||||
STAmount dstAmount;
|
||||
|
||||
if (txJSON["Amount"].isObject())
|
||||
{
|
||||
std::string issuerStr;
|
||||
if( txJSON["Amount"].isMember("issuer")) issuerStr=txJSON["Amount"]["issuer"].asString();
|
||||
if( !txJSON["Amount"].isMember("value") || !txJSON["Amount"].isMember("currency")) return rpcError(rpcDST_AMT_MALFORMED);
|
||||
if (!dstAmount.setFullValue(txJSON["Amount"]["value"].asString(), txJSON["Amount"]["currency"].asString(), issuerStr))
|
||||
{
|
||||
return rpcError(rpcDST_AMT_MALFORMED);
|
||||
}
|
||||
}
|
||||
else if (!dstAmount.setFullValue(txJSON["Amount"].asString()))
|
||||
if (!dstAmount.bSetJson(txJSON["Amount"]))
|
||||
{
|
||||
return rpcError(rpcDST_AMT_MALFORMED);
|
||||
}
|
||||
@@ -1365,10 +1407,10 @@ Json::Value RPCHandler::doCommand(const std::string& command, Json::Value& param
|
||||
{ "logrotate", &RPCHandler::doLogRotate, 0, 0, true, false, optNone },
|
||||
{ "nickname_info", &RPCHandler::doNicknameInfo, 1, 1, false, false, optCurrent },
|
||||
{ "owner_info", &RPCHandler::doOwnerInfo, 1, 2, false, false, optCurrent },
|
||||
{ "path_find", &RPCHandler::doPathFind, -1, -1, false, false, optCurrent },
|
||||
{ "peers", &RPCHandler::doPeers, 0, 0, true, false, optNone },
|
||||
{ "profile", &RPCHandler::doProfile, 1, 9, false, false, optCurrent },
|
||||
{ "ripple_lines_get", &RPCHandler::doRippleLinesGet, 1, 2, false, false, optCurrent },
|
||||
{ "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 },
|
||||
{ "server_info", &RPCHandler::doServerInfo, 0, 0, true, false, optNone },
|
||||
|
||||
@@ -10,7 +10,7 @@ class RPCHandler
|
||||
InfoSub* mInfoSub;
|
||||
int mRole;
|
||||
|
||||
typedef Json::Value (RPCHandler::*doFuncPtr)(const Json::Value ¶ms);
|
||||
typedef Json::Value (RPCHandler::*doFuncPtr)(const Json::Value& params);
|
||||
enum {
|
||||
optNone = 0,
|
||||
optNetwork = 1, // Need network
|
||||
@@ -35,7 +35,7 @@ class RPCHandler
|
||||
|
||||
Json::Value accountFromString(const uint256& uLedger, RippleAddress& naAccount, bool& bIndex, const std::string& strIdent, const int iIndex);
|
||||
|
||||
Json::Value doAcceptLedger(const Json::Value ¶ms);
|
||||
Json::Value doAcceptLedger(const Json::Value& params);
|
||||
|
||||
Json::Value doAccountInfo(const Json::Value& params);
|
||||
Json::Value doAccountTransactions(const Json::Value& params);
|
||||
@@ -51,10 +51,10 @@ class RPCHandler
|
||||
Json::Value doOwnerInfo(const Json::Value& params);
|
||||
|
||||
Json::Value doProfile(const Json::Value& params);
|
||||
Json::Value doPathFind(const Json::Value& params);
|
||||
Json::Value doPeers(const Json::Value& params);
|
||||
|
||||
Json::Value doRippleLinesGet(const Json::Value ¶ms);
|
||||
Json::Value doRippleLinesGet(const Json::Value& params);
|
||||
Json::Value doRipplePathFind(const Json::Value& jvRequest);
|
||||
Json::Value doServerInfo(const Json::Value& params);
|
||||
Json::Value doSessionClose(const Json::Value& params);
|
||||
Json::Value doSessionOpen(const Json::Value& params);
|
||||
|
||||
Reference in New Issue
Block a user