@yerofey/cryptowallet-cli 1.41.2 → 1.43.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/cli.js +3 -1
- package/package.json +16 -14
- package/src/Method.js +3 -1
- package/src/Wallet.js +121 -45
package/cli.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yerofey/cryptowallet-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.43.0",
|
|
4
4
|
"description": "Crypto wallet generator CLI tool",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"homepage": "https://github.com/yerofey/cryptowallet-cli",
|
|
@@ -116,45 +116,47 @@
|
|
|
116
116
|
],
|
|
117
117
|
"dependencies": {
|
|
118
118
|
"@binance-chain/javascript-sdk": "^4.2.2",
|
|
119
|
-
"@emurgo/cardano-serialization-lib-nodejs": "^
|
|
120
|
-
"@harmony-js/account": "^0.1.
|
|
119
|
+
"@emurgo/cardano-serialization-lib-nodejs": "^15.0.1",
|
|
120
|
+
"@harmony-js/account": "^0.1.57",
|
|
121
121
|
"@mysten/sui": "^1.18.0",
|
|
122
|
-
"@solana/web3.js": "^1.98.
|
|
123
|
-
"@ton/core": "^0.
|
|
122
|
+
"@solana/web3.js": "^1.98.4",
|
|
123
|
+
"@ton/core": "^0.61.0",
|
|
124
124
|
"@ton/crypto": "^3.3.0",
|
|
125
|
-
"@ton/ton": "^15.1
|
|
125
|
+
"@ton/ton": "^15.3.1",
|
|
126
126
|
"@yerofey/dogecoin-bip84": "^0.0.5",
|
|
127
127
|
"@yerofey/litecoin-bip84": "^0.0.5",
|
|
128
128
|
"bigint-buffer": "^1.1.5",
|
|
129
|
+
"bip32": "^5.0.0",
|
|
129
130
|
"bip39": "^3.1.0",
|
|
130
131
|
"bip84": "^0.2.9",
|
|
131
132
|
"bip86": "^0.0.4",
|
|
132
133
|
"bs58": "^6.0.0",
|
|
133
134
|
"cardano-wallet-js": "^1.4.0",
|
|
134
|
-
"chalk": "5.
|
|
135
|
+
"chalk": "5.6.2",
|
|
135
136
|
"clipboardy": "^4.0.0",
|
|
136
137
|
"coininfo": "5.2.1",
|
|
137
138
|
"coinkey": "3.0.0",
|
|
138
139
|
"columnify": "1.6.0",
|
|
139
|
-
"commander": "^
|
|
140
|
+
"commander": "^14.0.1",
|
|
140
141
|
"csv-writer": "^1.6.0",
|
|
141
|
-
"dotenv": "^
|
|
142
|
+
"dotenv": "^17.2.2",
|
|
142
143
|
"ed25519-hd-key": "^1.3.0",
|
|
143
144
|
"eth-lib": "0.1.29",
|
|
144
145
|
"ethereum-bip84": "0.0.3",
|
|
145
|
-
"ethereum-cryptography": "^3.
|
|
146
|
+
"ethereum-cryptography": "^3.2.0",
|
|
146
147
|
"ethereum-mnemonic-privatekey-utils": "1.0.5",
|
|
147
148
|
"qrcode-terminal": "^0.12.0",
|
|
148
149
|
"ripple-address-codec": "^5.0.0",
|
|
149
150
|
"ripple-keypairs": "^2.0.0",
|
|
150
|
-
"stellar-hd-wallet": "^
|
|
151
|
+
"stellar-hd-wallet": "^1.0.2",
|
|
151
152
|
"tezos-sign": "1.4.1",
|
|
153
|
+
"tiny-secp256k1": "^2.2.4",
|
|
152
154
|
"tonweb": "^0.0.66",
|
|
153
|
-
"tronweb": "^6.0.
|
|
155
|
+
"tronweb": "^6.0.4",
|
|
154
156
|
"xrpl": "^4.2.0"
|
|
155
157
|
},
|
|
156
158
|
"devDependencies": {
|
|
157
|
-
"ava": "^6.
|
|
158
|
-
"eslint": "^9.
|
|
159
|
+
"ava": "^6.4.1",
|
|
160
|
+
"eslint": "^9.35.0"
|
|
159
161
|
}
|
|
160
162
|
}
|
package/src/Method.js
CHANGED
package/src/Wallet.js
CHANGED
|
@@ -6,6 +6,8 @@ const { red, yellow, gray } = chalk;
|
|
|
6
6
|
import CoinKey from 'coinkey';
|
|
7
7
|
import CoinInfo from 'coininfo';
|
|
8
8
|
import bip39 from 'bip39';
|
|
9
|
+
import { BIP32Factory } from 'bip32';
|
|
10
|
+
import * as ecc from 'tiny-secp256k1';
|
|
9
11
|
import bip84 from 'bip84';
|
|
10
12
|
const { fromMnemonic, fromZPrv } = bip84;
|
|
11
13
|
import bip86 from 'bip86';
|
|
@@ -46,7 +48,11 @@ import StellarHDWallet from 'stellar-hd-wallet';
|
|
|
46
48
|
import { Seed as CardanoSeed } from 'cardano-wallet-js';
|
|
47
49
|
import CardanoWasm from '@emurgo/cardano-serialization-lib-nodejs';
|
|
48
50
|
|
|
49
|
-
|
|
51
|
+
const bip32 = BIP32Factory(ecc);
|
|
52
|
+
|
|
53
|
+
config({
|
|
54
|
+
quiet: true,
|
|
55
|
+
});
|
|
50
56
|
|
|
51
57
|
class Wallet {
|
|
52
58
|
constructor(cw) {
|
|
@@ -410,32 +416,64 @@ class Wallet {
|
|
|
410
416
|
|
|
411
417
|
const mnemonic = mnemonicString || bip39.generateMnemonic();
|
|
412
418
|
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
419
|
+
if (row.format == 'legacy') {
|
|
420
|
+
const seed = bip39.mnemonicToSeedSync(mnemonic);
|
|
421
|
+
const root = bip32.fromSeed(seed);
|
|
422
|
+
const coinPath = normalizeLegacyPath(row.path, "m/44'/0'");
|
|
423
|
+
const accountNode = root.derivePath(`${coinPath}/0'`);
|
|
424
|
+
const changeNode = accountNode.derive(0);
|
|
425
|
+
const coinInfo = CoinInfo(chain).versions;
|
|
426
|
+
|
|
427
|
+
let addresses = [];
|
|
428
|
+
if (number >= 1) {
|
|
429
|
+
for (let i = 0; i < number; i++) {
|
|
430
|
+
const child = changeNode.derive(i);
|
|
431
|
+
const key = new CoinKey(child.privateKey, coinInfo);
|
|
432
|
+
key.compressed = true;
|
|
433
|
+
addresses.push({
|
|
434
|
+
index: i,
|
|
435
|
+
address: key.publicAddress,
|
|
436
|
+
privateKey: key.privateWif,
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
}
|
|
421
440
|
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
441
|
+
Object.assign(result, {
|
|
442
|
+
format: row.format,
|
|
443
|
+
addresses,
|
|
444
|
+
privateExtendedKey: accountNode.toBase58(),
|
|
445
|
+
mnemonic,
|
|
446
|
+
});
|
|
447
|
+
} else {
|
|
448
|
+
const root =
|
|
449
|
+
row.format == 'taproot'
|
|
450
|
+
? new fromMnemonicBip86(mnemonic, '')
|
|
451
|
+
: new fromMnemonic(mnemonic, '');
|
|
452
|
+
const child =
|
|
453
|
+
row.format == 'taproot'
|
|
454
|
+
? root.deriveAccount(0)
|
|
455
|
+
: root.deriveAccount(0);
|
|
456
|
+
const account =
|
|
457
|
+
row.format == 'taproot' ? new fromXPrv(child) : new fromZPrv(child);
|
|
458
|
+
|
|
459
|
+
let addresses = [];
|
|
460
|
+
if (number >= 1) {
|
|
461
|
+
for (let i = 0; i < number; i++) {
|
|
462
|
+
addresses.push({
|
|
463
|
+
index: i,
|
|
464
|
+
address: account.getAddress(i, false, row.purpose),
|
|
465
|
+
privateKey: account.getPrivateKey(i),
|
|
466
|
+
});
|
|
467
|
+
}
|
|
430
468
|
}
|
|
431
|
-
}
|
|
432
469
|
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
470
|
+
Object.assign(result, {
|
|
471
|
+
format: row.format,
|
|
472
|
+
addresses,
|
|
473
|
+
privateExtendedKey: account.getAccountPrivateKey(),
|
|
474
|
+
mnemonic,
|
|
475
|
+
});
|
|
476
|
+
}
|
|
439
477
|
} else if (chain == 'DOGE' || chain == 'LTC') {
|
|
440
478
|
// Validate mnemonic
|
|
441
479
|
if (mnemonicString != '' && !bip39.validateMnemonic(mnemonicString)) {
|
|
@@ -444,31 +482,62 @@ class Wallet {
|
|
|
444
482
|
};
|
|
445
483
|
}
|
|
446
484
|
|
|
447
|
-
const _fromMnemonic =
|
|
448
|
-
chain == 'DOGE' ? fromMnemonicDoge : fromMnemonicLite;
|
|
449
|
-
const _fromZPrv = chain == 'DOGE' ? fromZPrvDoge : fromZPrvLite;
|
|
450
485
|
const mnemonic = mnemonicString || bip39.generateMnemonic();
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
486
|
+
if (row.format == 'legacy') {
|
|
487
|
+
const seed = bip39.mnemonicToSeedSync(mnemonic);
|
|
488
|
+
const root = bip32.fromSeed(seed);
|
|
489
|
+
const fallbackPath = chain == 'DOGE' ? "m/44'/3'" : "m/44'/2'";
|
|
490
|
+
const coinPath = normalizeLegacyPath(row.path, fallbackPath);
|
|
491
|
+
const accountNode = root.derivePath(`${coinPath}/0'`);
|
|
492
|
+
const changeNode = accountNode.derive(0);
|
|
493
|
+
const coinInfo = CoinInfo(chain).versions;
|
|
494
|
+
|
|
495
|
+
let addresses = [];
|
|
496
|
+
if (number >= 1) {
|
|
497
|
+
for (let i = 0; i < number; i++) {
|
|
498
|
+
const child = changeNode.derive(i);
|
|
499
|
+
const key = new CoinKey(child.privateKey, coinInfo);
|
|
500
|
+
key.compressed = true;
|
|
501
|
+
addresses.push({
|
|
502
|
+
index: i,
|
|
503
|
+
address: key.publicAddress,
|
|
504
|
+
privateKey: key.privateWif,
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
}
|
|
454
508
|
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
509
|
+
Object.assign(result, {
|
|
510
|
+
format: row.format,
|
|
511
|
+
addresses,
|
|
512
|
+
privateExtendedKey: accountNode.toBase58(),
|
|
513
|
+
mnemonic,
|
|
514
|
+
});
|
|
515
|
+
} else {
|
|
516
|
+
const _fromMnemonic =
|
|
517
|
+
chain == 'DOGE' ? fromMnemonicDoge : fromMnemonicLite;
|
|
518
|
+
const _fromZPrv = chain == 'DOGE' ? fromZPrvDoge : fromZPrvLite;
|
|
519
|
+
const root = new _fromMnemonic(mnemonic, '');
|
|
520
|
+
const child = root.deriveAccount(0);
|
|
521
|
+
const account = new _fromZPrv(child);
|
|
522
|
+
|
|
523
|
+
let addresses = [];
|
|
524
|
+
if (number >= 1) {
|
|
525
|
+
for (let i = 0; i < number; i++) {
|
|
526
|
+
addresses.push({
|
|
527
|
+
index: i,
|
|
528
|
+
address: account.getAddress(i, false, row.purpose),
|
|
529
|
+
privateKey: account.getPrivateKey(i),
|
|
530
|
+
});
|
|
531
|
+
}
|
|
463
532
|
}
|
|
464
|
-
}
|
|
465
533
|
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
534
|
+
Object.assign(result, {
|
|
535
|
+
format: row.format,
|
|
536
|
+
addresses,
|
|
537
|
+
privateExtendedKey: account.getAccountPrivateKey(),
|
|
538
|
+
mnemonic,
|
|
539
|
+
});
|
|
540
|
+
}
|
|
472
541
|
} else if (row.format == 'BEP2') {
|
|
473
542
|
// Validate mnemonic
|
|
474
543
|
if (mnemonicString != '' && !bip39.validateMnemonic(mnemonicString)) {
|
|
@@ -922,4 +991,11 @@ function generateMnemonicString(length = 12) {
|
|
|
922
991
|
return bip39.generateMnemonic(entropy);
|
|
923
992
|
}
|
|
924
993
|
|
|
994
|
+
function normalizeLegacyPath(pathValue, fallbackPath) {
|
|
995
|
+
const basePath = (pathValue && pathValue.trim()) || fallbackPath || '';
|
|
996
|
+
if (basePath === '') return basePath;
|
|
997
|
+
if (basePath.endsWith("'")) return basePath;
|
|
998
|
+
return basePath.replace(/\/(\d+)$/, "/$1'");
|
|
999
|
+
}
|
|
1000
|
+
|
|
925
1001
|
export { generateMnemonicString, Wallet };
|