Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 42 additions & 3 deletions bin/bwallet-cli
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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.');
Expand Down
60 changes: 60 additions & 0 deletions lib/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down