From df9b26fddeb15d3d81546361aad6e90310a0b1f5 Mon Sep 17 00:00:00 2001 From: Gustavo Cortez Date: Wed, 23 Apr 2014 01:55:00 -0300 Subject: [PATCH] List of transactions by address associated to wallet --- css/main.css | 18 ++++++++ index.html | 76 +++++++++++++++++++-------------- js/controllers/transactions.js | 11 +++++ js/models/blockchain/Insight.js | 47 +++++++++++++++++++- 4 files changed, 120 insertions(+), 32 deletions(-) diff --git a/css/main.css b/css/main.css index 0df6831d4..6ab5b4587 100644 --- a/css/main.css +++ b/css/main.css @@ -117,6 +117,24 @@ body { font-size: 12px; } +.btransactions .panel { + background: #fff; +} + +.btransactions .txheader { + font-size: 12px; + margin-bottom: 10px; + padding-bottom: 10px; + border-bottom: 1px solid #eee; +} + +.btransactions .txbottom { + margin-top: 10px; + padding-top: 10px; + border-top: 1px solid #eee; + font-size: 12px; +} + .pending table { width: 100%; border: none; diff --git a/index.html b/index.html index bedc3b4ac..b5aef3a5d 100644 --- a/index.html +++ b/index.html @@ -329,39 +329,53 @@
-
diff --git a/js/controllers/transactions.js b/js/controllers/transactions.js index d4356a62a..aee87b56e 100644 --- a/js/controllers/transactions.js +++ b/js/controllers/transactions.js @@ -67,5 +67,16 @@ console.log('[transactions.js.68:txid:] SENTTX CALLBACK',txid); //TODO } }; + $scope.getTransactions = function() { + var w =$rootScope.wallet; + var addresses = w.getAddressesStr(true); + + w.blockchain.getTransactions(addresses, function(txs) { + $scope.blockchain_txs = txs; + $scope.$digest(); + }); + + }; + _updateTxs(); }); diff --git a/js/models/blockchain/Insight.js b/js/models/blockchain/Insight.js index 67097f2ce..0bcca1a72 100644 --- a/js/models/blockchain/Insight.js +++ b/js/models/blockchain/Insight.js @@ -29,6 +29,52 @@ function _asyncForEach(array, fn, callback) { } }; +Insight.prototype.getTransactions = function(addresses, cb) { + var self = this; + + if (!addresses || !addresses.length) return cb([]); + + var txids = []; + var txs = []; + + _asyncForEach(addresses, function(addr, callback) { + var options = { + host: self.host, + port: self.port, + scheme: self.scheme, + method: 'GET', + path: '/api/addr/' + addr, + + headers: { 'Access-Control-Request-Headers' : '' } + }; + + self._request(options, function(err, res) { + var txids_tmp = res.transactions; + for(var i=0; i