Merge pull request #292 from troggy/expose-getUtxos

Expose getUtxos via REST endpoint
This commit is contained in:
Ivan Socolsky 2015-07-19 13:14:00 -03:00
commit 018adb2000
2 changed files with 13 additions and 5 deletions

View File

@ -276,6 +276,15 @@ ExpressApp.prototype.start = function(opts, cb) {
});
});
router.get('/v1/utxos/', function(req, res) {
getServerWithAuth(req, res, function(server) {
server.getUtxos(function(err, utxos) {
if (err) return returnError(err, res, req);
res.json(utxos);
});
});
});
router.post('/v1/txproposals/:id/signatures/', function(req, res) {
getServerWithAuth(req, res, function(server) {
req.body.txProposalId = req.params['id'];

View File

@ -621,10 +621,9 @@ WalletService.prototype._getBlockchainExplorer = function(network) {
};
/**
* _getUtxos
*
* Returns list of UTXOs
*/
WalletService.prototype._getUtxos = function(cb) {
WalletService.prototype.getUtxos = function(cb) {
var self = this;
@ -735,7 +734,7 @@ WalletService.prototype._computeKbToSendMax = function(utxos, amount, cb) {
WalletService.prototype.getBalance = function(opts, cb) {
var self = this;
self._getUtxos(function(err, utxos) {
self.getUtxos(function(err, utxos) {
if (err) return cb(err);
var balance = self._totalizeUtxos(utxos);
@ -867,7 +866,7 @@ WalletService.prototype._selectTxInputs = function(txp, cb) {
return _.pluck(_.sortBy(list, 'order'), 'utxo');
};
self._getUtxos(function(err, utxos) {
self.getUtxos(function(err, utxos) {
if (err) return cb(err);
var balance = self._totalizeUtxos(utxos);