Merge pull request #28 from thedawnrider/addressProperties
Address properties
This commit is contained in:
commit
5541e6590d
@ -51,3 +51,54 @@ exports.utxo = function(req, res, next) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
exports.balance = function(req, res, next) {
|
||||||
|
var a = getAddr(req, res, next);
|
||||||
|
if (a)
|
||||||
|
a.update(function(err) {
|
||||||
|
if (err) {
|
||||||
|
return common.handleErrors(err, res);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return res.jsonp(a.balanceSat);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.totalReceived = function(req, res, next) {
|
||||||
|
var a = getAddr(req, res, next);
|
||||||
|
if (a)
|
||||||
|
a.update(function(err) {
|
||||||
|
if (err) {
|
||||||
|
return common.handleErrors(err, res);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return res.jsonp(a.totalReceivedSat);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.totalSent = function(req, res, next) {
|
||||||
|
var a = getAddr(req, res, next);
|
||||||
|
if (a)
|
||||||
|
a.update(function(err) {
|
||||||
|
if (err) {
|
||||||
|
return common.handleErrors(err, res);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return res.jsonp(a.totalSentSat);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.unconfirmedBalance = function(req, res, next) {
|
||||||
|
var a = getAddr(req, res, next);
|
||||||
|
if (a)
|
||||||
|
a.update(function(err) {
|
||||||
|
if (err) {
|
||||||
|
return common.handleErrors(err, res);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return res.jsonp(a.unconfirmedBalanceSat);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|||||||
@ -32,6 +32,12 @@ module.exports = function(app) {
|
|||||||
app.get(apiPrefix + '/addr/:addr', addresses.show);
|
app.get(apiPrefix + '/addr/:addr', addresses.show);
|
||||||
app.get(apiPrefix + '/addr/:addr/utxo', addresses.utxo);
|
app.get(apiPrefix + '/addr/:addr/utxo', addresses.utxo);
|
||||||
|
|
||||||
|
// Address property routes
|
||||||
|
app.get(apiPrefix + '/addr/:addr/balance', addresses.balance);
|
||||||
|
app.get(apiPrefix + '/addr/:addr/totalReceived', addresses.totalReceived);
|
||||||
|
app.get(apiPrefix + '/addr/:addr/totalSent', addresses.totalSent);
|
||||||
|
app.get(apiPrefix + '/addr/:addr/unconfirmedBalance', addresses.unconfirmedBalance);
|
||||||
|
|
||||||
// Status route
|
// Status route
|
||||||
var st = require('../app/controllers/status');
|
var st = require('../app/controllers/status');
|
||||||
app.get(apiPrefix + '/status', st.show);
|
app.get(apiPrefix + '/status', st.show);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user