From 55f3a46b7791091302df3cdec9032815a24bcccb Mon Sep 17 00:00:00 2001 From: Kosta Korenkov <7r0ggy@gmail.com> Date: Sat, 18 Jul 2015 12:10:49 +0300 Subject: [PATCH] Expose getUtxos to public --- lib/expressapp.js | 9 +++++++++ lib/server.js | 9 ++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/expressapp.js b/lib/expressapp.js index f35bef1..56a1c2a 100644 --- a/lib/expressapp.js +++ b/lib/expressapp.js @@ -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']; diff --git a/lib/server.js b/lib/server.js index 2865266..b604010 100644 --- a/lib/server.js +++ b/lib/server.js @@ -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);