From b18dc95755672275e7ab6dceb85d581f01449d2c Mon Sep 17 00:00:00 2001 From: Braydon Fuller Date: Tue, 5 Apr 2016 10:32:34 -0400 Subject: [PATCH] address: update utxos --- lib/addresses.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/addresses.js b/lib/addresses.js index 065375b..7e82030 100644 --- a/lib/addresses.js +++ b/lib/addresses.js @@ -117,13 +117,12 @@ AddressController.prototype.check = function(req, res, next, addresses) { AddressController.prototype.utxo = function(req, res) { var self = this; - this.node.getUnspentOutputs(req.addr, true, function(err, utxos) { - if(err && err instanceof self.node.errors.NoOutputs) { - return res.jsonp([]); - } else if(err) { + this.node.getAddressUnspentOutputs(req.addr, {}, function(err, utxos) { + if(err) { return common.handleErrors(err, res); + } else if (!utxos.length) { + return res.jsonp([]); } - res.jsonp(utxos.map(self.transformUtxo.bind(self))); }); }; @@ -147,10 +146,12 @@ AddressController.prototype.transformUtxo = function(utxo) { address: utxo.address, txid: utxo.txid, vout: utxo.outputIndex, + height: utxo.height, ts: utxo.timestamp ? parseInt(utxo.timestamp) : Date.now(), scriptPubKey: utxo.script, amount: utxo.satoshis / 1e8, - confirmations: utxo.confirmations + satoshis: utxo.satoshis, + confirmations: this.node.services.bitcoind.height - utxo.height + 1 }; };