@yerofey/cryptowallet-cli 1.26.2 → 1.29.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.
Files changed (3) hide show
  1. package/README.md +1 -1
  2. package/package.json +1 -1
  3. package/src/Wallet.js +91 -32
package/README.md CHANGED
@@ -88,7 +88,7 @@ $ cw -c BTC -f bech32 -m "radio bright pizza pluck family crawl palm flame forge
88
88
  # generate N of BTC bech32 wallets from mnemonic string
89
89
  $ cw -c BTC -f bech32 -n 10 -m "radio bright pizza pluck family crawl palm flame forget focus stock stadium"
90
90
 
91
- # generate BTC Taproot wallet ("bc1q...")
91
+ # generate BTC Taproot wallet ("bc1p...")
92
92
  $ cw -c BTC -f taproot
93
93
 
94
94
  # generate ERC-like wallet from mnemonic string
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yerofey/cryptowallet-cli",
3
- "version": "1.26.2",
3
+ "version": "1.29.0",
4
4
  "description": "Crypto wallet generator CLI tool",
5
5
  "type": "module",
6
6
  "homepage": "https://github.com/yerofey/cryptowallet-cli",
package/src/Wallet.js CHANGED
@@ -44,9 +44,7 @@ class Wallet {
44
44
  }
45
45
 
46
46
  async init() {
47
- const cw = this.cw;
48
- const row = cw.row;
49
- const options = cw.options;
47
+ const { row, options } = this.cw;
50
48
 
51
49
  const desiredSymbolsArray =
52
50
  options.prefix.length > 0 || options.suffix.length > 0
@@ -234,10 +232,7 @@ class Wallet {
234
232
  }
235
233
 
236
234
  async createWallet() {
237
- const cw = this.cw;
238
- const chain = cw.chain;
239
- const row = cw.row;
240
- const options = cw.options;
235
+ const { chain, options, row } = this.cw;
241
236
 
242
237
  let format = options.format || '';
243
238
  const mnemonic = options.mnemonic || '';
@@ -568,35 +563,99 @@ class Wallet {
568
563
 
569
564
  return result;
570
565
  }
566
+
567
+ // handleBTC() {
568
+ // const wallet = CoinKey.createRandom(CoinInfo('BTC').versions);
569
+
570
+ // return {
571
+ // address: wallet.publicAddress,
572
+ // privateKey: wallet.privateWif,
573
+ // };
574
+ // }
575
+
576
+ // handleDOGE() {
577
+ // const mnemonic = generateMnemonicString(12);
578
+ // const root = fromMnemonicDoge(mnemonic, '');
579
+ // const child = root.deriveAccount(0);
580
+ // const account = fromZPrvDoge(child);
581
+
582
+ // return {
583
+ // mnemonic,
584
+ // privateExtendedKey: account.getAccountPrivateKey(),
585
+ // addresses: [
586
+ // {
587
+ // index: 0,
588
+ // address: account.getAddress(0, false, 44),
589
+ // privateKey: account.getPrivateKey(0),
590
+ // },
591
+ // ],
592
+ // };
593
+ // }
594
+
595
+ // handleEVM() {
596
+ // const mnemonic = bip39.generateMnemonic();
597
+ // const privateKey = pkutils.getPrivateKeyFromMnemonic(mnemonic);
598
+ // const account = Account.fromPrivate('0x' + privateKey);
599
+
600
+ // return {
601
+ // address: account.address,
602
+ // privateKey,
603
+ // };
604
+ // }
605
+
606
+ // handleLTC() {
607
+ // const mnemonic = generateMnemonicString(12);
608
+ // const root = fromMnemonicLite(mnemonic, '');
609
+ // const child = root.deriveAccount(0);
610
+ // const account = fromZPrvLite(child);
611
+
612
+ // return {
613
+ // mnemonic,
614
+ // privateExtendedKey: account.getAccountPrivateKey(),
615
+ // addresses: [
616
+ // {
617
+ // index: 0,
618
+ // address: account.getAddress(0, false, 44),
619
+ // privateKey: account.getPrivateKey(0),
620
+ // },
621
+ // ],
622
+ // };
623
+ // }
624
+
625
+ // handleSOL() {
626
+ // const mnemonic = generateMnemonicString(24);
627
+ // const seed = bip39.mnemonicToSeedSync(mnemonic);
628
+ // const keypair = SolanaKeypair.fromSeed(seed.slice(0, 32));
629
+ // const publicKey = new SolanaPublickey(keypair.publicKey);
630
+ // const privateKey = bs58.encode(keypair.secretKey);
631
+
632
+ // return {
633
+ // address: publicKey.toBase58(),
634
+ // privateKey,
635
+ // };
636
+ // }
637
+
638
+ // handleTON() {
639
+ // const mnemonic = newTonMnemonic();
640
+ // const keyPair = TonMnemonicToPrivateKey(mnemonic);
641
+ // const tonweb = new TonWeb();
642
+ // const WalletClass = tonweb.wallet.all.v4R2;
643
+ // const wallet = new WalletClass(tonweb.provider, keyPair);
644
+ // const address = wallet.getAddress();
645
+
646
+ // return {
647
+ // mnemonic,
648
+ // address,
649
+ // };
650
+ // }
571
651
  }
572
652
 
573
653
  function generateMnemonicString(length = 12) {
574
- let entropy;
575
- switch (length) {
576
- case 12:
577
- entropy = 128;
578
- break;
579
- case 15:
580
- entropy = 160;
581
- break;
582
- case 18:
583
- entropy = 192;
584
- break;
585
- case 21:
586
- entropy = 224;
587
- break;
588
- case 24:
589
- entropy = 256;
590
- break;
591
- default:
592
- throw new Error(
593
- 'Invalid mnemonic length. Supported lengths are 12, 15, 18, 21, and 24.'
594
- );
654
+ const entropy = { 12: 128, 15: 160, 18: 192, 21: 224, 24: 256 }[length] || 0;
655
+ if (entropy == 0) {
656
+ throw new Error('Invalid mnemonic length.');
595
657
  }
596
-
597
- // Generate the mnemonic based on the specified entropy
598
- const mnemonic = bip39.generateMnemonic(entropy);
599
- return mnemonic;
658
+ return bip39.generateMnemonic(entropy);
600
659
  }
601
660
 
602
661
  export { generateMnemonicString, Wallet };