@yerofey/cryptowallet-cli 1.18.0 → 1.18.2
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 +2 -1
- package/src/Method.js +102 -40
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yerofey/cryptowallet-cli",
|
|
3
|
-
"version": "1.18.
|
|
3
|
+
"version": "1.18.2",
|
|
4
4
|
"description": "Crypto wallet generator CLI tool",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"homepage": "https://github.com/yerofey/cryptowallet-cli",
|
|
@@ -119,6 +119,7 @@
|
|
|
119
119
|
"columnify": "1.6.0",
|
|
120
120
|
"commander": "11.1.0",
|
|
121
121
|
"csv-writer": "^1.6.0",
|
|
122
|
+
"dotenv": "^16.4.1",
|
|
122
123
|
"eth-lib": "0.1.29",
|
|
123
124
|
"ethereum-bip84": "0.0.3",
|
|
124
125
|
"ethereum-mnemonic-privatekey-utils": "1.0.5",
|
package/src/Method.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { config } from 'dotenv';
|
|
1
2
|
import path from 'node:path';
|
|
2
3
|
import chalk from 'chalk';
|
|
3
4
|
import columnify from 'columnify';
|
|
@@ -6,9 +7,10 @@ import { log, supportedChains, loadJson } from './utils.js';
|
|
|
6
7
|
import { generateMnemonicString } from './Wallet.js';
|
|
7
8
|
import CW from './CW.js';
|
|
8
9
|
|
|
10
|
+
config();
|
|
9
11
|
const { blue, green, blueBright, greenBright, yellow, red, magenta, white } =
|
|
10
12
|
chalk;
|
|
11
|
-
|
|
13
|
+
const IS_DEV = process.env.NODE_ENV === 'development' || false;
|
|
12
14
|
const pkg = await loadJson(
|
|
13
15
|
`${path.dirname(import.meta.url)}/../package.json`.replace('file://', '')
|
|
14
16
|
);
|
|
@@ -93,7 +95,7 @@ class Method {
|
|
|
93
95
|
|
|
94
96
|
const cw = await new CW(chain, options).init();
|
|
95
97
|
|
|
96
|
-
const startsWithSymbols = cw.row.startsWith.split('|') || [];
|
|
98
|
+
const startsWithSymbols = cw.row.startsWith.split('|') || [''];
|
|
97
99
|
|
|
98
100
|
let chainFullName =
|
|
99
101
|
(cw.row.name || chain) +
|
|
@@ -193,8 +195,9 @@ class Method {
|
|
|
193
195
|
log(`📄 ${cw.wallet.mnemonic}`);
|
|
194
196
|
linesCount += 1;
|
|
195
197
|
}
|
|
196
|
-
|
|
198
|
+
|
|
197
199
|
if (displayAsText) {
|
|
200
|
+
// display addresses
|
|
198
201
|
for (const item of cw.wallet.addresses) {
|
|
199
202
|
if (cw.wallet.addresses.length > 1) {
|
|
200
203
|
log();
|
|
@@ -217,14 +220,23 @@ class Method {
|
|
|
217
220
|
cw.suffixFoundInWallets.includes(item.address)
|
|
218
221
|
) {
|
|
219
222
|
// highlight found prefix and suffix
|
|
220
|
-
const addressStartingSymbol =
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
const
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
223
|
+
const addressStartingSymbol =
|
|
224
|
+
startsWithSymbols.filter((symbol) =>
|
|
225
|
+
item.address.startsWith(symbol)
|
|
226
|
+
)[0] || '';
|
|
227
|
+
const addressCutPrefixLength = addressStartingSymbol.length || 0;
|
|
228
|
+
let addressHighlightedPart;
|
|
229
|
+
if (addressCutPrefixLength > 0) {
|
|
230
|
+
addressHighlightedPart = item.address.substring(
|
|
231
|
+
addressCutPrefixLength + cw.options.prefix.length,
|
|
232
|
+
cw.options.prefix.length
|
|
233
|
+
);
|
|
234
|
+
} else {
|
|
235
|
+
addressHighlightedPart = item.address.substring(
|
|
236
|
+
0,
|
|
237
|
+
cw.options.prefix.length
|
|
238
|
+
);
|
|
239
|
+
}
|
|
228
240
|
const addressLastPart = item.address.slice(
|
|
229
241
|
cw.options.prefix.length + addressCutPrefixLength,
|
|
230
242
|
item.address.length - cw.options.suffix.length
|
|
@@ -232,45 +244,94 @@ class Method {
|
|
|
232
244
|
const addressHighlightedSuffix = item.address.slice(
|
|
233
245
|
item.address.length - cw.options.suffix.length
|
|
234
246
|
);
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
247
|
+
const fullAddressLength =
|
|
248
|
+
addressStartingSymbol.length +
|
|
249
|
+
addressHighlightedPart.length +
|
|
250
|
+
addressLastPart.length +
|
|
251
|
+
addressHighlightedSuffix.length;
|
|
252
|
+
// show hightlighted address (only if it's length is the same as the original address length)
|
|
253
|
+
if (fullAddressLength == item.address.length || IS_DEV) {
|
|
254
|
+
log(
|
|
255
|
+
`👛 ${addressStartingSymbol}${magenta(
|
|
256
|
+
addressHighlightedPart
|
|
257
|
+
)}${addressLastPart}${magenta(addressHighlightedSuffix)}`
|
|
258
|
+
);
|
|
259
|
+
// DEBUG
|
|
260
|
+
if (IS_DEV) {
|
|
261
|
+
log(`___ ${item.address}`);
|
|
262
|
+
}
|
|
263
|
+
} else {
|
|
264
|
+
log(`👛 ${item.address}`);
|
|
265
|
+
}
|
|
240
266
|
} else if (
|
|
241
267
|
cw.prefixFound &&
|
|
242
268
|
cw.prefixFoundInWallets.includes(item.address)
|
|
243
269
|
) {
|
|
244
270
|
// highlight found prefix
|
|
245
|
-
const addressStartingSymbol =
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
const
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
271
|
+
const addressStartingSymbol =
|
|
272
|
+
startsWithSymbols.filter((symbol) =>
|
|
273
|
+
item.address.startsWith(symbol)
|
|
274
|
+
)[0] || '';
|
|
275
|
+
const addressCutPrefixLength = addressStartingSymbol.length || 0;
|
|
276
|
+
let addressHighlightedPart;
|
|
277
|
+
if (addressCutPrefixLength > 0) {
|
|
278
|
+
addressHighlightedPart = item.address.substring(
|
|
279
|
+
addressCutPrefixLength + cw.options.prefix.length,
|
|
280
|
+
cw.options.prefix.length
|
|
281
|
+
);
|
|
282
|
+
} else {
|
|
283
|
+
addressHighlightedPart = item.address.substring(
|
|
284
|
+
0,
|
|
285
|
+
cw.options.prefix.length
|
|
286
|
+
);
|
|
287
|
+
}
|
|
253
288
|
const addressLastPart = item.address.slice(
|
|
254
289
|
cw.options.prefix.length + addressCutPrefixLength
|
|
255
290
|
);
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
)
|
|
291
|
+
const fullAddressLength =
|
|
292
|
+
addressStartingSymbol.length +
|
|
293
|
+
addressHighlightedPart.length +
|
|
294
|
+
addressLastPart.length;
|
|
295
|
+
// show hightlighted address (only if it's length is the same as the original address length)
|
|
296
|
+
if (fullAddressLength == item.address.length || IS_DEV) {
|
|
297
|
+
log(
|
|
298
|
+
`👛 ${addressStartingSymbol}${magenta(
|
|
299
|
+
addressHighlightedPart
|
|
300
|
+
)}${addressLastPart}`
|
|
301
|
+
);
|
|
302
|
+
// DEBUG
|
|
303
|
+
if (IS_DEV) {
|
|
304
|
+
log(`___ ${item.address}`);
|
|
305
|
+
}
|
|
306
|
+
} else {
|
|
307
|
+
log(`👛 ${item.address}`);
|
|
308
|
+
}
|
|
261
309
|
} else if (
|
|
262
310
|
cw.suffixFound &&
|
|
263
311
|
cw.suffixFoundInWallets.includes(item.address)
|
|
264
312
|
) {
|
|
265
313
|
// highlight found suffix
|
|
266
|
-
const
|
|
314
|
+
const addressFirstPart = item.address.slice(
|
|
267
315
|
0,
|
|
268
316
|
item.address.length - cw.options.suffix.length
|
|
269
317
|
);
|
|
270
318
|
const addressHighlightedSuffix = item.address.slice(
|
|
271
319
|
item.address.length - cw.options.suffix.length
|
|
272
320
|
);
|
|
273
|
-
|
|
321
|
+
const fullAddressLength =
|
|
322
|
+
addressFirstPart.length + addressHighlightedSuffix.length;
|
|
323
|
+
// show hightlighted address (only if it's length is the same as the original address length)
|
|
324
|
+
if (fullAddressLength == item.address.length || IS_DEV) {
|
|
325
|
+
log(
|
|
326
|
+
`👛 ${addressFirstPart}${magenta(addressHighlightedSuffix)}`
|
|
327
|
+
);
|
|
328
|
+
// DEBUG
|
|
329
|
+
if (IS_DEV) {
|
|
330
|
+
log(`___ ${item.address}`);
|
|
331
|
+
}
|
|
332
|
+
} else {
|
|
333
|
+
log(`👛 ${item.address}`);
|
|
334
|
+
}
|
|
274
335
|
} else {
|
|
275
336
|
log(`👛 ${item.address}`);
|
|
276
337
|
}
|
|
@@ -278,6 +339,16 @@ class Method {
|
|
|
278
339
|
log(`🔑 ${item.privateKey}`);
|
|
279
340
|
}
|
|
280
341
|
}
|
|
342
|
+
|
|
343
|
+
// tested
|
|
344
|
+
if (cw.wallet.tested !== undefined && cw.wallet.tested == false) {
|
|
345
|
+
log();
|
|
346
|
+
log(
|
|
347
|
+
red(
|
|
348
|
+
'‼️ This wallet generation method is not tested yet, use it at your own risk'
|
|
349
|
+
)
|
|
350
|
+
);
|
|
351
|
+
}
|
|
281
352
|
} else {
|
|
282
353
|
outputData.wallets = cw.wallet.addresses;
|
|
283
354
|
}
|
|
@@ -356,15 +427,6 @@ class Method {
|
|
|
356
427
|
log();
|
|
357
428
|
}
|
|
358
429
|
|
|
359
|
-
// tested
|
|
360
|
-
if (cw.wallet.tested !== undefined && cw.wallet.tested == false) {
|
|
361
|
-
log(
|
|
362
|
-
red(
|
|
363
|
-
'‼️ This wallet generation format was not tested yet, do not use it!'
|
|
364
|
-
)
|
|
365
|
-
);
|
|
366
|
-
}
|
|
367
|
-
|
|
368
430
|
// formats
|
|
369
431
|
if (
|
|
370
432
|
cw.row.formats !== undefined &&
|