@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 CHANGED
@@ -16,7 +16,9 @@ import Method from './src/Method.js';
16
16
  import chalk from 'chalk';
17
17
 
18
18
  // load environment variables
19
- config();
19
+ config({
20
+ quiet: true,
21
+ });
20
22
 
21
23
  // get the current file path
22
24
  const __filename = fileURLToPath(import.meta.url);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yerofey/cryptowallet-cli",
3
- "version": "1.41.2",
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": "^14.1.1",
120
- "@harmony-js/account": "^0.1.58",
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.0",
123
- "@ton/core": "^0.60.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.0",
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.4.1",
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": "^13.1.0",
140
+ "commander": "^14.0.1",
140
141
  "csv-writer": "^1.6.0",
141
- "dotenv": "^16.4.7",
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.1.0",
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": "^0.0.10",
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.1",
155
+ "tronweb": "^6.0.4",
154
156
  "xrpl": "^4.2.0"
155
157
  },
156
158
  "devDependencies": {
157
- "ava": "^6.2.0",
158
- "eslint": "^9.17.0"
159
+ "ava": "^6.4.1",
160
+ "eslint": "^9.35.0"
159
161
  }
160
162
  }
package/src/Method.js CHANGED
@@ -9,7 +9,9 @@ import CW from './CW.js';
9
9
  import { generateMnemonicString } from './Wallet.js';
10
10
  import { log, supportedChains, loadJson } from './utils.js';
11
11
 
12
- config();
12
+ config({
13
+ quiet: true,
14
+ });
13
15
 
14
16
  const {
15
17
  blue,
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
- config();
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
- const root =
414
- row.format == 'taproot'
415
- ? new fromMnemonicBip86(mnemonic, '')
416
- : new fromMnemonic(mnemonic, '');
417
- const child =
418
- row.format == 'taproot' ? root.deriveAccount(0) : root.deriveAccount(0);
419
- const account =
420
- row.format == 'taproot' ? new fromXPrv(child) : new fromZPrv(child);
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
- let addresses = [];
423
- if (number >= 1) {
424
- for (let i = 0; i < number; i++) {
425
- addresses.push({
426
- index: i,
427
- address: account.getAddress(i, false, row.purpose),
428
- privateKey: account.getPrivateKey(i),
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
- Object.assign(result, {
434
- format: row.format,
435
- addresses,
436
- privateExtendedKey: account.getAccountPrivateKey(),
437
- mnemonic,
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
- const root = new _fromMnemonic(mnemonic, '');
452
- const child = root.deriveAccount(0);
453
- const account = new _fromZPrv(child);
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
- let addresses = [];
456
- if (number >= 1) {
457
- for (let i = 0; i < number; i++) {
458
- addresses.push({
459
- index: i,
460
- address: account.getAddress(i, false, row.purpose),
461
- privateKey: account.getPrivateKey(i),
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
- Object.assign(result, {
467
- format: row.format,
468
- addresses,
469
- privateExtendedKey: account.getAccountPrivateKey(),
470
- mnemonic,
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 };