From 2701f25052331a987f804e0710173dda48d9cdcc Mon Sep 17 00:00:00 2001 From: Arthur Britto Date: Fri, 7 Dec 2012 15:22:24 -0800 Subject: [PATCH] Be more strict with payment build_path flag. --- src/cpp/ripple/RPCHandler.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/cpp/ripple/RPCHandler.cpp b/src/cpp/ripple/RPCHandler.cpp index c633ede40..51c038a03 100644 --- a/src/cpp/ripple/RPCHandler.cpp +++ b/src/cpp/ripple/RPCHandler.cpp @@ -913,7 +913,13 @@ Json::Value RPCHandler::doSubmit(Json::Value jvRequest) txJSON["Fee"] = (int) theConfig.FEE_ACCOUNT_CREATE; } - if (!txJSON.isMember("Paths") && txJSON.isMember("Amount") && jvRequest.isMember("build_path")) + if (txJSON.isMember("Paths") && jvRequest.isMember("build_path")) + { + // Asking to build a path when providing one is an error. + return rpcError(rpcINVALID_PARAMS); + } + + if (!txJSON.isMember("Paths") && txJSON.isMember("Amount") && jvRequest.isMember("build_path")) { // Need a ripple path. STPathSet spsPaths; @@ -939,6 +945,12 @@ Json::Value RPCHandler::doSubmit(Json::Value jvRequest) saSendMax.setIssuer(raSrcAddressID.getAccountID()); } + if (saSendMax.isNative() && saSend.isNative()) + { + // Asking to build a path for XRP to XRP is an error. + return rpcError(rpcINVALID_PARAMS); + } + Pathfinder pf(raSrcAddressID, dstAccountID, saSendMax.getCurrency(), saSendMax.getIssuer(), saSend); if (!pf.findPaths(5, 1, spsPaths))