simple versions of vin vout for displaying
This commit is contained in:
parent
aab8ac2e29
commit
0dfaec73db
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue