server: add get wallets call.
This commit is contained in:
parent
b38d859382
commit
37f8d45c25
8
bin/cli
8
bin/cli
@ -33,6 +33,11 @@ CLI.prototype.getInfo = co(function* getInfo() {
|
||||
this.log(info);
|
||||
});
|
||||
|
||||
CLI.prototype.getWallets = co(function* getWallets() {
|
||||
var wallets = yield this.client.getWallets();
|
||||
this.log(wallets);
|
||||
});
|
||||
|
||||
CLI.prototype.createWallet = co(function* createWallet() {
|
||||
var options = { id: this.argv[0] };
|
||||
var wallet;
|
||||
@ -613,6 +618,8 @@ CLI.prototype.handleNode = co(function* handleNode() {
|
||||
switch (this.argv.shift()) {
|
||||
case 'info':
|
||||
return yield this.getInfo();
|
||||
case 'wallets':
|
||||
return yield this.getWallets();
|
||||
case 'mkwallet':
|
||||
return yield this.createWallet();
|
||||
case 'broadcast':
|
||||
@ -639,6 +646,7 @@ CLI.prototype.handleNode = co(function* handleNode() {
|
||||
this.log('Unrecognized command.');
|
||||
this.log('Commands:');
|
||||
this.log(' $ info: Get server info.');
|
||||
this.log(' $ wallets: List all wallets.');
|
||||
this.log(' $ wallet create [id]: Create wallet.');
|
||||
this.log(' $ broadcast [tx-hex]: Broadcast transaction.');
|
||||
this.log(' $ mempool: Get mempool snapshot.');
|
||||
|
||||
@ -460,8 +460,16 @@ HTTPClient.prototype.none = function none() {
|
||||
};
|
||||
|
||||
/**
|
||||
* Request the raw wallet JSON (will create wallet if it does not exist).
|
||||
* @private
|
||||
* Get list of all wallet IDs.
|
||||
* @returns {Promise}
|
||||
*/
|
||||
|
||||
HTTPClient.prototype.getWallets = function getWallets() {
|
||||
return this._get('/wallets');
|
||||
};
|
||||
|
||||
/**
|
||||
* Create a wallet.
|
||||
* @param {Object} options - See {@link Wallet}.
|
||||
* @returns {Promise}
|
||||
*/
|
||||
@ -472,7 +480,6 @@ HTTPClient.prototype.createWallet = function createWallet(options) {
|
||||
|
||||
/**
|
||||
* Get the raw wallet JSON.
|
||||
* @private
|
||||
* @param {WalletID} id
|
||||
* @returns {Promise}
|
||||
*/
|
||||
|
||||
@ -835,6 +835,12 @@ HTTPServer.prototype._init = function _init() {
|
||||
send(200, { success: true });
|
||||
}));
|
||||
|
||||
// List wallets
|
||||
this.get('/wallets', con(function* (req, res, send, next) {
|
||||
var wallets = yield this.walletdb.getWallets();
|
||||
send(200, wallets);
|
||||
}));
|
||||
|
||||
// Get wallet
|
||||
this.get('/wallet/:id', function(req, res, send, next) {
|
||||
send(200, req.wallet.toJSON());
|
||||
|
||||
Loading…
Reference in New Issue
Block a user