clean up.

This commit is contained in:
Chris Kleeschulte 2017-01-11 19:03:44 -05:00
parent e6d569620b
commit 44cb188c61

View File

@ -14,15 +14,7 @@ var storage = multer.memoryStorage();
var upload = multer({ storage: storage });
var validators = require('./validators');
var utils = require('./utils');
/**
* The Address Service builds upon the Database Service and the Bitcoin Service to add additional
* functionality for getting information by base58check encoded addresses. This includes getting the
* balance for an address, the history for a collection of addresses, and unspent outputs for
* constructing transactions. This is typically the core functionality for building a wallet.
* @param {Object} options
* @param {Node} options.node - An instance of the node
* @param {String} options.name - An optional name of the service
*/
var WalletService = function(options) {
BaseService.call(this, options);
this._dbOptions = {
@ -39,23 +31,8 @@ WalletService.dependencies = [
'web'
];
/**
* Called by the Node to get the available API methods for this service,
* that can be exposed over the JSON-RPC interface.
*/
WalletService.prototype.getAPIMethods = function() {
return [
//['getWalletInfo', this, this.getInfo, 0]
//['getWalletBalance', this, this.getWalletBalance, 2],
//['getBlockTimestampInfo', this, this.getBlockTimestampInfo, 2],
//['addWalletAddresses', this, this., 2],
//['addWalletAddress', this, this.addWalletAddress, 2],
//['addWallet', this, this.addWallet, 2],
//['getWalletUtxos', this, this.getWalletUtxos, 2],
//['getWalletRawTransactions', this, this.getWalletRawTransactions, 1]
//['getWalletTxids', this, this.getWalletTxids, 1]
//['getWalletTransactions', this, this.getWalletTransactions, 1]
];
return [];
};
WalletService.prototype.start = function(callback) {
setImmediate(callback);
@ -65,9 +42,6 @@ WalletService.prototype.stop = function(callback) {
setImmediate(callback);
};
/**
* Called by the Bus to get the available events for this service.
*/
WalletService.prototype.getPublishEvents = function() {
return [];
};
@ -127,6 +101,7 @@ WalletService.prototype._endpointGetAddresses = function() {
});
};
};
WalletService.prototype._endpointPostAddresses = function() {
var self = this;
return function(req, res) {
@ -154,6 +129,7 @@ WalletService.prototype._getUtxos = function(walletId, height, callback) {
self.node.services.bitcoind.getAddressUnspentOutputs(addresses, {queryMempool: false}, callback);
});
};
WalletService.prototype._getBalance = function(walletId, height, callback) {
// TODO get the balance only to this height
var self = this;
@ -175,9 +151,11 @@ WalletService.prototype._getBalance = function(walletId, height, callback) {
});
});
};
WalletService.prototype._getAddresses = function(walletId, callback) {
this._db.get(walletId, callback);
};
WalletService.prototype._storeAddresses = function(walletId, addresses, callback) {
this._db.put(walletId, addresses, callback);
};
@ -193,21 +171,6 @@ WalletService.prototype.setupRoutes = function(app, express) {
app.get('/info',
s._endpointGetInfo()
);
//app.get('/wallets/:walletId/txids',
// v.checkWalletId,
// v.checkRangeParams,
// s._endpointTxids()
//);
//app.get('/wallets/:walletId/transactions',
// v.checkWalletId,
// v.checkRangeParams,
// s._endpointTransactions()
//);
//app.get('/wallets/:walletId/rawtransactions',
// v.checkWalletId,
// v.checkRangeParams,
// s._endpointRawTransactions()
//);
app.get('/wallets/:walletId/utxos',
s._endpointUTXOs()
);
@ -222,21 +185,11 @@ WalletService.prototype.setupRoutes = function(app, express) {
v.checkAddresses,
s._endpointPostAddresses()
);
//app.put('/wallets/:walletId',
// v.checkWalletId,
// s._endpointPutWallet()
//);
//app.get('/info/timestamps',
// s._endpointGetHeightsFromTimestamps()
//);
//app.get('/jobs/:jobId',
// s._endpointJobStatus()
//);
//app.use(s._endpointNotFound());
};
WalletService.prototype.getRoutePrefix = function() {
return 'wallet';
return 'bws';
};
module.exports = WalletService;