Fixed: sub-query APIs value conversion
- Fixed: Sat-to-Coin conversion applied over Coin value - Fixed: totalReceived and totalSent APIs returning Sat instead of Coin value
This commit is contained in:
parent
79ed3ad330
commit
ad9fe0c80a
@ -27,7 +27,7 @@ AddressController.prototype.show = function(req, res) {
|
|||||||
options.to = parseInt(req.query.to);
|
options.to = parseInt(req.query.to);
|
||||||
}
|
}
|
||||||
|
|
||||||
this._address.getAddressSummary(req.addr, options, function(err, data) {
|
self._address.getAddressSummary(req.addr, options, function(err, data) {
|
||||||
if(err) {
|
if(err) {
|
||||||
return self.common.handleErrors(err, res);
|
return self.common.handleErrors(err, res);
|
||||||
}
|
}
|
||||||
@ -75,24 +75,24 @@ AddressController.prototype.show_ws = function(req, ws) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
AddressController.prototype.balance = function(req, res) {
|
AddressController.prototype.balance = function(req, res) {
|
||||||
this.addressSummarySubQuery(req, res, 'balanceSat');
|
this.addressSummarySubQuery(req, res, 'balance');
|
||||||
};
|
};
|
||||||
|
|
||||||
AddressController.prototype.totalReceived = function(req, res) {
|
AddressController.prototype.totalReceived = function(req, res) {
|
||||||
this.addressSummarySubQuery(req, res, 'totalReceivedSat');
|
this.addressSummarySubQuery(req, res, 'totalReceived');
|
||||||
};
|
};
|
||||||
|
|
||||||
AddressController.prototype.totalSent = function(req, res) {
|
AddressController.prototype.totalSent = function(req, res) {
|
||||||
this.addressSummarySubQuery(req, res, 'totalSentSat');
|
this.addressSummarySubQuery(req, res, 'totalSent');
|
||||||
};
|
};
|
||||||
|
|
||||||
AddressController.prototype.unconfirmedBalance = function(req, res) {
|
AddressController.prototype.unconfirmedBalance = function(req, res) {
|
||||||
this.addressSummarySubQuery(req, res, 'unconfirmedBalanceSat');
|
this.addressSummarySubQuery(req, res, 'unconfirmedBalance');
|
||||||
};
|
};
|
||||||
|
|
||||||
AddressController.prototype.addressSummarySubQuery = function(req, res, param) {
|
AddressController.prototype.addressSummarySubQuery = function(req, res, param) {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.getAddressSummary(req.addr, {}, function(err, data) {
|
self.getAddressSummary(req.addr, {}, function(err, data) {
|
||||||
if(err) {
|
if(err) {
|
||||||
return self.common.handleErrors(err, res);
|
return self.common.handleErrors(err, res);
|
||||||
}
|
}
|
||||||
@ -104,21 +104,21 @@ AddressController.prototype.addressSummarySubQuery = function(req, res, param) {
|
|||||||
AddressController.prototype.getAddressSummary = function(address, options, callback) {
|
AddressController.prototype.getAddressSummary = function(address, options, callback) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
this._address.getAddressSummary(address, options, function(err, summary) {
|
self._address.getAddressSummary(address, options, function(err, summary) {
|
||||||
if(err) {
|
if(err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
var transformed = {
|
var transformed = {
|
||||||
address: self.common.translateOutputAddress(address),
|
address: self.common.translateOutputAddress(address),
|
||||||
balance: Unit.fromSatoshis(summary.balance).toBTC(),
|
balance: summary.balance,
|
||||||
balanceSat: summary.balance,
|
balanceSat: summary.balanceSat,
|
||||||
totalReceived: Unit.fromSatoshis(summary.totalReceived).toBTC(),
|
totalReceived: summary.totalReceived,
|
||||||
totalReceivedSat: summary.totalReceivedSat,
|
totalReceivedSat: summary.totalReceivedSat,
|
||||||
totalSent: Unit.fromSatoshis(summary.totalSent).toBTC(),
|
totalSent: summary.totalSent,
|
||||||
totalSentSat: summary.totalSentSat,
|
totalSentSat: summary.totalSentSat,
|
||||||
unconfirmedBalance: Unit.fromSatoshis(summary.unconfirmedBalance).toBTC(),
|
unconfirmedBalance: summary.unconfirmedBalance,
|
||||||
unconfirmedBalanceSat: summary.unconfirmedBalance,
|
unconfirmedBalanceSat: summary.unconfirmedBalanceSat,
|
||||||
unconfirmedTxApperances: summary.unconfirmedAppearances, // misspelling - ew
|
unconfirmedTxApperances: summary.unconfirmedAppearances, // misspelling - ew
|
||||||
txApperances: summary.txApperances, // yuck
|
txApperances: summary.txApperances, // yuck
|
||||||
transactions: summary.transactions
|
transactions: summary.transactions
|
||||||
@ -148,7 +148,7 @@ AddressController.prototype.checkAddrs = function(req, res, next) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!_.isArray(req.addrs) || _.compact(req.addrs).length < 1) {
|
if(!_.isArray(req.addrs) || _.compact(req.addrs).length < 1) {
|
||||||
return this.common.handleErrors({
|
return self.common.handleErrors({
|
||||||
message: 'Must include address',
|
message: 'Must include address',
|
||||||
code: 1
|
code: 1
|
||||||
}, res);
|
}, res);
|
||||||
@ -159,7 +159,7 @@ AddressController.prototype.checkAddrs = function(req, res, next) {
|
|||||||
req.addr = req.addrs[0];
|
req.addr = req.addrs[0];
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
console.log('[addresses.js.130]', e); //TODO
|
console.log('[addresses.js.130]', e); //TODO
|
||||||
return this.common.handleErrors({
|
return self.common.handleErrors({
|
||||||
message: 'Invalid address: ' + e,
|
message: 'Invalid address: ' + e,
|
||||||
code: 1
|
code: 1
|
||||||
}, res);
|
}, res);
|
||||||
@ -171,7 +171,7 @@ console.log('[addresses.js.130]', e); //TODO
|
|||||||
AddressController.prototype.utxo = function(req, res) {
|
AddressController.prototype.utxo = function(req, res) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
this._address.getAddressUnspentOutputs(req.addr, {}, function(err, utxos) {
|
self._address.getAddressUnspentOutputs(req.addr, {}, function(err, utxos) {
|
||||||
var results;
|
var results;
|
||||||
if(err) {
|
if(err) {
|
||||||
return self.common.handleErrors(err, res);
|
return self.common.handleErrors(err, res);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user