hodl-wallet 1.3.4 → 1.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.mjs +24 -8
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -127,19 +127,35 @@ class Wallet {
127
127
  }
128
128
 
129
129
  if (accountAction === 'Create New Account') {
130
- const mnemonic = bip39.generateMnemonic();
131
- const seed = await bip39.mnemonicToSeed(mnemonic);
132
- const root = hdkey.fromMasterSeed(seed);
133
- const addrNode = root.derive("m/44'/60'/0'/0/0");
134
- const privateKey = addrNode.privateKey.toString('hex');
135
- this.account = this.web3.eth.accounts.privateKeyToAccount('0x' + privateKey);
136
- this.account.mnemonic = mnemonic;
130
+ const { createWithMnemonic } = await inquirer.prompt({
131
+ type: 'confirm',
132
+ name: 'createWithMnemonic',
133
+ message: 'Create account with mnemonic?',
134
+ default: true
135
+ });
136
+
137
+ let message = 'Do you want to display sensitive information (private key';
138
+ if (createWithMnemonic) {
139
+ const mnemonic = bip39.generateMnemonic();
140
+ const seed = await bip39.mnemonicToSeed(mnemonic);
141
+ const root = hdkey.fromMasterSeed(seed);
142
+ const addrNode = root.derive("m/44'/60'/0'/0/0");
143
+ const privateKey = addrNode.privateKey.toString('hex');
144
+ this.account = this.web3.eth.accounts.privateKeyToAccount('0x' + privateKey);
145
+ this.account.mnemonic = mnemonic;
146
+ message += ' and mnemonic';
147
+ } else {
148
+ this.account = this.web3.eth.accounts.create();
149
+ }
150
+
151
+ message += ')?';
152
+
137
153
  await this.db.secureSet('account', this.account);
138
154
 
139
155
  const { showSensitive } = await inquirer.prompt({
140
156
  type: 'confirm',
141
157
  name: 'showSensitive',
142
- message: 'Do you want to display sensitive information (private key and mnemonic)?',
158
+ message,
143
159
  default: false,
144
160
  });
145
161
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hodl-wallet",
3
- "version": "1.3.4",
3
+ "version": "1.3.6",
4
4
  "description": "🧊 HODL Wallet - Fast CLI crypto wallet!",
5
5
  "author": "Martin Clasen",
6
6
  "repository": {