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) {
|
AddressController.prototype.utxo = function(req, res) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
this.node.getUnspentOutputs(req.addr, true, function(err, utxos) {
|
this.node.getAddressUnspentOutputs(req.addr, {}, function(err, utxos) {
|
||||||
if(err && err instanceof self.node.errors.NoOutputs) {
|
if(err) {
|
||||||
return res.jsonp([]);
|
|
||||||
} else if(err) {
|
|
||||||
return common.handleErrors(err, res);
|
return common.handleErrors(err, res);
|
||||||
|
} else if (!utxos.length) {
|
||||||
|
return res.jsonp([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
res.jsonp(utxos.map(self.transformUtxo.bind(self)));
|
res.jsonp(utxos.map(self.transformUtxo.bind(self)));
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -147,10 +146,12 @@ AddressController.prototype.transformUtxo = function(utxo) {
|
|||||||
address: utxo.address,
|
address: utxo.address,
|
||||||
txid: utxo.txid,
|
txid: utxo.txid,
|
||||||
vout: utxo.outputIndex,
|
vout: utxo.outputIndex,
|
||||||
|
height: utxo.height,
|
||||||
ts: utxo.timestamp ? parseInt(utxo.timestamp) : Date.now(),
|
ts: utxo.timestamp ? parseInt(utxo.timestamp) : Date.now(),
|
||||||
scriptPubKey: utxo.script,
|
scriptPubKey: utxo.script,
|
||||||
amount: utxo.satoshis / 1e8,
|
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