]]]", program);
}
@@ -248,15 +328,10 @@ else {
// console.log("START");
var self = this;
- self.base = {
- hostname: ip,
- port: port,
- };
-
var remote = (new Remote({
websocket_ip: ws_ip,
websocket_port: ws_port,
-// trace: true
+ trace: false
}))
.on('state', function (m) {
console.log("STATE: %s", m);
@@ -267,6 +342,12 @@ else {
.connect()
;
+ self.base = {
+ hostname: ip,
+ port: port,
+ remote: remote,
+ };
+
// console.log("SERVE");
var server = http.createServer(function (req, res) {
var input = "";
@@ -294,14 +375,16 @@ else {
.on('success', function (m) {
// console.log("account_root: %s", JSON.stringify(m, undefined, 2));
- httpd_response(res,
- {
- statusCode: 200,
- url: _url,
- body: ""
- + JSON.stringify(rewrite_object(m, self.base), undefined, 2)
- + "
"
- });
+ augment_object(m, self.base, function() {
+ httpd_response(res,
+ {
+ statusCode: 200,
+ url: _url,
+ body: ""
+ + JSON.stringify(rewrite_object(m, self.base), undefined, 2)
+ + "
"
+ });
+ });
})
.request();
diff --git a/src/cpp/ripple/CallRPC.cpp b/src/cpp/ripple/CallRPC.cpp
index 1d0f009105..ef23c387a9 100644
--- a/src/cpp/ripple/CallRPC.cpp
+++ b/src/cpp/ripple/CallRPC.cpp
@@ -65,19 +65,11 @@ std::string EncodeBase64(const std::string& s)
// TODO New routine for parsing ledger parameters, other routines should standardize on this.
static bool jvParseLedger(Json::Value& jvRequest, const std::string& strLedger)
{
- if (strLedger == "closed")
+ if (strLedger == "current" || strLedger == "closed" || strLedger == "validated")
{
- jvRequest["ledger_index"] = -1;
+ jvRequest["ledger_index"] = strLedger;
}
- else if (strLedger == "current")
- {
- jvRequest["ledger_index"] = -2;
- }
- else if (strLedger == "validated")
- {
- jvRequest["ledger_index"] = -3;
- }
- else if (strLedger.length() > 12)
+ else if (strLedger.length() == 32)
{
// YYY Could confirm this is a uint256.
jvRequest["ledger_hash"] = strLedger;
@@ -143,7 +135,7 @@ Json::Value RPCParser::parseInternal(const Json::Value& jvParams)
}
// account_info ||
-// account_info || []
+// account_info || [[] ]
Json::Value RPCParser::parseAccountInfo(const Json::Value& jvParams)
{
Json::Value jvRequest(Json::objectValue);
@@ -159,6 +151,9 @@ Json::Value RPCParser::parseAccountInfo(const Json::Value& jvParams)
jvRequest["ident"] = strIdent;
jvRequest["account_index"] = iIndex;
+ if (jvParams.size() == 3 && !jvParseLedger(jvRequest, jvParams[2u].asString()))
+ return rpcError(rpcLGR_IDX_MALFORMED);
+
return jvRequest;
}
@@ -343,20 +338,7 @@ Json::Value RPCParser::parseLedger(const Json::Value& jvParams)
return jvRequest;
}
- std::string strLedger = jvParams[0u].asString();
-
- if (strLedger == "current" || strLedger == "closed" || strLedger == "validated")
- {
- jvRequest["ledger_index"] = strLedger;
- }
- else if (strLedger.length() > 12)
- {
- jvRequest["ledger_hash"] = strLedger;
- }
- else
- {
- jvRequest["ledger_index"] = lexical_cast_s(strLedger);
- }
+ jvParseLedger(jvRequest, jvParams[0u].asString());
if (2 == jvParams.size() && jvParams[1u].asString() == "full")
{
@@ -373,7 +355,7 @@ Json::Value RPCParser::parseLedgerId(const Json::Value& jvParams)
std::string strLedger = jvParams[0u].asString();
- if (strLedger.length() > 32)
+ if (strLedger.length() == 32)
{
jvRequest["ledger_hash"] = strLedger;
}
@@ -641,7 +623,7 @@ Json::Value RPCParser::parseCommand(std::string strMethod, Json::Value jvParams)
// Request-response methods
// - Returns an error, or the request.
// - To modify the method, provide a new method in the request.
- { "account_info", &RPCParser::parseAccountInfo, 1, 2 },
+ { "account_info", &RPCParser::parseAccountInfo, 1, 3 },
{ "account_lines", &RPCParser::parseAccountItems, 1, 2 },
{ "account_offers", &RPCParser::parseAccountItems, 1, 2 },
{ "account_tx", &RPCParser::parseAccountTransactions, 2, 4 },