@yerofey/cryptowallet-cli 1.20.0 → 1.22.0

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/README.md CHANGED
@@ -46,9 +46,11 @@ $ cw -c btc
46
46
  # generate random mnemonic string (12 words) to import in any wallet app
47
47
  $ cw -m
48
48
 
49
- # generate random mnemonic string of a specific length (12, 18, or 24 words)
49
+ # generate random mnemonic string of a specific length (12, 15, 18, 21 or 24 words)
50
50
  $ cw -m 12
51
+ $ cw -m 15
51
52
  $ cw -m 18
53
+ $ cw -m 21
52
54
  $ cw -m 24
53
55
 
54
56
  # generate a wallet from a given mnemonic string
@@ -137,6 +139,7 @@ $ cw -l
137
139
  ## Options
138
140
 
139
141
  - `-b` or `-c` or `--chain`: Specify the blockchain ticker to generate a wallet for
142
+ - `-C` or `--copy`: Copy the generated mnemonic to the clipboard
140
143
  - `-D` or `--csv`: Save output into CSV file with custom or default name ("`cw-output.csv`") - this is a shorthand for `-o csv -F filename`
141
144
  - `-f` or `--format`: Specify the blockchain wallet format (for BTC: legacy, segwit, bech32)
142
145
  - `-g` or `--geek`: Display some additional "geeky" info
@@ -144,7 +147,9 @@ $ cw -l
144
147
  - `-m` or `--mnemonic [value]`: If used without a value or with `12`, `18`, or `24`, it generates a mnemonic string of that length. If a mnemonic string is provided, it generates a wallet from the given mnemonic. For example:
145
148
  - `$ cw -m`: Generates a default 12-word mnemonic string.
146
149
  - `$ cw -m 12`: Generates a 12-word mnemonic string.
150
+ - `$ cw -m 15`: Generates a 15-word mnemonic string.
147
151
  - `$ cw -m 18`: Generates an 18-word mnemonic string.
152
+ - `$ cw -m 21`: Generates a 21-word mnemonic string.
148
153
  - `$ cw -m 24`: Generates a 24-word mnemonic string.
149
154
  - `$ cw -m "your mnemonic phrase here"`: Generates a wallet from the provided mnemonic string.
150
155
  - `-n` or `--number`: Specify number of wallets to display (works for HD wallets only, like BTC/LTC/DOGE)
package/cli.js CHANGED
@@ -18,7 +18,7 @@ import Method from './src/Method.js';
18
18
  options.mnemonic === '' ||
19
19
  options.mnemonic.split(' ').length === 1)
20
20
  ) {
21
- return new Method('mnemonic').init({ mnemonic: options.mnemonic });
21
+ return new Method('mnemonic').init({ mnemonic: options.mnemonic, copy: options?.copy || false });
22
22
  }
23
23
 
24
24
  if (options.version) {
@@ -29,7 +29,7 @@ import Method from './src/Method.js';
29
29
  return new Method('donate').init();
30
30
  }
31
31
 
32
- const chain = options.chain.toUpperCase() || 'ETH';
32
+ const chain = options.chain.toUpperCase() || 'ERC';
33
33
  if (supportedChains.includes(chain)) {
34
34
  return new Method('wallet', {
35
35
  chain,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yerofey/cryptowallet-cli",
3
- "version": "1.20.0",
3
+ "version": "1.22.0",
4
4
  "description": "Crypto wallet generator CLI tool",
5
5
  "type": "module",
6
6
  "homepage": "https://github.com/yerofey/cryptowallet-cli",
@@ -114,6 +114,7 @@
114
114
  "bs58": "^5.0.0",
115
115
  "buffer": "^6.0.3",
116
116
  "chalk": "5.3.0",
117
+ "clipboardy": "^4.0.0",
117
118
  "coininfo": "5.2.1",
118
119
  "coinkey": "3.0.0",
119
120
  "columnify": "1.6.0",
package/src/Method.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { config } from 'dotenv';
2
2
  import path from 'node:path';
3
3
  import chalk from 'chalk';
4
+ import clipboardy from 'clipboardy';
4
5
  import columnify from 'columnify';
5
6
  import CsvWriter from 'csv-writer';
6
7
  import { log, supportedChains, loadJson } from './utils.js';
@@ -66,9 +67,10 @@ class Method {
66
67
 
67
68
  _mnemonic() {
68
69
  const mnemonic = this.inputOptions.mnemonic || '12';
69
- const mnemonicLength = ['12', '18', '24'].includes(mnemonic)
70
+ const mnemonicLength = ['12', '15', '18', '21', '24'].includes(mnemonic)
70
71
  ? parseInt(mnemonic, 10)
71
72
  : 12;
73
+ const mnemonicString = generateMnemonicString(mnemonicLength);
72
74
 
73
75
  log(
74
76
  `✨ ${green('Done!')} ${blueBright(
@@ -77,13 +79,26 @@ class Method {
77
79
  } words mnemonic string:`
78
80
  )}\n`
79
81
  );
80
- log(`📄 ${generateMnemonicString(mnemonicLength)}`);
82
+ log(`📄 ${mnemonicString}`);
83
+ // copy to clipboard if flag is set
84
+ if (this.inputOptions.copy) {
85
+ clipboardy.writeSync(mnemonicString);
86
+ log(`📋 ${green('Mnemonic copied to your clipboard!')}`);
87
+ }
81
88
  log();
82
89
  log(
83
90
  greenBright(
84
91
  'â„šī¸ You can import it into your favorite wallet app or use it to generate a wallet with "-m" flag'
85
92
  )
86
93
  );
94
+
95
+ // donation
96
+ log();
97
+ log(
98
+ blueBright(
99
+ '🙏 Consider supporting this project - check donations options with: cw --donate'
100
+ )
101
+ );
87
102
  }
88
103
 
89
104
  _version() {
@@ -199,6 +214,7 @@ class Method {
199
214
 
200
215
  if (displayAsText) {
201
216
  // display addresses
217
+ let index = 0;
202
218
  for (const item of cw.wallet.addresses) {
203
219
  if (cw.wallet.addresses.length > 1) {
204
220
  log();
@@ -350,6 +366,13 @@ class Method {
350
366
  if (item.privateKey !== undefined) {
351
367
  log(`🔑 ${item.privateKey}`);
352
368
  }
369
+ // copy to clipboard if flag is set
370
+ if (cw.options.copy && cw.wallet.mnemonic !== undefined && index == 0) {
371
+ clipboardy.writeSync(cw.wallet.mnemonic);
372
+ log(`📋 ${green('Mnemonic copied to your clipboard!')}`);
373
+ }
374
+
375
+ index += 1;
353
376
  }
354
377
 
355
378
  // tested
@@ -418,7 +441,7 @@ class Method {
418
441
  }
419
442
  }
420
443
 
421
- // formats, network, apps
444
+ // formats, network, apps, attempts, donation
422
445
  if (displayAsText) {
423
446
  if (
424
447
  cw.row.formats !== undefined ||
@@ -468,6 +491,7 @@ class Method {
468
491
  );
469
492
  }
470
493
 
494
+ // apps
471
495
  if (cw.row.apps !== undefined) {
472
496
  let apps = {
473
497
  metamask: 'MetaMask',
package/src/Wallet.js CHANGED
@@ -38,7 +38,7 @@ config();
38
38
  class Wallet {
39
39
  constructor(cw) {
40
40
  this.cw = cw;
41
- this.supportedMnemonicLengths = [12, 18, 24];
41
+ this.supportedMnemonicLengths = [12, 15, 18, 21, 24];
42
42
  }
43
43
 
44
44
  async init() {
@@ -436,25 +436,25 @@ class Wallet {
436
436
  };
437
437
  }
438
438
 
439
+ let addresses = [];
439
440
  const mnemonic = mnemonicString || generateMnemonicString(24);
440
441
  const seed = await bip39.mnemonicToSeed(mnemonic);
441
- const derivationPath = "m/44'/501'/0'/0'";
442
- const derivedSeed = derivePath(derivationPath, seed.toString('hex')).key;
443
- const keypair = SolanaKeypair.fromSeed(derivedSeed);
444
- const publicKey = new SolanaPublickey(keypair.publicKey);
445
- const publicKeyString = publicKey.toString();
446
- const secretKeyString = bs58.encode(keypair.secretKey);
447
442
 
448
- // TODO: add support for multiple addresses
443
+ for (let i = 0; i < number; i++) {
444
+ const derivationPath = `m/44'/501'/${i}'/0'`;
445
+ const derivedSeed = derivePath(derivationPath, seed.toString('hex')).key;
446
+ const keypair = SolanaKeypair.fromSeed(derivedSeed);
447
+ const publicKey = new SolanaPublickey(keypair.publicKey);
448
+ const privateKey = bs58.encode(keypair.secretKey);
449
+ addresses.push({
450
+ index: i,
451
+ address: publicKey.toBase58(),
452
+ privateKey,
453
+ });
454
+ }
449
455
 
450
456
  Object.assign(result, {
451
- addresses: [
452
- {
453
- index: 0,
454
- address: publicKeyString,
455
- privateKey: secretKeyString,
456
- },
457
- ],
457
+ addresses,
458
458
  mnemonic,
459
459
  });
460
460
  } else if (chain == 'TON') {
@@ -553,15 +553,21 @@ function generateMnemonicString(length = 12) {
553
553
  case 12:
554
554
  entropy = 128;
555
555
  break;
556
+ case 15:
557
+ entropy = 160;
558
+ break;
556
559
  case 18:
557
560
  entropy = 192;
558
561
  break;
562
+ case 21:
563
+ entropy = 224;
564
+ break;
559
565
  case 24:
560
566
  entropy = 256;
561
567
  break;
562
568
  default:
563
569
  throw new Error(
564
- 'Invalid mnemonic length. Supported lengths are 12, 18, or 24.'
570
+ 'Invalid mnemonic length. Supported lengths are 12, 15, 18, 21, and 24.'
565
571
  );
566
572
  }
567
573
 
@@ -3,6 +3,6 @@
3
3
  "network": "EVM",
4
4
  "startsWith": "0x",
5
5
  "prefixTest": "[0-9a-fA-F]",
6
- "apps": ["metamask", "trustwallet", "binance-chain-wallet"],
6
+ "apps": ["metamask", "trustwallet"],
7
7
  "flags": ["m", "n", "p", "s"]
8
8
  }
@@ -4,5 +4,5 @@
4
4
  "startsWith": "",
5
5
  "prefixTest": "[1-9a-zA-Z]",
6
6
  "apps": ["phantom", "trustwallet"],
7
- "flags": ["p", "s"]
7
+ "flags": ["m", "n", "p", "s"]
8
8
  }
@@ -9,7 +9,7 @@
9
9
  "prefixTest": "[0-9a-zA-Z-_]",
10
10
  "rareSymbols": "[0-9]",
11
11
  "apps": ["tonkeeper", "trustwallet"],
12
- "flags": ["p", "s"]
12
+ "flags": ["m", "n", "p", "s"]
13
13
  }
14
14
  }
15
15
  }
package/src/options.js CHANGED
@@ -3,6 +3,7 @@ import { program } from 'commander';
3
3
 
4
4
  program.option('-b, --chain <ticker>', 'Wallet for specific blockchain', 'ERC');
5
5
  program.option('-c, --chain <ticker>', 'Wallet for specific blockchain', 'ERC');
6
+ program.option('-C, --copy', 'Copy the result to the clipboard');
6
7
  program.option(
7
8
  '-D, --csv [filename]',
8
9
  'Save result into CSV file'