diff --git a/app/models/Transaction.js b/app/models/Transaction.js index eaa0081..b2678e0 100644 --- a/app/models/Transaction.js +++ b/app/models/Transaction.js @@ -282,7 +282,7 @@ TransactionSchema.statics.queryInfo = function(txid, cb) { else { tx.ins.forEach(function(i) { if (i.value) { - info.vin[c].value = util.formatValue(i.value); + info.vin[c].value = parseFloat(util.formatValue(i.value)); var n = util.valueToBigInt(i.value).toNumber(); info.vin[c].valueSat = n; valueIn = valueIn.add( n ); diff --git a/public/css/common.css b/public/css/common.css index 9c9e546..fb01695 100644 --- a/public/css/common.css +++ b/public/css/common.css @@ -334,4 +334,13 @@ h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 { background-color: #1a1a1a; } +.expanded-tx { + border-bottom: 1px dashed #444; +} + + +.expanded-tx small { + font-size: 80%; +} + diff --git a/public/js/controllers/transactions.js b/public/js/controllers/transactions.js index 496e0dd..d33e250 100644 --- a/public/js/controllers/transactions.js +++ b/public/js/controllers/transactions.js @@ -8,11 +8,56 @@ angular.module('insight.transactions').controller('transactionsController', $scope.findTx($routeParams.txId); }; + + $scope.aggregateItems = function(items) { + var l = items.length; + + var ret = []; + var tmp = {}; + // TODO multiple output address + // + for(var i=0; i < l; i++) { + + // non standard output + if (items[i].scriptPubKey && items[i].scriptPubKey.addresses.length > 1) { + item[i].addr = items[i].scriptPubKey.addresses.join(','); + ret.push(items[i]); + continue; + } + + var addr = items[i].addr || + (items[i].scriptPubKey && items[i].scriptPubKey.addresses[0] ); + if (!tmp[addr]) { + tmp[addr] = {}; + tmp[addr].valueSat = 0; + tmp[addr].count = 0; + tmp[addr].addr = addr; + tmp[addr].items = []; + } + tmp[addr].valueSat += items[i].valueSat; + tmp[addr].value = tmp[addr].valueSat / 100000000; + tmp[addr].items.push(items[i]); + tmp[addr].count++; + } + + angular.forEach(tmp, function(v) { + ret.push(v); + }); + return (ret); + }; + + + $scope.processTX = function(tx) { + tx.vinSimple = $scope.aggregateItems(tx.vin); + tx.voutSimple = $scope.aggregateItems(tx.vout); + }; + $scope.findTx = function(txid) { Transaction.get({ txId: txid }, function(tx) { $scope.tx = tx; + $scope.processTX(tx); $scope.txs.unshift(tx); }, function(e) { if (e.status === 400) { @@ -32,6 +77,9 @@ angular.module('insight.transactions').controller('transactionsController', TransactionsByBlock.query({ block: bId }, function(txs) { + angular.forEach(txs, function(tx) { + $scope.processTX(tx); + }); $scope.txs = txs; }); }; @@ -40,6 +88,9 @@ angular.module('insight.transactions').controller('transactionsController', TransactionsByAddress.query({ address: aId }, function(txs) { + angular.forEach(txs, function(tx) { + $scope.processTX(tx); + }); $scope.txs = txs; }); }; diff --git a/public/views/transaction.html b/public/views/transaction.html index fe4afeb..4e325be 100644 --- a/public/views/transaction.html +++ b/public/views/transaction.html @@ -5,72 +5,13 @@
| Size | @@ -81,9 +22,10 @@{{tx.time * 1000|date:'medium'}} |
| Block | -Block | -Block + | + + {{tx.blockhash}} |
No Inputs (Newly Generated isCoinBasens)
-{{vin.reward}} BTC
-{{vin.value}} BTC
-{{vout.value}} BTC
-No Inputs (Newly Generated Coins)
+{{vin.reward}} BTC
+{{vin.value}} BTC
+{{vout.value}} BTC
+{{vout.value}} BTC
+