Fixed block responses.
This commit is contained in:
parent
5e5a58db19
commit
da8920c4dc
@ -1,6 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
var bitcore = require('bitcore-lib');
|
||||
var Unit = bitcore.Unit;
|
||||
var async = require('async');
|
||||
var TxController = require('./transactions');
|
||||
var Common = require('./common');
|
||||
@ -71,17 +72,17 @@ AddressController.prototype.getAddressSummary = function(address, options, callb
|
||||
|
||||
var transformed = {
|
||||
addrStr: address,
|
||||
balance: summary.balance / 1e8,
|
||||
balance: Unit.fromSatoshis(summary.balance).toBTC(),
|
||||
balanceSat: summary.balance,
|
||||
totalReceived: summary.totalReceived / 1e8,
|
||||
totalReceivedSat: summary.totalReceived,
|
||||
totalSent: summary.totalSpent / 1e8,
|
||||
totalSentSat: summary.totalSpent,
|
||||
unconfirmedBalance: summary.unconfirmedBalance / 1e8,
|
||||
totalReceived: Unit.fromSatoshis(summary.totalReceived).toBTC(),
|
||||
totalReceivedSat: summary.totalReceivedSat,
|
||||
totalSent: Unit.fromSatoshis(summary.totalSent).toBTC(),
|
||||
totalSentSat: summary.totalSent,
|
||||
unconfirmedBalance: Unit.fromSatoshis(summary.unconfirmedBalance).toBTC(),
|
||||
unconfirmedBalanceSat: summary.unconfirmedBalance,
|
||||
unconfirmedTxApperances: summary.unconfirmedAppearances, // misspelling - ew
|
||||
txApperances: summary.appearances, // yuck
|
||||
transactions: summary.txids
|
||||
txApperances: summary.txApperances, // yuck
|
||||
transactions: summary.transactions
|
||||
};
|
||||
|
||||
callback(null, transformed);
|
||||
@ -95,7 +96,7 @@ AddressController.prototype.checkAddr = function(req, res, next) {
|
||||
|
||||
AddressController.prototype.checkAddrs = function(req, res, next) {
|
||||
if(req.body.addrs) {
|
||||
req.addrs = req.body.addrs.split(',');
|
||||
req.addrs = req.body.addrs;
|
||||
} else {
|
||||
req.addrs = req.params.addrs.split(',');
|
||||
}
|
||||
@ -146,7 +147,7 @@ AddressController.prototype.multiutxo = function(req, res) {
|
||||
|
||||
var addresses;
|
||||
if (_.isArray(req.addrs)) {
|
||||
addresses = req.addrs;
|
||||
addresses = _.uniq(req.addrs);
|
||||
} else {
|
||||
addresses = req.addrs.split(',');
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@ TxController.prototype.transaction = function(req, res, next) {
|
||||
var self = this;
|
||||
var txid = req.params.txid;
|
||||
|
||||
this._transaction.getDetailedTransaction(txid, function(err, transaction) {
|
||||
this._transaction.getDetailedTransaction(txid, {}, function(err, transaction) {
|
||||
if (err) {
|
||||
return self.common.handleErrors(err, res);
|
||||
}
|
||||
@ -239,12 +239,15 @@ TxController.prototype.list = function(req, res) {
|
||||
|
||||
if(blockHash) {
|
||||
self._block.getBlockOverview(blockHash, function(err, block) {
|
||||
if(err && err.code === -5) {
|
||||
return self.common.handleErrors(null, res);
|
||||
} else if(err) {
|
||||
|
||||
if (err) {
|
||||
return self.common.handleErrors(err, res);
|
||||
}
|
||||
|
||||
if (!block) {
|
||||
return self.common.handleErrors(null, res);
|
||||
}
|
||||
|
||||
var totalTxs = block.txids.length;
|
||||
var txids;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user