@yerofey/cryptowallet-cli 1.2.9 → 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.9",
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": {
@@ -58,19 +58,20 @@
58
58
  "dependencies": {
59
59
  "@binance-chain/javascript-sdk": "^4.1.1",
60
60
  "@harmony-js/account": "^0.1.57",
61
- "bip39": "^3.0.4",
62
- "bip84": "^0.2.5",
63
- "chalk": "^4.1.2",
64
- "coininfo": "^5.1.0",
65
- "coinkey": "^3.0.0",
66
- "columnify": "^1.5.4",
67
- "commander": "^8.1.0",
68
- "dogecoin-bip84": "^0.0.4",
69
- "eth-lib": "^0.1.29",
70
- "ethereum-mnemonic-privatekey-utils": "^1.0.5",
71
- "litecoin-bip84": "^0.0.1",
72
- "tezos-sign": "^1.4.1",
73
- "tronweb": "^4.0.0"
61
+ "@yerofey/dogecoin-bip84": "^0.0.5",
62
+ "@yerofey/litecoin-bip84": "^0.0.5",
63
+ "bip39": "3.0.4",
64
+ "bip84": "0.2.6",
65
+ "chalk": "4.1.2",
66
+ "coininfo": "5.1.0",
67
+ "coinkey": "3.0.0",
68
+ "columnify": "1.5.4",
69
+ "commander": "8.1.0",
70
+ "eth-lib": "0.1.29",
71
+ "ethereum-bip84": "0.0.3",
72
+ "ethereum-mnemonic-privatekey-utils": "1.0.5",
73
+ "tezos-sign": "1.4.1",
74
+ "tronweb": "4.0.0"
74
75
  },
75
76
  "devDependencies": {
76
77
  "ava": "^3.15.0"
package/src/Wallet.js CHANGED
@@ -97,7 +97,7 @@ class Wallet {
97
97
  });
98
98
  } else if (coin == 'BTC') {
99
99
  const bip39 = require('bip39');
100
- const bip84 = require('bip84');
100
+ const { fromMnemonic, fromZPrv } = require('bip84');
101
101
 
102
102
  if (mnemonicString != '' && !bip39.validateMnemonic(mnemonicString)) {
103
103
  return {
@@ -106,9 +106,9 @@ class Wallet {
106
106
  }
107
107
 
108
108
  const mnemonic = mnemonicString || bip39.generateMnemonic();
109
- const root = new bip84.fromSeed(mnemonic);
109
+ const root = new fromMnemonic(mnemonic, '');
110
110
  const child = root.deriveAccount(0);
111
- const account = new bip84.fromZPrv(child);
111
+ const account = new fromZPrv(child);
112
112
 
113
113
  let addresses = [];
114
114
  if (number >= 1) {
@@ -129,7 +129,7 @@ class Wallet {
129
129
  });
130
130
  } else if (coin == 'DOGE' || coin == 'LTC') {
131
131
  const bip39 = require('bip39');
132
- const bip84 = require(row.title.toLowerCase() + '-bip84');
132
+ const { fromMnemonic, fromZPrv } = require('@yerofey/' + row.title.toLowerCase() + '-bip84');
133
133
 
134
134
  if (mnemonicString != '' && !bip39.validateMnemonic(mnemonicString)) {
135
135
  return {
@@ -138,9 +138,9 @@ class Wallet {
138
138
  }
139
139
 
140
140
  const mnemonic = mnemonicString || bip39.generateMnemonic();
141
- const root = new bip84.fromMnemonic(mnemonic, '');
141
+ const root = new fromMnemonic(mnemonic, '');
142
142
  const child = root.deriveAccount(0);
143
- const account = new bip84.fromZPrv(child);
143
+ const account = new fromZPrv(child);
144
144
 
145
145
  let addresses = [];
146
146
  if (number >= 1) {
@@ -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
  },
@@ -21,7 +22,7 @@
21
22
  "format": "BEP20",
22
23
  "network": "EVM",
23
24
  "startsWith": "0x",
24
- "prefixTest": "[0-9a-f]",
25
+ "prefixTest": "[0-9a-fA-F]",
25
26
  "apps": [
26
27
  "metamask",
27
28
  "trustwallet",
@@ -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
  }
@@ -2,7 +2,7 @@
2
2
  "name": "ERC-like",
3
3
  "network": "EVM",
4
4
  "startsWith": "0x",
5
- "prefixTest": "[0-9a-f]",
5
+ "prefixTest": "[0-9a-fA-F]",
6
6
  "apps": [
7
7
  "metamask",
8
8
  "trustwallet",
@@ -10,6 +10,7 @@
10
10
  ],
11
11
  "flags": [
12
12
  "m",
13
+ "n",
13
14
  "p"
14
15
  ]
15
16
  }
@@ -6,13 +6,14 @@
6
6
  "format": "ERC20",
7
7
  "network": "EVM",
8
8
  "startsWith": "0x",
9
- "prefixTest": "[0-9a-f]",
9
+ "prefixTest": "[0-9a-fA-F]",
10
10
  "apps": [
11
11
  "metamask",
12
12
  "trustwallet"
13
13
  ],
14
14
  "flags": [
15
15
  "m",
16
+ "n",
16
17
  "p"
17
18
  ]
18
19
  }
@@ -2,13 +2,14 @@
2
2
  "title": "Ethereum",
3
3
  "network": "EVM",
4
4
  "startsWith": "0x",
5
- "prefixTest": "[0-9a-f]",
5
+ "prefixTest": "[0-9a-fA-F]",
6
6
  "apps": [
7
7
  "metamask",
8
8
  "trustwallet"
9
9
  ],
10
10
  "flags": [
11
11
  "m",
12
+ "n",
12
13
  "p"
13
14
  ]
14
15
  }
@@ -2,13 +2,14 @@
2
2
  "title": "Polygon",
3
3
  "network": "EVM",
4
4
  "startsWith": "0x",
5
- "prefixTest": "[0-9a-f]",
5
+ "prefixTest": "[0-9a-fA-F]",
6
6
  "apps": [
7
7
  "metamask",
8
8
  "trustwallet"
9
9
  ],
10
10
  "flags": [
11
11
  "m",
12
+ "n",
12
13
  "p"
13
14
  ]
14
15
  }