From 4fab249ead5fff91c6dd650f26f8cf1f7606234b Mon Sep 17 00:00:00 2001 From: Javed Khan Date: Wed, 18 Jul 2018 19:08:52 +0530 Subject: [PATCH] bwallet: add admin command - fee --- bin/bwallet-cli | 16 ++++++++++++++++ lib/wallet.js | 19 +++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/bin/bwallet-cli b/bin/bwallet-cli index 03efd1e..49c2645 100755 --- a/bin/bwallet-cli +++ b/bin/bwallet-cli @@ -479,6 +479,18 @@ class CLI { this.log(result); } + async fee() { + const rate = parseFloat(this.argv.shift()); + let result; + if (!rate) { + result = await this.client.getFee(); + } else { + result = await this.client.setFee(rate); + } + + this.log(result); + } + async handleWallet() { switch (this.argv.shift()) { case 'listen': @@ -666,6 +678,9 @@ class CLI { case 'rpc': await this.rpc(); break; + case 'fee': + await this.fee(); + break; default: this.log('Unrecognized command.'); this.log('Commands:'); @@ -674,6 +689,7 @@ class CLI { this.log(' $ resend: Resend pending transactions.'); this.log(' $ backup [path]: Backup the wallet db.'); this.log(' $ rpc [command] [args]: Execute RPC command.'); + this.log(' $ fee [rate?]: Get/Set fee rate.'); break; } return; diff --git a/lib/wallet.js b/lib/wallet.js index 29bcdf2..626ae02 100644 --- a/lib/wallet.js +++ b/lib/wallet.js @@ -190,6 +190,25 @@ class WalletClient extends Client { return this.get('/wallet'); } + /* + * Get fee rate + * @returns {Promise} + */ + + getFee() { + return this.get('/fee'); + } + + /* + * Set fee rate + * @param {Number} Fee rate + * @returns {Promise} + */ + + setFee(rate) { + return this.post('/fee', { rate }); + } + /** * Create a wallet. * @param {Object} options