add client api for history

This commit is contained in:
Ivan Socolsky 2015-02-22 00:12:05 -03:00
parent d2a1c668a4
commit 036cc88ba8
3 changed files with 31 additions and 1 deletions

View File

@ -768,4 +768,20 @@ API.prototype.removeTxProposal = function(txp, cb) {
});
};
API.prototype.getTxHistory = function(opts, cb) {
var self = this;
this._loadAndCheck(function(err, data) {
if (err) return cb(err);
var url = '/v1/txhistory/';
self._doGetRequest(url, data, function(err, txs) {
if (err) return cb(err);
_processTxps(txs, data.sharedEncryptingKey);
return cb(null, txs);
});
});
};
module.exports = API;

View File

@ -263,6 +263,17 @@ ExpressApp.start = function(opts) {
});
});
router.get('/v1/txhistory/', function(req, res) {
getServerWithAuth(req, res, function(server) {
server.getTxHistory({}, function(err, txs) {
if (err) return returnError(err, res, req);
res.json(txs);
});
});
});
// TODO: DEBUG only!
router.get('/v1/dump', function(req, res) {
var server = WalletService.getInstance();

View File

@ -945,7 +945,9 @@ WalletService.prototype.getTxHistory = function(opts, cb) {
});
};
function paginate(txs) {
// TODO
};
// Get addresses for this wallet
self.storage.fetchAddresses(self.walletId, function(err, addresses) {
@ -978,6 +980,7 @@ WalletService.prototype.getTxHistory = function(opts, cb) {
var txs = res[1];
decorate(txs, addresses, proposals);
paginate(txs);
return cb(null, txs);
});