@yerofey/cryptowallet-cli 1.28.0 → 1.30.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 +2 -1
- package/package.json +1 -1
- package/src/Wallet.js +8 -89
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 ("
|
|
91
|
+
# generate BTC Taproot wallet ("bc1p...")
|
|
92
92
|
$ cw -c BTC -f taproot
|
|
93
93
|
|
|
94
94
|
# generate ERC-like wallet from mnemonic string
|
|
@@ -184,6 +184,7 @@ $ cw -l
|
|
|
184
184
|
- [x] v18.x ✅
|
|
185
185
|
- [x] v19.x ✅
|
|
186
186
|
- [x] v20.x ✅
|
|
187
|
+
- [x] v21.x ✅
|
|
187
188
|
|
|
188
189
|
*tested on Ubuntu 22.04 & Mac M1*
|
|
189
190
|
|
package/package.json
CHANGED
package/src/Wallet.js
CHANGED
|
@@ -445,10 +445,14 @@ class Wallet {
|
|
|
445
445
|
});
|
|
446
446
|
} else if (chain == 'SOL') {
|
|
447
447
|
// Validate mnemonic
|
|
448
|
-
if (mnemonicString != ''
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
}
|
|
448
|
+
if (mnemonicString != '') {
|
|
449
|
+
try {
|
|
450
|
+
bip39.validateMnemonic(mnemonicString);
|
|
451
|
+
} catch (error) {
|
|
452
|
+
return {
|
|
453
|
+
error: 'mnemonic is not valid',
|
|
454
|
+
};
|
|
455
|
+
}
|
|
452
456
|
}
|
|
453
457
|
|
|
454
458
|
let addresses = [];
|
|
@@ -563,91 +567,6 @@ class Wallet {
|
|
|
563
567
|
|
|
564
568
|
return result;
|
|
565
569
|
}
|
|
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
|
-
// }
|
|
651
570
|
}
|
|
652
571
|
|
|
653
572
|
function generateMnemonicString(length = 12) {
|