@yerofey/cryptowallet-cli 1.2.11 → 1.2.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yerofey/cryptowallet-cli",
3
- "version": "1.2.11",
3
+ "version": "1.2.12",
4
4
  "homepage": "https://github.com/yerofey/cryptowallet-cli",
5
5
  "author": "Yerofey S. <pm@yerofey.dev> (https://github.com/yerofey)",
6
6
  "bin": {
@@ -61,19 +61,19 @@
61
61
  "@yerofey/dogecoin-bip84": "^0.0.5",
62
62
  "@yerofey/litecoin-bip84": "^0.0.5",
63
63
  "bip39": "3.0.4",
64
- "bip84": "^0.2.6",
64
+ "bip84": "0.2.6",
65
65
  "chalk": "4.1.2",
66
66
  "coininfo": "5.1.0",
67
67
  "coinkey": "3.0.0",
68
68
  "columnify": "1.5.4",
69
69
  "commander": "8.1.0",
70
70
  "eth-lib": "0.1.29",
71
+ "ethereum-bip84": "0.0.3",
71
72
  "ethereum-mnemonic-privatekey-utils": "1.0.5",
72
73
  "tezos-sign": "1.4.1",
73
74
  "tronweb": "4.0.0"
74
75
  },
75
76
  "devDependencies": {
76
- "ava": "^3.15.0",
77
- "ethereum-bip84": "0.0.2"
77
+ "ava": "^3.15.0"
78
78
  }
79
79
  }
package/src/Wallet.js CHANGED
@@ -169,19 +169,36 @@ class Wallet {
169
169
  }
170
170
  }
171
171
 
172
+ let addresses = [];
172
173
  const mnemonic = mnemonicString || bip39.generateMnemonic();
173
- const privateKey = bCrypto.getPrivateKeyFromMnemonic(mnemonic, true, 0);
174
-
174
+
175
+ if (number == 1) {
176
+ const privateKey = bCrypto.getPrivateKeyFromMnemonic(mnemonic, true, 0);
177
+ addresses.push({
178
+ address: bCrypto.getAddressFromPrivateKey(privateKey, 'bnb'),
179
+ privateKey
180
+ });
181
+ } else {
182
+ for (let i = 0; i <= number; i++) {
183
+ const privateKey = bCrypto.getPrivateKeyFromMnemonic(mnemonic, true, i);
184
+ addresses.push({
185
+ index: i,
186
+ address: bCrypto.getAddressFromPrivateKey(privateKey, 'bnb'),
187
+ privateKey
188
+ });
189
+ }
190
+ }
191
+
175
192
  Object.assign(result, {
176
193
  format: 'BEP2',
177
- address: bCrypto.getAddressFromPrivateKey(privateKey, 'bnb'),
178
- privateKey,
194
+ addresses,
179
195
  mnemonic
180
196
  });
181
197
  } else if (row.network == 'EVM') {
182
198
  const bip39 = require('bip39');
183
199
  const pkutils = require('ethereum-mnemonic-privatekey-utils');
184
200
  const { Account } = require('eth-lib/lib');
201
+ const { fromMnemonic, fromZPrv } = require('ethereum-bip84');
185
202
 
186
203
  if (mnemonicString != '' && !bip39.validateMnemonic(mnemonicString)) {
187
204
  return {
@@ -189,14 +206,37 @@ class Wallet {
189
206
  }
190
207
  }
191
208
 
209
+ let addresses = [];
192
210
  const mnemonic = mnemonicString || bip39.generateMnemonic();
193
211
  const privateKey = pkutils.getPrivateKeyFromMnemonic(mnemonic);
194
- const account = Account.fromPrivate('0x' + privateKey);
195
-
212
+
213
+ if (number == 1) {
214
+ const account = Account.fromPrivate('0x' + privateKey);
215
+
216
+ addresses.push({
217
+ address: account.address,
218
+ privateKey
219
+ });
220
+ } else {
221
+ // TODO: add variable for accountId
222
+ const root = new fromMnemonic(mnemonic, '');
223
+ const child = root.deriveAccount(0);
224
+ const account = new fromZPrv(child);
225
+ for (let walletId = 0; walletId <= number; walletId++) {
226
+ const walletAddress = account.getAddress(walletId);
227
+ const privateKey = account.getPrivateKey(walletId);
228
+
229
+ addresses.push({
230
+ index: walletId,
231
+ address: walletAddress,
232
+ privateKey
233
+ });
234
+ }
235
+ }
236
+
196
237
  Object.assign(result, {
197
238
  format: row.format || '',
198
- address: account.address,
199
- privateKey: privateKey,
239
+ addresses,
200
240
  mnemonic
201
241
  });
202
242
  } else if (coin == 'ONE') {
@@ -14,6 +14,7 @@
14
14
  "flags": [
15
15
  "f",
16
16
  "m",
17
+ "n",
17
18
  "p"
18
19
  ]
19
20
  },
@@ -30,6 +31,7 @@
30
31
  "flags": [
31
32
  "f",
32
33
  "m",
34
+ "n",
33
35
  "p"
34
36
  ]
35
37
  },
@@ -46,6 +48,7 @@
46
48
  "flags": [
47
49
  "f",
48
50
  "m",
51
+ "n",
49
52
  "p"
50
53
  ]
51
54
  }
@@ -10,6 +10,7 @@
10
10
  ],
11
11
  "flags": [
12
12
  "m",
13
+ "n",
13
14
  "p"
14
15
  ]
15
16
  }
@@ -13,6 +13,7 @@
13
13
  ],
14
14
  "flags": [
15
15
  "m",
16
+ "n",
16
17
  "p"
17
18
  ]
18
19
  }
@@ -9,6 +9,7 @@
9
9
  ],
10
10
  "flags": [
11
11
  "m",
12
+ "n",
12
13
  "p"
13
14
  ]
14
15
  }
@@ -9,6 +9,7 @@
9
9
  ],
10
10
  "flags": [
11
11
  "m",
12
+ "n",
12
13
  "p"
13
14
  ]
14
15
  }