diff --git a/bin/bwallet-cli b/bin/bwallet-cli index 03efd1e..b5b708c 100755 --- a/bin/bwallet-cli +++ b/bin/bwallet-cli @@ -189,6 +189,33 @@ class CLI { this.log(addr); } + async deriveReceive() { + const account = this.config.str([0, 'account']); + const index = this.config.uint([1, 'index']); + const force = this.config.bool([2, 'force']); + const addr = await this.wallet.deriveReceive(account, index, force); + + this.log(addr); + } + + async deriveChange() { + const account = this.config.str([0, 'account']); + const index = this.config.uint([1, 'index']); + const force = this.config.bool([2, 'force']); + const addr = await this.wallet.deriveChange(account, index, force); + + this.log(addr); + } + + async deriveNested() { + const account = this.config.str([0, 'account']); + const index = this.config.uint([1, 'index']); + const force = this.config.bool([2, 'force']); + const addr = await this.wallet.deriveNested(account, index, force); + + this.log(addr); + } + async getAccounts() { const accounts = await this.wallet.getAccounts(); this.log(accounts); @@ -541,6 +568,15 @@ class CLI { case 'nested': await this.createNested(); break; + case 'derivereceive': + await this.deriveReceive(); + break; + case 'derivechange': + await this.deriveChange(); + break; + case 'derivenested': + await this.deriveNested(); + break; case 'retoken': await this.retoken(); break; @@ -607,9 +643,12 @@ class CLI { this.log(' $ account list: List account names.'); this.log(' $ account create [account-name]: Create account.'); this.log(' $ account get [account-name]: Get account details.'); - this.log(' $ address: Derive new address.'); - this.log(' $ change: Derive new change address.'); - this.log(' $ nested: Derive new nested address.'); + this.log(' $ address: Create new address.'); + this.log(' $ change: Create new change address.'); + this.log(' $ nested: Create new nested address.'); + this.log(' $ derivereceive: Derive receive address.'); + this.log(' $ derivechange: Derive change address.'); + this.log(' $ derivenested: Derive nested address.'); this.log(' $ retoken: Create new api key.'); this.log(' $ send [address] [value]: Send transaction.'); this.log(' $ mktx [address] [value]: Create transaction.'); diff --git a/lib/wallet.js b/lib/wallet.js index b146b68..ad6f966 100644 --- a/lib/wallet.js +++ b/lib/wallet.js @@ -435,6 +435,36 @@ class WalletClient extends Client { return this.post(`/wallet/${id}/nested`, { account }); } + /** + * Derive receive address. + * @param {Object} options + * @returns {Promise} + */ + + deriveReceive(id, account, index, force) { + return this.get(`/wallet/${id}/address`, { account, index, force }); + } + + /** + * Derive change address. + * @param {Object} options + * @returns {Promise} + */ + + deriveChange(id, account, index, force) { + return this.get(`/wallet/${id}/change`, { account, index, force }); + } + + /** + * Derive nested address. + * @param {Object} options + * @returns {Promise} + */ + + deriveNested(id, account, index, force) { + return this.get(`/wallet/${id}/nested`, { account, index, force }); + } + /** * Change or set master key`s passphrase. * @param {String|Buffer} passphrase @@ -871,6 +901,36 @@ class Wallet extends EventEmitter { return this.client.createNested(this.id, account); } + /** + * Derive address. + * @param {Object} options + * @returns {Promise} + */ + + deriveReceive(account, index, force ) { + return this.client.deriveReceive(this.id, account, index, force); + } + + /** + * Derive change address. + * @param {Object} options + * @returns {Promise} + */ + + deriveChange(account, index, force) { + return this.client.deriveChange(this.id, account, index, force); + } + + /** + * Derive nested address. + * @param {Object} options + * @returns {Promise} + */ + + deriveNested(account, index, force) { + return this.client.deriveNested(this.id, account, index, force); + } + /** * Change or set master key`s passphrase. * @param {String|Buffer} passphrase