@yerofey/cryptowallet-cli 1.38.1 → 1.38.2
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 +3 -3
- package/cli.js +22 -26
- package/package.json +2 -3
- package/src/Method.js +4 -3
- package/src/Wallet.js +12 -6
- package/src/chains/TRON.json +9 -0
- package/src/chains/TRX.json +2 -1
- package/src/options.js +1 -1
- package/src/utils.js +3 -2
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
[](https://npmjs.com/@yerofey/cryptowallet-cli)
|
|
5
5
|
[](https://npmjs.com/package/@yerofey/cryptowallet-cli)
|
|
6
6
|
|
|
7
|
-
>
|
|
7
|
+
> CW: crypto wallet generator CLI tool
|
|
8
8
|
|
|
9
9
|

|
|
10
10
|
|
|
@@ -259,9 +259,9 @@ Each chain JSON file is structured to provide essential information about the bl
|
|
|
259
259
|
- `flags`: An array of supported features for the wallet generation. Common flags include `m` for mnemonic support, `n` for generating multiple wallets, `p` for prefix support, and `s` for suffix support.
|
|
260
260
|
- `formats`: (Optional) An object defining multiple wallet formats if the blockchain supports more than one format. Each format should specify its unique properties.
|
|
261
261
|
|
|
262
|
-
By following this structure, the `
|
|
262
|
+
By following this structure, the `cw` tool can understand and support wallet generation for a wide array of blockchains.
|
|
263
263
|
|
|
264
|
-
Feel free to contribute by adding support for more chains, and help in making `
|
|
264
|
+
Feel free to contribute by adding support for more chains, and help in making `cw` a more comprehensive tool for the crypto community!
|
|
265
265
|
|
|
266
266
|
## Contributing
|
|
267
267
|
|
package/cli.js
CHANGED
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
// filter out unwanted "bigint" warning messages
|
|
5
|
-
const originalStderrWrite = process.stderr.write;
|
|
6
|
-
process.stderr.write = function (chunk, encoding, callback) {
|
|
7
|
-
const msg = chunk.toString();
|
|
8
|
-
if (msg.includes('bigint: Failed to load bindings')) return;
|
|
9
|
-
originalStderrWrite.apply(process.stderr, arguments);
|
|
10
|
-
};
|
|
11
|
-
|
|
12
4
|
import os from 'node:os';
|
|
13
5
|
import {
|
|
14
6
|
Worker,
|
|
@@ -17,24 +9,23 @@ import {
|
|
|
17
9
|
workerData,
|
|
18
10
|
} from 'node:worker_threads';
|
|
19
11
|
import { fileURLToPath } from 'node:url';
|
|
20
|
-
import chalk from 'chalk';
|
|
21
12
|
import { options } from './src/options.js';
|
|
22
|
-
import { log, supportedChains } from './src/utils.js';
|
|
13
|
+
import { exit, log, supportedChains } from './src/utils.js';
|
|
23
14
|
import Method from './src/Method.js';
|
|
15
|
+
import chalk from 'chalk';
|
|
24
16
|
|
|
25
17
|
// get the current file path
|
|
26
18
|
const __filename = fileURLToPath(import.meta.url);
|
|
27
19
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
if (options.list !== undefined) {
|
|
20
|
+
// show all supported chains
|
|
21
|
+
if (options.list) {
|
|
31
22
|
(async () => {
|
|
32
|
-
|
|
23
|
+
await new Method('list').init();
|
|
24
|
+
exit(0);
|
|
33
25
|
})();
|
|
34
|
-
exit(0);
|
|
35
26
|
}
|
|
36
27
|
|
|
37
|
-
// generate mnemonic string
|
|
28
|
+
// generate mnemonic string
|
|
38
29
|
if (
|
|
39
30
|
options.mnemonic &&
|
|
40
31
|
(options.mnemonic === true ||
|
|
@@ -42,32 +33,35 @@ if (
|
|
|
42
33
|
options.mnemonic.split(' ').length === 1)
|
|
43
34
|
) {
|
|
44
35
|
(async () => {
|
|
45
|
-
|
|
36
|
+
new Method('mnemonic').init({
|
|
46
37
|
mnemonic: options.mnemonic,
|
|
47
38
|
copy: options?.copy || false,
|
|
48
39
|
});
|
|
40
|
+
exit(0);
|
|
49
41
|
})();
|
|
50
|
-
exit(0);
|
|
51
42
|
}
|
|
52
43
|
|
|
44
|
+
// show the version number
|
|
53
45
|
if (options.version) {
|
|
54
46
|
(async () => {
|
|
55
|
-
|
|
47
|
+
new Method('version').init();
|
|
48
|
+
exit(0);
|
|
56
49
|
})();
|
|
57
|
-
exit(0);
|
|
58
50
|
}
|
|
59
51
|
|
|
52
|
+
// show donation message
|
|
60
53
|
if (options.donate) {
|
|
61
54
|
(async () => {
|
|
62
|
-
|
|
55
|
+
new Method('donate').init();
|
|
56
|
+
exit(0);
|
|
63
57
|
})();
|
|
64
|
-
exit(0);
|
|
65
58
|
}
|
|
66
59
|
|
|
60
|
+
// generate a wallet
|
|
67
61
|
const chain = (options.chain.toUpperCase() || 'EVM').trim();
|
|
68
62
|
if (!supportedChains.includes(chain)) {
|
|
69
63
|
log(chalk.red('⛔️ Error: this chain is not supported!'));
|
|
70
|
-
|
|
64
|
+
exit(1);
|
|
71
65
|
}
|
|
72
66
|
options.b = chain; // ensure the chain is passed to the Method class
|
|
73
67
|
|
|
@@ -75,7 +69,7 @@ options.b = chain; // ensure the chain is passed to the Method class
|
|
|
75
69
|
const allMachineThreads = os.cpus().length;
|
|
76
70
|
const availableThreads = os.cpus().length - 1; // leave 1 core for the main thread
|
|
77
71
|
const defaultThreads = os.cpus().length / 2; // use half of the available threads
|
|
78
|
-
const inputThreads = parseInt(options.threads ||
|
|
72
|
+
const inputThreads = parseInt(options.threads || defaultThreads, 10); // user input threads
|
|
79
73
|
let numThreads = defaultThreads; // default to half of the available threads
|
|
80
74
|
if (inputThreads > availableThreads) {
|
|
81
75
|
numThreads = defaultThreads;
|
|
@@ -90,13 +84,15 @@ if (isMainThread) {
|
|
|
90
84
|
console.log(
|
|
91
85
|
chalk.green(
|
|
92
86
|
'🐢 Using only 1 thread to generate a wallet, this might take a while...'
|
|
93
|
-
)
|
|
87
|
+
),
|
|
88
|
+
chalk.gray(`(pass "-t ${availableThreads}" to use all available threads)`)
|
|
94
89
|
);
|
|
95
90
|
} else {
|
|
96
91
|
console.log(
|
|
97
92
|
chalk.green(
|
|
98
93
|
`⚡ Using ${numThreads}/${allMachineThreads} threads to generate a wallet...`
|
|
99
|
-
)
|
|
94
|
+
),
|
|
95
|
+
chalk.gray(`(pass "-t ${availableThreads}" to use all available threads)`)
|
|
100
96
|
);
|
|
101
97
|
}
|
|
102
98
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yerofey/cryptowallet-cli",
|
|
3
|
-
"version": "1.38.
|
|
3
|
+
"version": "1.38.2",
|
|
4
4
|
"description": "Crypto wallet generator CLI tool",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"homepage": "https://github.com/yerofey/cryptowallet-cli",
|
|
@@ -41,7 +41,6 @@
|
|
|
41
41
|
}
|
|
42
42
|
],
|
|
43
43
|
"bin": {
|
|
44
|
-
"cryptowallet": "cli.js",
|
|
45
44
|
"cw": "cli.js"
|
|
46
45
|
},
|
|
47
46
|
"engines": {
|
|
@@ -58,6 +57,7 @@
|
|
|
58
57
|
"./src/"
|
|
59
58
|
],
|
|
60
59
|
"keywords": [
|
|
60
|
+
"cw",
|
|
61
61
|
"cli",
|
|
62
62
|
"cli-app",
|
|
63
63
|
"console",
|
|
@@ -133,7 +133,6 @@
|
|
|
133
133
|
"ed25519-hd-key": "^1.3.0",
|
|
134
134
|
"eth-lib": "0.1.29",
|
|
135
135
|
"ethereum-bip84": "0.0.3",
|
|
136
|
-
"ethereum-cryptography": "^3.0.0",
|
|
137
136
|
"ethereum-mnemonic-privatekey-utils": "1.0.5",
|
|
138
137
|
"qrcode-terminal": "^0.12.0",
|
|
139
138
|
"tezos-sign": "1.4.1",
|
package/src/Method.js
CHANGED
|
@@ -5,11 +5,12 @@ import clipboardy from 'clipboardy';
|
|
|
5
5
|
import columnify from 'columnify';
|
|
6
6
|
import CsvWriter from 'csv-writer';
|
|
7
7
|
import qr from 'qrcode-terminal';
|
|
8
|
-
import { log, supportedChains, loadJson } from './utils.js';
|
|
9
|
-
import { generateMnemonicString } from './Wallet.js';
|
|
10
8
|
import CW from './CW.js';
|
|
9
|
+
import { generateMnemonicString } from './Wallet.js';
|
|
10
|
+
import { log, supportedChains, loadJson } from './utils.js';
|
|
11
11
|
|
|
12
12
|
config();
|
|
13
|
+
|
|
13
14
|
const {
|
|
14
15
|
blue,
|
|
15
16
|
green,
|
|
@@ -53,7 +54,7 @@ class Method {
|
|
|
53
54
|
for (const val of supportedChains) {
|
|
54
55
|
// eslint-disable-next-line no-undef
|
|
55
56
|
const data = await loadJson(
|
|
56
|
-
`${path.dirname(import.meta.url)}
|
|
57
|
+
`${path.dirname(import.meta.url)}${path.sep}chains${path.sep}${val}.json`.replace(
|
|
57
58
|
'file://',
|
|
58
59
|
''
|
|
59
60
|
)
|
package/src/Wallet.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { config } from 'dotenv';
|
|
3
3
|
import { log } from './utils.js';
|
|
4
4
|
import chalk from 'chalk';
|
|
5
|
-
const { red, yellow } = chalk;
|
|
5
|
+
const { red, yellow, gray } = chalk;
|
|
6
6
|
import CoinKey from 'coinkey';
|
|
7
7
|
import CoinInfo from 'coininfo';
|
|
8
8
|
import bip39 from 'bip39';
|
|
@@ -21,7 +21,6 @@ import { Account } from 'eth-lib/lib/index.js';
|
|
|
21
21
|
import { Wallet as HarmonyWallet } from '@harmony-js/account';
|
|
22
22
|
import pkutils from 'ethereum-mnemonic-privatekey-utils';
|
|
23
23
|
import bCrypto from '@binance-chain/javascript-sdk/lib/crypto/index.js';
|
|
24
|
-
import { HDKey } from 'ethereum-cryptography/hdkey.js';
|
|
25
24
|
import tronWeb from 'tronweb';
|
|
26
25
|
import tezos from 'tezos-sign';
|
|
27
26
|
import {
|
|
@@ -112,7 +111,9 @@ class Wallet {
|
|
|
112
111
|
if (options.prefix && options.suffix) {
|
|
113
112
|
// prefix & suffix
|
|
114
113
|
log(
|
|
115
|
-
|
|
114
|
+
gray(
|
|
115
|
+
`⏳ Generating wallet with "${options.prefix}" prefix and "${options.suffix}" suffix, this for sure will take a while...`
|
|
116
|
+
)
|
|
116
117
|
);
|
|
117
118
|
onlyBoth = true;
|
|
118
119
|
} else {
|
|
@@ -123,7 +124,9 @@ class Wallet {
|
|
|
123
124
|
RegExp(row.rareSymbols, 'g').test(options.prefix))
|
|
124
125
|
) {
|
|
125
126
|
log(
|
|
126
|
-
|
|
127
|
+
gray(
|
|
128
|
+
`⏳ Generating wallet with "${options.prefix}" prefix, this might take a while...`
|
|
129
|
+
)
|
|
127
130
|
);
|
|
128
131
|
onlyPrefix = true;
|
|
129
132
|
}
|
|
@@ -134,7 +137,9 @@ class Wallet {
|
|
|
134
137
|
RegExp(row.rareSymbols, 'g').test(options.suffix))
|
|
135
138
|
) {
|
|
136
139
|
log(
|
|
137
|
-
|
|
140
|
+
gray(
|
|
141
|
+
`⏳ Generating wallet with "${options.suffix}" suffix, this might take a while...`
|
|
142
|
+
)
|
|
138
143
|
);
|
|
139
144
|
onlySuffix = true;
|
|
140
145
|
}
|
|
@@ -626,7 +631,8 @@ class Wallet {
|
|
|
626
631
|
// Generate mnemonic if not provided
|
|
627
632
|
const mnemonic = mnemonicString || bip39.generateMnemonic();
|
|
628
633
|
// Generate Tron address from private key
|
|
629
|
-
const wallet =
|
|
634
|
+
const wallet =
|
|
635
|
+
tronWeb.utils.accounts.generateAccountWithMnemonic(mnemonic);
|
|
630
636
|
|
|
631
637
|
Object.assign(result, {
|
|
632
638
|
addresses: [
|
package/src/chains/TRX.json
CHANGED
package/src/options.js
CHANGED
|
@@ -38,7 +38,7 @@ program.option(
|
|
|
38
38
|
'-t, --threads <threads>',
|
|
39
39
|
'Number of threads (cores) to use for wallet generation'
|
|
40
40
|
);
|
|
41
|
-
program.option('-v, --version', 'Display
|
|
41
|
+
program.option('-v, --version', 'Display package version');
|
|
42
42
|
program.option('--donate', 'Donate to the project');
|
|
43
43
|
program.parse();
|
|
44
44
|
|
package/src/utils.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { readdirSync, statSync } from 'node:fs';
|
|
2
2
|
import { readFile } from 'node:fs/promises';
|
|
3
|
-
import path from 'node:path';
|
|
4
3
|
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import path from 'node:path';
|
|
5
5
|
|
|
6
6
|
const log = console.log;
|
|
7
|
+
const exit = process.exit;
|
|
7
8
|
|
|
8
9
|
const dirname = (metaUrl) => {
|
|
9
10
|
const __filename = fileURLToPath(metaUrl);
|
|
@@ -49,4 +50,4 @@ supportedChains = filesList(chainsFolder).map((item) => {
|
|
|
49
50
|
.replace('.json', '');
|
|
50
51
|
});
|
|
51
52
|
|
|
52
|
-
export { log, loadFile, loadJson, objectHasAllKeys, supportedChains };
|
|
53
|
+
export { exit, log, loadFile, loadJson, objectHasAllKeys, supportedChains };
|