List of transactions by address associated to wallet

This commit is contained in:
Gustavo Cortez 2014-04-23 01:55:00 -03:00
parent 37c20b47ac
commit df9b26fdde
4 changed files with 120 additions and 32 deletions

View File

@ -117,6 +117,24 @@ body {
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 {
width: 100%;
border: none;

View File

@ -329,39 +329,53 @@
</div>
</div>
<div class="large-12 columns">
<!--
<h4>Last transactions</h4>
<div class="panel">
<div class="row">
<p class="large-5 columns"> Address 1 <small class="right"> 1231 BTC </small></p>
<i class="large-1 columns fi-arrow-left size-16 text-center"></i>
<p class="large-5 columns"> Address 2 <small class="right"> 1231 BTC </small></p>
<span class="panel-res panel-sign">
<i class="fi-check size-16"></i>
</span>
<h3>Last transactions</h3>
<div class="btransactions" ng-init="getTransactions()">
<div class="panel" ng-repeat="btx in blockchain_txs | orderBy: 'firstSeenTs':true"">
<div class="txheader">
<div class="row">
<div class="large-8 columns">
ID: {{btx.txid}}
</div>
<div class="large-4 columns text-right">
{{btx.firstSeenTs * 1000 | date:'medium'}} </h6>
</div>
</div>
</div>
<div class="row">
<div class="large-5 columns">
<div ng-repeat="vin in btx.vin">
{{vin.addr}}
<small>{{vin.value}}</small>
</div>
</div>
<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="large-10 columns">
<div ng-repeat="addr in vout.scriptPubKey.addresses">
{{addr}}
</div>
</div>
<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 class="panel">
<div class="row">
<p class="large-5 columns"> Address 1 <small class="right"> 1231 BTC </small></p>
<i class="large-1 columns fi-arrow-left size-16 text-center"></i>
<p class="large-5 columns"> Address 2 <small class="right"> 1231 BTC </small></p>
<span class="panel-res panel-sign">
<i class="fi-check size-16"></i>
</span>
</div>
</div>
<div class="panel">
<div class="row">
<p class="large-5 columns"> Address 1 <small class="right"> 1231 BTC </small></p>
<i class="large-1 columns fi-arrow-left size-16 text-center"></i>
<p class="large-5 columns"> Address 2 <small class="right"> 1231 BTC </small></p>
<span class="panel-res panel-ignore">
<i class="fi-x size-16"></i>
</span>
</div>
</div>
-->
</div>
</div>
</div>

View File

@ -67,5 +67,16 @@ console.log('[transactions.js.68:txid:] SENTTX CALLBACK',txid); //TODO
}
};
$scope.getTransactions = function() {
var w =$rootScope.wallet;
var addresses = w.getAddressesStr(true);
w.blockchain.getTransactions(addresses, function(txs) {
$scope.blockchain_txs = txs;
$scope.$digest();
});
};
_updateTxs();
});

View File

@ -29,6 +29,52 @@ function _asyncForEach(array, fn, callback) {
}
};
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() {
_asyncForEach(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) {
var self = this;
@ -98,7 +144,6 @@ Insight.prototype._request = function(options, callback) {
request.open(options.method, url, true);
request.onreadystatechange = function() {
if (request.readyState === 4) {
console.log('[Insight.js.102]', request); //TODO
if (request.status === 200) {
return callback(null, JSON.parse(request.responseText));
}