mirror of https://github.com/BTCPrivate/copay.git
Merge pull request #136 from cmgustavo/feature/01-blockchain-tx-list
Feature/01 blockchain tx list
This commit is contained in:
commit
e860f96fb7
18
css/main.css
18
css/main.css
|
@ -117,6 +117,24 @@ body {
|
||||||
font-size: 12px;
|
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 {
|
.pending table {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
border: none;
|
border: none;
|
||||||
|
|
64
index.html
64
index.html
|
@ -338,40 +338,54 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="large-12 columns">
|
<div class="large-12 columns" ng-init="getTransactions()" ng-show="blockchain_txs[0].txid">
|
||||||
<!--
|
<h3>Last transactions</h3>
|
||||||
<h4>Last transactions</h4>
|
<div class="btransactions">
|
||||||
<div class="panel">
|
<div class="panel" ng-repeat="btx in blockchain_txs | orderBy: 'firstSeenTs':true">
|
||||||
|
<div class="txheader">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<p class="large-5 columns"> Address 1 <small class="right"> 1231 BTC </small></p>
|
<div class="large-8 columns">
|
||||||
<i class="large-1 columns fi-arrow-left size-16 text-center"></i>
|
ID: {{btx.txid}}
|
||||||
<p class="large-5 columns"> Address 2 <small class="right"> 1231 BTC </small></p>
|
</div>
|
||||||
<span class="panel-res panel-sign">
|
<div class="large-4 columns text-right">
|
||||||
<i class="fi-check size-16"></i>
|
{{btx.firstSeenTs * 1000 | date:'medium'}} </h6>
|
||||||
</span>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel">
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<p class="large-5 columns"> Address 1 <small class="right"> 1231 BTC </small></p>
|
<div class="large-5 columns">
|
||||||
<i class="large-1 columns fi-arrow-left size-16 text-center"></i>
|
<div ng-repeat="vin in btx.vin">
|
||||||
<p class="large-5 columns"> Address 2 <small class="right"> 1231 BTC </small></p>
|
{{vin.addr}}
|
||||||
<span class="panel-res panel-sign">
|
<small>{{vin.value}}</small>
|
||||||
<i class="fi-check size-16"></i>
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel">
|
<div class="large-1 columns text-center">
|
||||||
|
<i class="fi-arrow-right"></i>
|
||||||
|
</div>
|
||||||
|
<div class="large-6 columns">
|
||||||
|
<div ng-repeat="vout in btx.vout">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<p class="large-5 columns"> Address 1 <small class="right"> 1231 BTC </small></p>
|
<div class="large-10 columns">
|
||||||
<i class="large-1 columns fi-arrow-left size-16 text-center"></i>
|
<div ng-repeat="addr in vout.scriptPubKey.addresses">
|
||||||
<p class="large-5 columns"> Address 2 <small class="right"> 1231 BTC </small></p>
|
{{addr}}
|
||||||
<span class="panel-res panel-ignore">
|
</div>
|
||||||
<i class="fi-x size-16"></i>
|
</div>
|
||||||
</span>
|
<div class="large-2 columns">
|
||||||
|
<small>{{vout.value}}</small>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="txbottom">
|
||||||
|
<div class="row">
|
||||||
|
<div class="large-4 columns">Fees: {{btx.fees}}</div>
|
||||||
|
<div class="large-4 columns text-center">Confirmations: {{btx.confirmations || 0}}</div>
|
||||||
|
<div class="large-4 columns text-right">Total: {{btx.valueOut}}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
-->
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -70,6 +70,17 @@ angular.module('copay.transactions').controller('TransactionsController',
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$scope.getTransactions = function() {
|
||||||
|
var w =$rootScope.wallet;
|
||||||
|
var addresses = w.getAddressesStr();
|
||||||
|
|
||||||
|
if (addresses.length > 0) {
|
||||||
|
w.blockchain.getTransactions(addresses, function(txs) {
|
||||||
|
$scope.blockchain_txs = txs;
|
||||||
|
$rootScope.$digest();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
$scope.reject = function (ntxid) {
|
$scope.reject = function (ntxid) {
|
||||||
var w = $rootScope.wallet;
|
var w = $rootScope.wallet;
|
||||||
|
|
|
@ -29,6 +29,77 @@ function _asyncForEach(array, fn, callback) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function removeRepeatedElements(ar){
|
||||||
|
var ya=false,v="",aux=[].concat(ar),r=Array();
|
||||||
|
for (var i in aux){ //
|
||||||
|
v=aux[i];
|
||||||
|
ya=false;
|
||||||
|
for (var a in aux){
|
||||||
|
if (v==aux[a]){
|
||||||
|
if (ya==false){
|
||||||
|
ya=true;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
aux[a]="";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (var a in aux){
|
||||||
|
if (aux[a]!=""){
|
||||||
|
r.push(aux[a]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
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<txids_tmp.length; i++) {
|
||||||
|
txids.push(txids_tmp[i]);
|
||||||
|
}
|
||||||
|
callback();
|
||||||
|
});
|
||||||
|
}, function() {
|
||||||
|
var clean_txids = removeRepeatedElements(txids);
|
||||||
|
_asyncForEach(clean_txids, function(txid, callback2) {
|
||||||
|
var options = {
|
||||||
|
host: self.host,
|
||||||
|
port: self.port,
|
||||||
|
scheme: self.scheme,
|
||||||
|
method: 'GET',
|
||||||
|
path: '/api/tx/' + txid,
|
||||||
|
headers: { 'Access-Control-Request-Headers' : '' }
|
||||||
|
};
|
||||||
|
self._request(options, function(err, res) {
|
||||||
|
txs.push(res);
|
||||||
|
callback2();
|
||||||
|
});
|
||||||
|
}, function() {
|
||||||
|
return cb(txs);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
Insight.prototype.getUnspent = function(addresses, cb) {
|
Insight.prototype.getUnspent = function(addresses, cb) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
|
@ -98,7 +169,6 @@ Insight.prototype._request = function(options, callback) {
|
||||||
request.open(options.method, url, true);
|
request.open(options.method, url, true);
|
||||||
request.onreadystatechange = function() {
|
request.onreadystatechange = function() {
|
||||||
if (request.readyState === 4) {
|
if (request.readyState === 4) {
|
||||||
console.log('[Insight.js.102]', request); //TODO
|
|
||||||
if (request.status === 200) {
|
if (request.status === 200) {
|
||||||
return callback(null, JSON.parse(request.responseText));
|
return callback(null, JSON.parse(request.responseText));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue