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 @@
-
- {{tx.txid}} -
- -
- -
-
    -
  • - - - Address could not be parsed - {{vin.addr}} - {{vin.value}} BTC -
  • - -
-
-
    -
  • - No Inputs (Newly Generated isCoinBasens) - {{vinn.reward}} BTC -
  • -
-
-
- -
- -
- -
-
-
- {{vout.scriptPubKey.type}} -
-
- -
-
-
-
- -
- Feeds: {{tx.feeds}} -
- - - -
-
+

Summary

- +
@@ -81,9 +22,10 @@ - - - +
Size {{tx.time * 1000|date:'medium'}}
Block Block
Block + + + {{tx.blockhash}}
@@ -106,6 +48,7 @@
+ diff --git a/public/views/transaction/list.html b/public/views/transaction/list.html index eb3a45c..e0c036c 100644 --- a/public/views/transaction/list.html +++ b/public/views/transaction/list.html @@ -1,71 +1,5 @@
Loading...
There are not transactions
-
- {{tx.txid}} - {{tx.time * 1000 | date:'medium'}} -
- -
-
-
-
-

No Inputs (Newly Generated isCoinBasens)

-
-

{{vin.reward}} BTC

-
-
    -
  • - - -
    -
    - Address could not be parsed - {{vin.addr}} -
    -
    -

    {{vin.value}} BTC

    -
  • -
-
- -
-   -
- -
-
-
-
- {{vout.scriptPubKey.type}} -
-
-
-
- -
-
-

{{vout.value}} BTC

-
-
-
-
-
- -
-
-
- - - -
- Feeds: {{tx.feeds}} -
-
+
diff --git a/public/views/transaction/tx.html b/public/views/transaction/tx.html new file mode 100644 index 0000000..c33a0f6 --- /dev/null +++ b/public/views/transaction/tx.html @@ -0,0 +1,114 @@ +
+ {{tx.txid}} + {{tx.time * 1000 | date:'medium'}} +
+ +
+
+
+
+

No Inputs (Newly Generated Coins)

+
+

{{vin.reward}} BTC

+
+ +
+ + +
    +
  • + + +
    +
    + Address could not be parsed + {{vin.addr}} +
    +
    + scriptSig{{vin.scriptSig.asm}} +
    +
    +

    {{vin.value}} BTC

    +
+ + +
+
+ +
+   +
+ +
+
+
+
+ +
+
+

{{vout.value}} BTC

+
+
+
+
+ + type {{vout.scriptPubKey.type}} +
+ scriptPubKey {{vout.scriptPubKey.asm}} +
+
+
+

{{vout.value}} BTC

+
+
+ +
+ +
+
+ +
+
+
+ + + +
+ Feeds: {{tx.feeds}} +
+
+