diff --git a/src/cpp/ripple/CallRPC.cpp b/src/cpp/ripple/CallRPC.cpp index e4a71d56f..4afb21a3c 100644 --- a/src/cpp/ripple/CallRPC.cpp +++ b/src/cpp/ripple/CallRPC.cpp @@ -442,16 +442,23 @@ Json::Value RPCParser::parseAccountItems(const Json::Value& jvParams) return jvRequest; } -// ripple_path_find json +// ripple_path_find [] Json::Value RPCParser::parseRipplePathFind(const Json::Value& jvParams) { - Json::Value txJSON; Json::Reader reader; + Json::Value jvRequest; + bool bLedger = 2 == jvParams.size(); - cLog(lsTRACE) << "RPC json:" << jvParams[0u]; - if (reader.parse(jvParams[0u].asString(), txJSON)) + cLog(lsTRACE) << "RPC json: " << jvParams[0u]; + + if (bLedger) { - return txJSON; + jvParseLedger(jvRequest, jvParams[1u].asString()); + } + + if (reader.parse(jvParams[0u].asString(), jvRequest)) + { + return jvRequest; } return rpcError(rpcINVALID_PARAMS); @@ -652,7 +659,7 @@ Json::Value RPCParser::parseCommand(std::string strMethod, Json::Value jvParams) { "ping", &RPCParser::parseAsIs, 0, 0 }, // { "profile", &RPCParser::parseProfile, 1, 9 }, { "random", &RPCParser::parseAsIs, 0, 0 }, - { "ripple_path_find", &RPCParser::parseRipplePathFind, 1, 1 }, + { "ripple_path_find", &RPCParser::parseRipplePathFind, 1, 2 }, { "sign", &RPCParser::parseSignSubmit, 2, 2 }, { "submit", &RPCParser::parseSignSubmit, 1, 2 }, { "server_info", &RPCParser::parseAsIs, 0, 0 }, diff --git a/src/cpp/ripple/RPCHandler.cpp b/src/cpp/ripple/RPCHandler.cpp index 412853584..43916603f 100644 --- a/src/cpp/ripple/RPCHandler.cpp +++ b/src/cpp/ripple/RPCHandler.cpp @@ -885,7 +885,6 @@ Json::Value RPCHandler::doAccountLines(Json::Value jvRequest) if (!lpLedger) return jvResult; - if (!jvRequest.isMember("account")) return rpcError(rpcINVALID_PARAMS); @@ -1153,10 +1152,14 @@ Json::Value RPCHandler::doRandom(Json::Value jvRequest) // - From a trusted server, allows clients to use path without manipulation. Json::Value RPCHandler::doRipplePathFind(Json::Value jvRequest) { - Json::Value jvResult(Json::objectValue); RippleAddress raSrc; RippleAddress raDst; STAmount saDstAmount; + Ledger::pointer lpLedger; + Json::Value jvResult = lookupLedger(jvRequest, lpLedger); + + if (!lpLedger) + return jvResult; if (theApp->getJobQueue().getJobCountGE(jtCLIENT) > 200) { @@ -1201,7 +1204,6 @@ Json::Value RPCHandler::doRipplePathFind(Json::Value jvRequest) } else { - Ledger::pointer lpCurrent = mNetOps->getCurrentLedger(); Json::Value jvSrcCurrencies; if (jvRequest.isMember("source_currencies")) @@ -1210,7 +1212,7 @@ Json::Value RPCHandler::doRipplePathFind(Json::Value jvRequest) } else { - boost::unordered_set usCurrencies = usAccountSourceCurrencies(raSrc, lpCurrent); + boost::unordered_set usCurrencies = usAccountSourceCurrencies(raSrc, lpLedger); // Add XRP as a source currency. // YYY Only bother if they are above reserve. @@ -1228,7 +1230,7 @@ Json::Value RPCHandler::doRipplePathFind(Json::Value jvRequest) } } - Ledger::pointer lSnapShot = boost::make_shared(boost::ref(*lpCurrent), false); + Ledger::pointer lSnapShot = boost::make_shared(boost::ref(*lpLedger), false); LedgerEntrySet lesSnapshot(lSnapShot); ScopedUnlock su(theApp->getMasterLock()); // As long as we have a locked copy of the ledger, we can unlock. diff --git a/src/cpp/ripple/main.cpp b/src/cpp/ripple/main.cpp index a69c9629e..88dc35a33 100644 --- a/src/cpp/ripple/main.cpp +++ b/src/cpp/ripple/main.cpp @@ -92,6 +92,7 @@ void printHelp(const po::options_description& desc) cerr << " peers" << endl; cerr << " random" << endl; cerr << " ripple ..." << endl; + cerr << " ripple_path_find []" << endl; // cerr << " send [] [] []" << endl; cerr << " stop" << endl; cerr << " tx " << endl;