@yerofey/cryptowallet-cli 1.17.0 → 1.17.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 +16 -4
- package/cli.js +6 -1
- package/package.json +1 -1
- package/src/utils.js +9 -5
package/README.md
CHANGED
|
@@ -43,6 +43,16 @@ $ cw
|
|
|
43
43
|
# generate random BTC wallet (default format: bech32 - "bc1q...")
|
|
44
44
|
$ cw -c btc
|
|
45
45
|
|
|
46
|
+
# generate random mnemonic string (12 words) to import in any wallet app
|
|
47
|
+
$ cw -m
|
|
48
|
+
|
|
49
|
+
# generate random mnemonic string of a specific length (12, 18, or 24 words)
|
|
50
|
+
$ cw -m 18
|
|
51
|
+
$ cw -m 24
|
|
52
|
+
|
|
53
|
+
# generate a wallet from a given mnemonic string
|
|
54
|
+
$ cw -m "radio bright pizza pluck family crawl palm flame forget focus stock stadium"
|
|
55
|
+
|
|
46
56
|
# generate N random wallets (default coin is ETH/ERC-like)
|
|
47
57
|
$ cw -n 10
|
|
48
58
|
|
|
@@ -88,9 +98,6 @@ $ cw -c btc --csv
|
|
|
88
98
|
# generate few wallets and save the output into CSV file with custom name "new.csv"
|
|
89
99
|
$ cw -c btc -n 10 -D new
|
|
90
100
|
|
|
91
|
-
# generate just a mnemonic string (12 words) to import in any wallet app
|
|
92
|
-
$ cw -m
|
|
93
|
-
|
|
94
101
|
# list all supported blockchains
|
|
95
102
|
$ cw -l
|
|
96
103
|
```
|
|
@@ -133,7 +140,12 @@ $ cw -l
|
|
|
133
140
|
- `-f` or `--format`: Specify the blockchain wallet format (for BTC: legacy, segwit, bech32)
|
|
134
141
|
- `-g` or `--geek`: Display some additional "geeky" info
|
|
135
142
|
- `-l` or `--list`: List all supported blockchains
|
|
136
|
-
- `-m` or `--mnemonic`:
|
|
143
|
+
- `-m` or `--mnemonic [value]`: If used without a value or with `12`, `18`, or `24`, it generates a mnemonic string of that length. If a mnemonic string is provided, it generates a wallet from the given mnemonic. For example:
|
|
144
|
+
- `$ cw -m`: Generates a default 12-word mnemonic string.
|
|
145
|
+
- `$ cw -m 12`: Generates a 12-word mnemonic string.
|
|
146
|
+
- `$ cw -m 18`: Generates an 18-word mnemonic string.
|
|
147
|
+
- `$ cw -m 24`: Generates a 24-word mnemonic string.
|
|
148
|
+
- `$ cw -m "your mnemonic phrase here"`: Generates a wallet from the provided mnemonic string.
|
|
137
149
|
- `-n` or `--number`: Specify number of wallets to display (works for HD wallets only, like BTC/LTC/DOGE)
|
|
138
150
|
- `-p` or `--prefix`: Specify desired prefix for the wallet address (**case-insensitive**)
|
|
139
151
|
- `-P` or `--prefix-sensitive`: Specify desired prefix of the wallet address (**case-sensitive**)
|
package/cli.js
CHANGED
|
@@ -12,7 +12,12 @@ import Method from './src/Method.js';
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
// generate mnemonic string if no argument is passed or only the mnemonic length is passed
|
|
15
|
-
if (
|
|
15
|
+
if (
|
|
16
|
+
options.mnemonic &&
|
|
17
|
+
(options.mnemonic === true ||
|
|
18
|
+
options.mnemonic === '' ||
|
|
19
|
+
options.mnemonic.split(' ').length === 1)
|
|
20
|
+
) {
|
|
16
21
|
return new Method('mnemonic').init({ mnemonic: options.mnemonic });
|
|
17
22
|
}
|
|
18
23
|
|
package/package.json
CHANGED
package/src/utils.js
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import { readdirSync, statSync } from 'node:fs';
|
|
2
2
|
import { readFile } from 'node:fs/promises';
|
|
3
3
|
import path from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
4
5
|
|
|
5
6
|
const log = console.log;
|
|
6
7
|
|
|
8
|
+
const dirname = (metaUrl) => {
|
|
9
|
+
const __filename = fileURLToPath(metaUrl);
|
|
10
|
+
const __dirname = path.dirname(__filename);
|
|
11
|
+
return __dirname;
|
|
12
|
+
};
|
|
13
|
+
|
|
7
14
|
const filesList = (dir) => {
|
|
8
15
|
return readdirSync(dir).reduce((list, file) => {
|
|
9
16
|
const name = path.join(dir, file);
|
|
@@ -29,12 +36,9 @@ const objectHasAllKeys = (obj, keysArray) =>
|
|
|
29
36
|
keysArray.every((item) => obj.hasOwnProperty(item));
|
|
30
37
|
|
|
31
38
|
let supportedChains = [];
|
|
32
|
-
|
|
33
|
-
const chainsFolder = `${path.dirname(
|
|
34
|
-
decodeURIComponent(import.meta.url)
|
|
35
|
-
)}/chains/`.replace('file://', '');
|
|
39
|
+
const chainsFolder = path.join(dirname(import.meta.url), 'chains');
|
|
36
40
|
supportedChains = filesList(chainsFolder).map((item) =>
|
|
37
|
-
item.replace(chainsFolder, '').replace('.json', '')
|
|
41
|
+
item.replace(chainsFolder, '').replace('.json', '').replace('/', '')
|
|
38
42
|
);
|
|
39
43
|
|
|
40
44
|
export { log, loadFile, loadJson, objectHasAllKeys, supportedChains };
|