From ccd17582848bb6a13e5974e33888d12bf29890a1 Mon Sep 17 00:00:00 2001 From: wltsmrz Date: Wed, 21 Aug 2013 16:41:01 -0700 Subject: [PATCH] Add transaction-inbound and transaction-outbound events --- src/js/ripple/account.js | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/js/ripple/account.js b/src/js/ripple/account.js index 09b15574..49ea1368 100644 --- a/src/js/ripple/account.js +++ b/src/js/ripple/account.js @@ -162,23 +162,21 @@ Account.prototype.get_next_sequence = function(callback) { * * @param {function (err, lines)} callback Called with the result */ -Account.prototype.lines = function (callback) -{ +Account.prototype.lines = function (callback) { var self = this; + var callback = typeof callback === 'function' ? callback : function(){}; - self._remote.request_account_lines(this._account_id) - .on('success', function (e) { + function account_lines(err, lines) { + if (err) { + callback(err); + } else { self._lines = e.lines; self.emit('lines', self._lines); + callback(null, e); + } + } - if ("function" === typeof callback) { - callback(null, e); - } - }) - .on('error', function (e) { - callback(e); - }) - .request(); + this._remote.request_account_lines(this._account_id, account_lines); return this; }; @@ -195,6 +193,14 @@ Account.prototype.notifyTx = function (message) { // occurring. if (this._subs) { this.emit('transaction', message); + try { + var account = message.transaction.Account; + } catch(exception) { } + if (account === this._account_id) { + this.emit('transaction-outbound'); + } else { + this.emit('transaction-inbound'); + } } };