clean up.
This commit is contained in:
parent
e6d569620b
commit
44cb188c61
@ -14,15 +14,7 @@ var storage = multer.memoryStorage();
|
|||||||
var upload = multer({ storage: storage });
|
var upload = multer({ storage: storage });
|
||||||
var validators = require('./validators');
|
var validators = require('./validators');
|
||||||
var utils = require('./utils');
|
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) {
|
var WalletService = function(options) {
|
||||||
BaseService.call(this, options);
|
BaseService.call(this, options);
|
||||||
this._dbOptions = {
|
this._dbOptions = {
|
||||||
@ -39,23 +31,8 @@ WalletService.dependencies = [
|
|||||||
'web'
|
'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() {
|
WalletService.prototype.getAPIMethods = function() {
|
||||||
return [
|
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]
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
WalletService.prototype.start = function(callback) {
|
WalletService.prototype.start = function(callback) {
|
||||||
setImmediate(callback);
|
setImmediate(callback);
|
||||||
@ -65,9 +42,6 @@ WalletService.prototype.stop = function(callback) {
|
|||||||
setImmediate(callback);
|
setImmediate(callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Called by the Bus to get the available events for this service.
|
|
||||||
*/
|
|
||||||
WalletService.prototype.getPublishEvents = function() {
|
WalletService.prototype.getPublishEvents = function() {
|
||||||
return [];
|
return [];
|
||||||
};
|
};
|
||||||
@ -127,6 +101,7 @@ WalletService.prototype._endpointGetAddresses = function() {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
WalletService.prototype._endpointPostAddresses = function() {
|
WalletService.prototype._endpointPostAddresses = function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
return function(req, res) {
|
return function(req, res) {
|
||||||
@ -154,6 +129,7 @@ WalletService.prototype._getUtxos = function(walletId, height, callback) {
|
|||||||
self.node.services.bitcoind.getAddressUnspentOutputs(addresses, {queryMempool: false}, callback);
|
self.node.services.bitcoind.getAddressUnspentOutputs(addresses, {queryMempool: false}, callback);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
WalletService.prototype._getBalance = function(walletId, height, callback) {
|
WalletService.prototype._getBalance = function(walletId, height, callback) {
|
||||||
// TODO get the balance only to this height
|
// TODO get the balance only to this height
|
||||||
var self = this;
|
var self = this;
|
||||||
@ -175,9 +151,11 @@ WalletService.prototype._getBalance = function(walletId, height, callback) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
WalletService.prototype._getAddresses = function(walletId, callback) {
|
WalletService.prototype._getAddresses = function(walletId, callback) {
|
||||||
this._db.get(walletId, callback);
|
this._db.get(walletId, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
WalletService.prototype._storeAddresses = function(walletId, addresses, callback) {
|
WalletService.prototype._storeAddresses = function(walletId, addresses, callback) {
|
||||||
this._db.put(walletId, addresses, callback);
|
this._db.put(walletId, addresses, callback);
|
||||||
};
|
};
|
||||||
@ -193,21 +171,6 @@ WalletService.prototype.setupRoutes = function(app, express) {
|
|||||||
app.get('/info',
|
app.get('/info',
|
||||||
s._endpointGetInfo()
|
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',
|
app.get('/wallets/:walletId/utxos',
|
||||||
s._endpointUTXOs()
|
s._endpointUTXOs()
|
||||||
);
|
);
|
||||||
@ -222,21 +185,11 @@ WalletService.prototype.setupRoutes = function(app, express) {
|
|||||||
v.checkAddresses,
|
v.checkAddresses,
|
||||||
s._endpointPostAddresses()
|
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() {
|
WalletService.prototype.getRoutePrefix = function() {
|
||||||
return 'wallet';
|
return 'bws';
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = WalletService;
|
module.exports = WalletService;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user