address: update utxos
This commit is contained in:
parent
78870fc56e
commit
b18dc95755
@ -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
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user