From 8e7887fa4005dc54cc4474d627044b14b48684c8 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Mon, 20 Jan 2014 17:39:27 -0300 Subject: [PATCH 1/5] isolate TX view --- public/views/transaction.html | 70 +++--------------------------- public/views/transaction/list.html | 68 +---------------------------- public/views/transaction/tx.html | 68 +++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+), 130 deletions(-) create mode 100644 public/views/transaction/tx.html diff --git a/public/views/transaction.html b/public/views/transaction.html index fe4afeb..ddc6007 100644 --- a/public/views/transaction.html +++ b/public/views/transaction.html @@ -5,66 +5,7 @@
- - -
- -
-
    -
  • - - - Address could not be parsed - {{vin.addr}} - {{vin.value}} BTC -
  • - -
-
-
    -
  • - No Inputs (Newly Generated isCoinBasens) - {{vinn.reward}} BTC -
  • -
-
-
- -
- -
- -
-
-
- {{vout.scriptPubKey.type}} -
-
- -
-
-
-
- -
- Feeds: {{tx.feeds}} -
- - - -
-
+
@@ -81,9 +22,12 @@ {{tx.time * 1000|date:'medium'}} - Block - Block - + Block + + +
diff --git a/public/views/transaction/list.html b/public/views/transaction/list.html index f8501c9..a8d35eb 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..a48c67b --- /dev/null +++ b/public/views/transaction/tx.html @@ -0,0 +1,68 @@ +
+ {{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}} +
+
+ From 0c10fd35ea8ed78e743df837b4d5ffa06957396a Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Mon, 20 Jan 2014 17:51:13 -0300 Subject: [PATCH 2/5] fix layouts problems in tx --- public/views/transaction.html | 6 ++---- public/views/transaction/tx.html | 6 +++--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/public/views/transaction.html b/public/views/transaction.html index ddc6007..aef2bfa 100644 --- a/public/views/transaction.html +++ b/public/views/transaction.html @@ -11,7 +11,7 @@

Summary

- +
@@ -25,9 +25,7 @@
Size Block - + {{tx.blockhash}}
diff --git a/public/views/transaction/tx.html b/public/views/transaction/tx.html index a48c67b..84261d0 100644 --- a/public/views/transaction/tx.html +++ b/public/views/transaction/tx.html @@ -7,13 +7,13 @@
-

No Inputs (Newly Generated isCoinBasens)

+

No Inputs (Newly Generated Coins)

{{vin.reward}} BTC

  • - +
    @@ -40,7 +40,7 @@
    From aab8ac2e29f9f33c85dfd836b2a29a026afb25e7 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Mon, 20 Jan 2014 18:11:50 -0300 Subject: [PATCH 3/5] add scripts to tx --- public/views/transaction.html | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/public/views/transaction.html b/public/views/transaction.html index aef2bfa..8e4ee01 100644 --- a/public/views/transaction.html +++ b/public/views/transaction.html @@ -48,6 +48,20 @@
    +
    +

    ScriptSig

    +
      +
    • + {{vin.scriptSig.asm}} +
    +
    +
    +

    ScriptPubKey

    +
      +
    • {{vout.scriptPubKey.asm}} +
    +
    +
    From 0dfaec73db9512f8df9b78ba55a6ff0c58791c4d Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Mon, 20 Jan 2014 18:57:50 -0300 Subject: [PATCH 4/5] simple versions of vin vout for displaying --- public/js/controllers/transactions.js | 44 +++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/public/js/controllers/transactions.js b/public/js/controllers/transactions.js index 52b12c9..c82b659 100644 --- a/public/js/controllers/transactions.js +++ b/public/js/controllers/transactions.js @@ -17,11 +17,55 @@ 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) { + ret.push(items[i]); + continue; + } + + var addr = items[i].addr || 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); +console.log('[transactions.js.33:insSimple:]',tx); //TODO + }; + $scope.findTx = function(txid) { Transaction.get({ txId: txid }, function(tx) { $scope.tx = tx; +$scope.processTX(tx); $scope.txs.push(tx); }, function(e) { if (e.status === 400) { From 8df8b9e35082afcf12a6dc7853dc96ad0756be86 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Mon, 20 Jan 2014 23:01:07 -0300 Subject: [PATCH 5/5] expand input / outputs --- app/models/Transaction.js | 2 +- public/css/common.css | 9 +++ public/js/controllers/transactions.js | 13 +++- public/views/transaction.html | 13 ---- public/views/transaction/tx.html | 86 ++++++++++++++++++++------- 5 files changed, 86 insertions(+), 37 deletions(-) diff --git a/app/models/Transaction.js b/app/models/Transaction.js index 5e418ad..e7f0882 100644 --- a/app/models/Transaction.js +++ b/app/models/Transaction.js @@ -279,7 +279,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 5747588..525bd9a 100644 --- a/public/css/common.css +++ b/public/css/common.css @@ -314,4 +314,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 c82b659..7488ed3 100644 --- a/public/js/controllers/transactions.js +++ b/public/js/controllers/transactions.js @@ -29,11 +29,13 @@ angular.module('insight.transactions').controller('transactionsController', // 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.addresses[0]; + var addr = items[i].addr || + (items[i].scriptPubKey && items[i].scriptPubKey.addresses[0] ); if (!tmp[addr]) { tmp[addr] = {}; tmp[addr].valueSat = 0; @@ -57,7 +59,6 @@ angular.module('insight.transactions').controller('transactionsController', $scope.processTX = function(tx) { tx.vinSimple = $scope.aggregateItems(tx.vin); tx.voutSimple = $scope.aggregateItems(tx.vout); -console.log('[transactions.js.33:insSimple:]',tx); //TODO }; $scope.findTx = function(txid) { @@ -65,7 +66,7 @@ console.log('[transactions.js.33:insSimple:]',tx); //TODO txId: txid }, function(tx) { $scope.tx = tx; -$scope.processTX(tx); + $scope.processTX(tx); $scope.txs.push(tx); }, function(e) { if (e.status === 400) { @@ -85,6 +86,9 @@ $scope.processTX(tx); TransactionsByBlock.query({ block: bId }, function(txs) { + angular.forEach(txs, function(tx) { + $scope.processTX(tx); + }); $scope.txs = txs; }); }; @@ -93,6 +97,9 @@ $scope.processTX(tx); 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 8e4ee01..4e325be 100644 --- a/public/views/transaction.html +++ b/public/views/transaction.html @@ -48,19 +48,6 @@
    -
    -

    ScriptSig

    -
      -
    • - {{vin.scriptSig.asm}} -
    -
    -
    -

    ScriptPubKey

    -
      -
    • {{vout.scriptPubKey.asm}} -
    -
    diff --git a/public/views/transaction/tx.html b/public/views/transaction/tx.html index 84261d0..c33a0f6 100644 --- a/public/views/transaction/tx.html +++ b/public/views/transaction/tx.html @@ -11,19 +11,45 @@

{{vin.reward}} BTC

- +

{{vin.value}} BTC

+ + + + + +
@@ -32,21 +58,41 @@
-
-
- {{vout.scriptPubKey.type}} -
-
-
-
+
+

{{vout.value}} BTC

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

{{vout.value}} BTC

+
+
+ +
+