From 68510178c23e16c77e2a582d47ffb136d3b263e5 Mon Sep 17 00:00:00 2001 From: Arthur Britto Date: Thu, 23 May 2013 16:01:15 -0700 Subject: [PATCH] Add support for strict to CLI for account_info. --- src/cpp/ripple/CallRPC.cpp | 18 ++++++++++++++++-- src/cpp/ripple/main.cpp | 2 +- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/cpp/ripple/CallRPC.cpp b/src/cpp/ripple/CallRPC.cpp index 78fc2579ca..a347f7a636 100644 --- a/src/cpp/ripple/CallRPC.cpp +++ b/src/cpp/ripple/CallRPC.cpp @@ -437,7 +437,18 @@ Json::Value RPCParser::parseAccountLines(const Json::Value& jvParams) Json::Value RPCParser::parseAccountRaw(const Json::Value& jvParams, bool bPeer) { std::string strIdent = jvParams[0u].asString(); - std::string strPeer = bPeer && jvParams.size() >= 2 ? jvParams[1u].asString() : ""; + unsigned int iCursor = jvParams.size(); + bool bStrict = false; + std::string strPeer; + + if (!bPeer && iCursor >= 2 && jvParams[iCursor-1] == "strict") + { + bStrict = true; + --iCursor; + } + + if (bPeer && iCursor >= 2) + strPeer = jvParams[iCursor].asString(); int iIndex = 0; // int iIndex = jvParams.size() >= 2 ? lexical_cast_s(jvParams[1u].asString()) : 0; @@ -452,6 +463,9 @@ Json::Value RPCParser::parseAccountRaw(const Json::Value& jvParams, bool bPeer) jvRequest["account"] = strIdent; + if (bStrict) + jvRequest["strict"] = 1; + if (iIndex) jvRequest["account_index"] = iIndex; @@ -465,7 +479,7 @@ Json::Value RPCParser::parseAccountRaw(const Json::Value& jvParams, bool bPeer) jvRequest["peer"] = strPeer; } - if (jvParams.size() == (2+bPeer) && !jvParseLedger(jvRequest, jvParams[1u+bPeer].asString())) + if (iCursor == (2+bPeer) && !jvParseLedger(jvRequest, jvParams[1u+bPeer].asString())) return rpcError(rpcLGR_IDX_MALFORMED); return jvRequest; diff --git a/src/cpp/ripple/main.cpp b/src/cpp/ripple/main.cpp index 15a23767d2..7cfb5cb0b3 100644 --- a/src/cpp/ripple/main.cpp +++ b/src/cpp/ripple/main.cpp @@ -70,7 +70,7 @@ void printHelp(const po::options_description& desc) cerr << desc << endl; cerr << "Commands: " << endl; - cerr << " account_info |||| []" << endl; + cerr << " account_info |||| [] [strict]" << endl; cerr << " account_lines |\"\" []" << endl; cerr << " account_offers || []" << endl; cerr << " account_tx accountID [ledger_min [ledger_max [limit [offset]]]] [binary] [count] [descending]" << endl;