Merge pull request #27 from cmgustavo/fix/status-info

getting address information in two modes: only balance (without txs list...
This commit is contained in:
Matias Alejo Garcia 2014-03-22 02:11:20 -03:00
commit beee02072d
3 changed files with 20 additions and 14 deletions

View File

@ -136,8 +136,8 @@ The end-points are:
``` ```
### Address ### Address
``` ```
/api/addr/[:addr] /api/addr/[:addr][?noTxList=1]
/api/addr/mmvP3mTe53qxHdPqXEvdu8WdC7GfQ2vmx5 /api/addr/mmvP3mTe53qxHdPqXEvdu8WdC7GfQ2vmx5?noTxList=1
``` ```
### Transactions by Block ### Transactions by Block
``` ```

View File

@ -31,7 +31,7 @@ exports.show = function(req, res, next) {
else { else {
return res.jsonp(a); return res.jsonp(a);
} }
}); }, req.query.noTxList);
}; };

View File

@ -116,7 +116,7 @@ Address.prototype.getUtxo = function(next) {
}); });
}; };
Address.prototype.update = function(next) { Address.prototype.update = function(next, notxlist) {
var self = this; var self = this;
if (!self.addrStr) return next(); if (!self.addrStr) return next();
@ -132,13 +132,17 @@ Address.prototype.update = function(next) {
var v = txItem.value_sat; var v = txItem.value_sat;
if ( !seen[txItem.txid] ) { if ( !seen[txItem.txid] ) {
if (!notxlist) {
txs.push({txid: txItem.txid, ts: txItem.ts}); txs.push({txid: txItem.txid, ts: txItem.ts});
}
seen[txItem.txid]=1; seen[txItem.txid]=1;
add=1; add=1;
} }
if (txItem.spentTxId && !seen[txItem.spentTxId] ) { if (txItem.spentTxId && !seen[txItem.spentTxId] ) {
if (!notxlist) {
txs.push({txid: txItem.spentTxId, ts: txItem.spentTs}); txs.push({txid: txItem.spentTxId, ts: txItem.spentTs});
}
seen[txItem.spentTxId]=1; seen[txItem.spentTxId]=1;
addSpend=1; addSpend=1;
} }
@ -172,6 +176,7 @@ Address.prototype.update = function(next) {
}, },
], function (err) { ], function (err) {
if (!notxlist) {
// sort input and outputs togheter // sort input and outputs togheter
txs.sort( txs.sort(
function compare(a,b) { function compare(a,b) {
@ -181,6 +186,7 @@ Address.prototype.update = function(next) {
}); });
self.transactions = txs.map(function(i) { return i.txid; } ); self.transactions = txs.map(function(i) { return i.txid; } );
}
return next(err); return next(err);
}); });
}; };