@yerofey/cryptowallet-cli 1.19.0 → 1.20.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/package.json +2 -1
- package/src/Wallet.js +17 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yerofey/cryptowallet-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.20.0",
|
|
4
4
|
"description": "Crypto wallet generator CLI tool",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"homepage": "https://github.com/yerofey/cryptowallet-cli",
|
|
@@ -120,6 +120,7 @@
|
|
|
120
120
|
"commander": "11.1.0",
|
|
121
121
|
"csv-writer": "^1.6.0",
|
|
122
122
|
"dotenv": "^16.4.1",
|
|
123
|
+
"ed25519-hd-key": "^1.3.0",
|
|
123
124
|
"eth-lib": "0.1.29",
|
|
124
125
|
"ethereum-bip84": "0.0.3",
|
|
125
126
|
"ethereum-mnemonic-privatekey-utils": "1.0.5",
|
package/src/Wallet.js
CHANGED
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
Keypair as SolanaKeypair,
|
|
25
25
|
PublicKey as SolanaPublickey,
|
|
26
26
|
} from '@solana/web3.js';
|
|
27
|
+
import { derivePath } from 'ed25519-hd-key';
|
|
27
28
|
import bs58 from 'bs58';
|
|
28
29
|
import TonWeb from 'tonweb';
|
|
29
30
|
import {
|
|
@@ -428,10 +429,21 @@ class Wallet {
|
|
|
428
429
|
mnemonic,
|
|
429
430
|
});
|
|
430
431
|
} else if (chain == 'SOL') {
|
|
431
|
-
//
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
432
|
+
// Validate mnemonic
|
|
433
|
+
if (mnemonicString != '' && !bip39.validateMnemonic(mnemonicString)) {
|
|
434
|
+
return {
|
|
435
|
+
error: 'mnemonic is not valid',
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
const mnemonic = mnemonicString || generateMnemonicString(24);
|
|
440
|
+
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);
|
|
435
447
|
|
|
436
448
|
// TODO: add support for multiple addresses
|
|
437
449
|
|
|
@@ -443,6 +455,7 @@ class Wallet {
|
|
|
443
455
|
privateKey: secretKeyString,
|
|
444
456
|
},
|
|
445
457
|
],
|
|
458
|
+
mnemonic,
|
|
446
459
|
});
|
|
447
460
|
} else if (chain == 'TON') {
|
|
448
461
|
// Validate mnemonic
|