diff --git a/package.json b/package.json index bf860e737..1cbd65733 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ripple-lib", - "version": "0.7.1", + "version": "0.7.2", "description": "Ripple JavaScript client library", "files": [ diff --git a/src/cpp/ripple/PeerDoor.h b/src/cpp/ripple/PeerDoor.h index 5f03c5914..a6146e411 100644 --- a/src/cpp/ripple/PeerDoor.h +++ b/src/cpp/ripple/PeerDoor.h @@ -1,9 +1,6 @@ #ifndef __PEERDOOR__ #define __PEERDOOR__ -#include -#include - #include #include diff --git a/src/cpp/ripple/RPCHandler.cpp b/src/cpp/ripple/RPCHandler.cpp index 28b54a322..412853584 100644 --- a/src/cpp/ripple/RPCHandler.cpp +++ b/src/cpp/ripple/RPCHandler.cpp @@ -559,7 +559,7 @@ Json::Value RPCHandler::accountFromString(Ledger::ref lrLedger, RippleAddress& n } // { -// ident : , +// account: , // account_index : // optional // strict: // true, only allow public keys and addresses. false, default. // ledger_hash : @@ -573,10 +573,10 @@ Json::Value RPCHandler::doAccountInfo(Json::Value jvRequest) if (!lpLedger) return jvResult; - if (!jvRequest.isMember("ident")) + if (!jvRequest.isMember("account") && !jvRequest.isMember("ident")) return rpcError(rpcINVALID_PARAMS); - std::string strIdent = jvRequest["ident"].asString(); + std::string strIdent = jvRequest.isMember("account") ? jvRequest["account"].asString() : jvRequest["ident"].asString(); bool bIndex; int iIndex = jvRequest.isMember("account_index") ? jvRequest["account_index"].asUInt() : 0; bool bStrict = jvRequest.isMember("strict") && jvRequest["strict"].asBool(); @@ -742,10 +742,10 @@ Json::Value RPCHandler::doNicknameInfo(Json::Value params) // XXX This would be better if it took the ledger. Json::Value RPCHandler::doOwnerInfo(Json::Value jvRequest) { - if (!jvRequest.isMember("ident")) + if (!jvRequest.isMember("account") && !jvRequest.isMember("ident")) return rpcError(rpcINVALID_PARAMS); - std::string strIdent = jvRequest["ident"].asString(); + std::string strIdent = jvRequest.isMember("account") ? jvRequest["account"].asString() : jvRequest["ident"].asString(); bool bIndex; int iIndex = jvRequest.isMember("account_index") ? jvRequest["account_index"].asUInt() : 0; RippleAddress raAccount; diff --git a/src/js/account.js b/src/js/account.js index 59eb95c91..2e1121e5d 100644 --- a/src/js/account.js +++ b/src/js/account.js @@ -1,5 +1,7 @@ // Routines for working with an account. // +// You should not instantiate this class yourself, instead use Remote#account. +// // Events: // wallet_clean : True, iff the wallet has been updated. // wallet_dirty : True, iff the wallet needs to be updated. diff --git a/src/js/remote.js b/src/js/remote.js index fa9e4ba51..9b6bd4b5d 100644 --- a/src/js/remote.js +++ b/src/js/remote.js @@ -26,6 +26,7 @@ var OrderBook = require('./orderbook').OrderBook; var utils = require('./utils'); var config = require('./config'); +var sjcl = require('../../build/sjcl'); // Request events emitted: // 'success' : Request successful. @@ -890,7 +891,8 @@ Remote.prototype.request_tx = function (hash) { Remote.prototype.request_account_info = function (accountID) { var request = new Request(this, 'account_info'); - request.message.ident = UInt160.json_rewrite(accountID); + request.message.ident = UInt160.json_rewrite(accountID); // DEPRECATED + request.message.account = UInt160.json_rewrite(accountID); return request; }; @@ -1030,8 +1032,13 @@ Remote.prototype._server_subscribe = function () { self._stand_alone = !!message.stand_alone; self._testnet = !!message.testnet; - if (message.random) + if ("string" === typeof message.random) { + var rand = message.random.match(/[0-9A-F]{8}/ig); + while (rand && rand.length) + sjcl.random.addEntropy(parseInt(rand.pop(), 16)); + self.emit('random', utils.hexToArray(message.random)); + } if (message.ledger_hash && message.ledger_index) { self._ledger_time = message.ledger_time; @@ -1111,11 +1118,17 @@ Remote.prototype.request_owner_count = function (account, current) { }; Remote.prototype.account = function (accountId) { - var account = new Account(this, accountId); + accountId = UInt160.json_rewrite(accountId); - if (!account.is_valid()) return account; + if (!this._accounts[accountId]) { + var account = new Account(this, accountId); - return this._accounts[account.to_json()] = account; + if (!account.is_valid()) return account; + + this._accounts[accountId] = account; + } + + return this._accounts[accountId]; }; Remote.prototype.book = function (currency_out, issuer_out, @@ -1130,7 +1143,7 @@ Remote.prototype.book = function (currency_out, issuer_out, // Return the next account sequence if possible. // <-- undefined or Sequence Remote.prototype.account_seq = function (account, advance) { - var account = UInt160.json_rewrite(account); + account = UInt160.json_rewrite(account); var account_info = this.accounts[account]; var seq;