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.
- package/index.mjs +24 -8
- 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
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
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
|
|
158
|
+
message,
|
|
143
159
|
default: false,
|
|
144
160
|
});
|
|
145
161
|
|