diff --git a/lib/services/address/history.js b/lib/services/address/history.js index 946eac26..2d1dcd34 100644 --- a/lib/services/address/history.js +++ b/lib/services/address/history.js @@ -80,18 +80,18 @@ AddressHistory.prototype.get = function(callback) { return callback(new TypeError('Maximum number of addresses (' + this.maxAddressesQuery + ') exceeded')); } - this.options.noBalance = true; + var opts = _.clone(this.options); + opts.noBalance = true; if (this.addresses.length === 1) { var address = this.addresses[0]; - self.node.services.address.getAddressSummary(address, this.options, function(err, summary) { + self.node.services.address.getAddressSummary(address, opts, function(err, summary) { if (err) { return callback(err); } return self._paginateWithDetails.call(self, summary.txids, callback); }); } else { - var opts = _.clone(this.options); opts.fullTxList = true; async.mapLimit( diff --git a/lib/services/address/index.js b/lib/services/address/index.js index f67fa8ae..94c4db9f 100644 --- a/lib/services/address/index.js +++ b/lib/services/address/index.js @@ -1447,12 +1447,13 @@ AddressService.prototype._getAddressConfirmedOutputsSummary = function(address, var txid = output.txid; var outputIndex = output.outputIndex; + result.totalReceived += output.satoshis; + result.appearanceIds[txid] = output.height; if (!options.noBalance) { + // Bitcoind's isSpent only works for confirmed transactions var spentDB = self.node.services.bitcoind.isSpent(txid, outputIndex); - result.totalReceived += output.satoshis; - result.appearanceIds[txid] = output.height; if (!spentDB) { result.balance += output.satoshis; @@ -1546,12 +1547,12 @@ AddressService.prototype._getAddressMempoolSummary = function(address, options, if (err) { return next(err); } - if (!options.noBalance) { - for (var i = 0; i < mempoolOutputs.length; i++) { - var output = mempoolOutputs[i]; + for (var i = 0; i < mempoolOutputs.length; i++) { + var output = mempoolOutputs[i]; - result.unconfirmedAppearanceIds[output.txid] = output.timestamp; + result.unconfirmedAppearanceIds[output.txid] = output.timestamp; + if (!options.noBalance) { var spentIndexSyncKey = encoding.encodeSpentIndexSyncKey( new Buffer(output.txid, 'hex'), // TODO: get buffer directly output.outputIndex