@yerofey/cryptowallet-cli 1.6.2 → 1.7.1
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 +68 -58
- package/cli.js +51 -33
- package/package.json +14 -11
- package/src/CW.js +37 -34
- package/src/Chain.js +33 -23
- package/src/Method.js +380 -221
- package/src/Wallet.js +471 -351
- package/src/chains/BCH.json +7 -10
- package/src/chains/BLK.json +7 -10
- package/src/chains/BNB.json +27 -57
- package/src/chains/BTC.json +32 -55
- package/src/chains/BTG.json +7 -10
- package/src/chains/DASH.json +7 -10
- package/src/chains/DCR.json +7 -10
- package/src/chains/DGB.json +7 -10
- package/src/chains/DOGE.json +31 -52
- package/src/chains/ERC.json +7 -16
- package/src/chains/ETC.json +12 -20
- package/src/chains/ETH.json +7 -15
- package/src/chains/LTC.json +32 -55
- package/src/chains/MONA.json +7 -10
- package/src/chains/NBT.json +7 -10
- package/src/chains/NMC.json +7 -10
- package/src/chains/ONE.json +7 -14
- package/src/chains/POLYGON.json +7 -15
- package/src/chains/PPC.json +7 -10
- package/src/chains/QTUM.json +7 -10
- package/src/chains/RDD.json +7 -10
- package/src/chains/TRX.json +7 -13
- package/src/chains/VIA.json +7 -10
- package/src/chains/VTC.json +7 -10
- package/src/chains/XTZ.json +6 -9
- package/src/chains/ZEC.json +7 -10
- package/src/utils.js +41 -15
package/README.md
CHANGED
|
@@ -7,19 +7,24 @@
|
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## Install
|
|
10
|
-
```bash
|
|
11
|
-
# via Yarn
|
|
12
|
-
$ yarn global add @yerofey/cryptowallet-cli
|
|
13
10
|
|
|
11
|
+
```bash
|
|
14
12
|
# via NPM
|
|
15
13
|
$ npm i -g @yerofey/cryptowallet-cli
|
|
16
14
|
|
|
15
|
+
# via PNPM
|
|
16
|
+
$ pnpm add -g @yerofey/cryptowallet-cli
|
|
17
|
+
|
|
18
|
+
# via Yarn
|
|
19
|
+
$ yarn global add @yerofey/cryptowallet-cli
|
|
20
|
+
|
|
17
21
|
# via Homebrew
|
|
18
22
|
$ brew tap yerofey/cryptowallet && brew install cryptowallet
|
|
19
23
|
# (it is building from scratch, so might took a while - like a minute or so)
|
|
20
24
|
```
|
|
21
25
|
|
|
22
26
|
## Usage
|
|
27
|
+
|
|
23
28
|
```bash
|
|
24
29
|
# generate random ERC-like wallet (ETH, BNB, POLYGON, ...)
|
|
25
30
|
$ cw
|
|
@@ -68,72 +73,77 @@ $ cw -l
|
|
|
68
73
|
```
|
|
69
74
|
|
|
70
75
|
## Blockchains supported
|
|
71
|
-
|
|
72
|
-
-
|
|
73
|
-
-
|
|
74
|
-
-
|
|
75
|
-
-
|
|
76
|
-
-
|
|
77
|
-
-
|
|
78
|
-
-
|
|
79
|
-
-
|
|
80
|
-
-
|
|
81
|
-
-
|
|
82
|
-
-
|
|
83
|
-
-
|
|
84
|
-
-
|
|
85
|
-
-
|
|
86
|
-
-
|
|
87
|
-
-
|
|
88
|
-
-
|
|
89
|
-
-
|
|
90
|
-
-
|
|
91
|
-
-
|
|
92
|
-
-
|
|
93
|
-
-
|
|
94
|
-
-
|
|
95
|
-
|
|
96
|
-
|
|
76
|
+
|
|
77
|
+
- `BTC` (Bitcoin) [legacy, segwit, bech32]
|
|
78
|
+
- `ETH` (Ethereum)
|
|
79
|
+
- `BNB` (Binance Coin) [BEP2, BEP20, ERC20]
|
|
80
|
+
- `DOGE` (Dogecoin) [legacy, segwit, bech32]
|
|
81
|
+
- `BCH` (Bitcoin Cash)
|
|
82
|
+
- `LTC` (Litecoin) [legacy, segwit, bech32]
|
|
83
|
+
- `POLYGON` (Polygon)
|
|
84
|
+
- `TRX` (Tron)
|
|
85
|
+
- `XTZ` (Tezos)
|
|
86
|
+
- `DASH` (Dash)
|
|
87
|
+
- `DCR` (Decred)
|
|
88
|
+
- `ZEC` (Zcash)
|
|
89
|
+
- `QTUM` (Qtum)
|
|
90
|
+
- `BTG` (Bitcoin Gold)
|
|
91
|
+
- `ONE` (Harmony)
|
|
92
|
+
- `DGB` (DigiByte)
|
|
93
|
+
- `RDD` (ReddCoin)
|
|
94
|
+
- `VTC` (Vertcoin)
|
|
95
|
+
- `MONA` (MonaCoin)
|
|
96
|
+
- `NMC` (NameCoin)
|
|
97
|
+
- `PPC` (PeerCoin)
|
|
98
|
+
- `BLK` (BlackCoin)
|
|
99
|
+
- `VIA` (Viacoin)
|
|
100
|
+
- `NBT` (NIX Bridge Token)
|
|
101
|
+
|
|
102
|
+
_\*all other cryptos that are tokens in the ecosystems like Ethereum, Binance Smart Chain or Polygon and others (EVM compatible) are supported too, you just need to create ERC wallet (that is set by default)_
|
|
97
103
|
|
|
98
104
|
## Options
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
105
|
+
|
|
106
|
+
- `-b` or `-c` or `--chain`: Specify the blockchain ticker to generate a wallet for
|
|
107
|
+
- `-f` or `--format`: Specify the blockchain wallet format (for BTC: legacy, segwit, bech32)
|
|
108
|
+
- `-F` or `--filename`: Specify a filename (without extension) to output the data (works only with `-o` argument)
|
|
109
|
+
- `-g` or `--geek`: Display some additional "geeky" info
|
|
110
|
+
- `-l` or `--list`: List all supported blockchains
|
|
111
|
+
- `-m` or `--mnemonic`: Use a bip39 mnemonic phrase (if is set) to generate wallet, or leave it empty to generate new one
|
|
112
|
+
- `-n` or `--number`: Specify number of wallets to display (works for HD wallets only, like BTC/LTC/DOGE)
|
|
113
|
+
- `-o` or `--output`: Specify a file format (currently only `csv` supported) to output the generated data
|
|
114
|
+
- `-p` or `--prefix`: Specify desired prefix for the wallet address (**case-insensitive**)
|
|
115
|
+
- `-P` or `--prefix-sensitive`: Specify desired prefix of the wallet address (**case-sensitive**)
|
|
116
|
+
- `-s` or `--suffix`: Specify desired suffix for the wallet address (**case-insensitive**)
|
|
117
|
+
- `-S` or `--suffix-sensitive`: Specify desired suffix for the wallet address (**case-sensitive**)
|
|
118
|
+
- `-v` or `--version`: Display current version of CW tool
|
|
112
119
|
|
|
113
120
|
## Tested setups
|
|
114
|
-
|
|
115
|
-
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
*
|
|
119
|
-
- [x] v1.23.0
|
|
121
|
+
|
|
122
|
+
- Node.js
|
|
123
|
+
|
|
124
|
+
* [x] v16.12.0
|
|
125
|
+
* [x] v16.16.0
|
|
120
126
|
|
|
121
127
|
## Highlights
|
|
122
|
-
|
|
123
|
-
-
|
|
124
|
-
-
|
|
125
|
-
-
|
|
126
|
-
-
|
|
128
|
+
|
|
129
|
+
- 24+ blockchains supported
|
|
130
|
+
- Generate wallet with desired prefix/suffix
|
|
131
|
+
- Generate wallet from mnemonic
|
|
132
|
+
- Generate just a mnemonic
|
|
133
|
+
- Works fully offline
|
|
127
134
|
|
|
128
135
|
## TODO
|
|
129
|
-
|
|
130
|
-
-
|
|
131
|
-
- SegWit Bech32
|
|
132
|
-
-
|
|
133
|
-
-
|
|
136
|
+
|
|
137
|
+
- Windows support
|
|
138
|
+
- Show SegWit Bech32 BTC change addresses with additional flag
|
|
139
|
+
- SegWit Bech32 wallet address support for all Bitcoin forks
|
|
140
|
+
- More EVM compatible cryptos
|
|
141
|
+
- tests
|
|
134
142
|
|
|
135
143
|
## Author
|
|
144
|
+
|
|
136
145
|
[Yerofey S.](https://github.com/yerofey)
|
|
137
146
|
|
|
138
147
|
## License
|
|
148
|
+
|
|
139
149
|
[MIT](https://github.com/yerofey/cryptowallet-cli/blob/master/LICENSE)
|
package/cli.js
CHANGED
|
@@ -1,49 +1,67 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
import { program } from 'commander';
|
|
5
|
+
import chalk from 'chalk';
|
|
6
|
+
import { log, supportedChains } from './src/utils.js';
|
|
7
|
+
import Method from './src/Method.js';
|
|
8
8
|
|
|
9
9
|
program.option('-b, --chain <ticker>', 'Wallet for specific blockchain', 'ERC');
|
|
10
10
|
program.option('-c, --chain <ticker>', 'Wallet for specific blockchain', 'ERC');
|
|
11
|
-
program.option(
|
|
12
|
-
|
|
11
|
+
program.option(
|
|
12
|
+
'-f, --format <format>',
|
|
13
|
+
'Wallet format type (for cryptos with multiple wallet formats)'
|
|
14
|
+
);
|
|
15
|
+
program.option(
|
|
16
|
+
'-F, --filename <filename>',
|
|
17
|
+
'Filename to output the data (works with -o argument)'
|
|
18
|
+
);
|
|
13
19
|
program.option('-g, --geek', 'Display some more info (geeky)');
|
|
14
20
|
program.option('-l, --list', 'List all supported cryptos');
|
|
15
|
-
program.option(
|
|
16
|
-
|
|
21
|
+
program.option(
|
|
22
|
+
'-m, --mnemonic [mnemonic]',
|
|
23
|
+
'Generate wallet from mnemonic string OR just a mnemonic string'
|
|
24
|
+
);
|
|
25
|
+
program.option(
|
|
26
|
+
'-n, --number <number>',
|
|
27
|
+
'Number of wallets to generate (if supported)'
|
|
28
|
+
);
|
|
17
29
|
program.option('-o, --output <format>', 'Return results into some file');
|
|
18
30
|
program.option('-p, --prefix <prefix>', 'Desired wallet prefix');
|
|
19
|
-
program.option(
|
|
31
|
+
program.option(
|
|
32
|
+
'-P, --prefix-sensitive <prefix>',
|
|
33
|
+
'Desired wallet prefix (case-sensitive)'
|
|
34
|
+
);
|
|
20
35
|
program.option('-s, --suffix <suffix>', 'Desired wallet suffix');
|
|
21
|
-
program.option(
|
|
36
|
+
program.option(
|
|
37
|
+
'-S, --suffix-sensitive <suffix>',
|
|
38
|
+
'Desired wallet suffix (case-sensitive)'
|
|
39
|
+
);
|
|
22
40
|
program.option('-v, --version', 'Display cryptowallet version');
|
|
23
41
|
program.parse();
|
|
24
42
|
|
|
25
43
|
(async () => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
const options = program.opts();
|
|
45
|
+
|
|
46
|
+
if (options.list !== undefined) {
|
|
47
|
+
return new Method('list').init();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (options.mnemonic == true) {
|
|
51
|
+
return new Method('mnemonic').init();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (options.version) {
|
|
55
|
+
return new Method('version').init();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const chain = options.chain.toUpperCase() || '';
|
|
59
|
+
if (supportedChains.includes(chain)) {
|
|
60
|
+
return new Method('wallet', {
|
|
61
|
+
chain,
|
|
62
|
+
options,
|
|
63
|
+
}).init();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
log(chalk.red('⛔️ Error: this blockchain is not supported!'));
|
|
49
67
|
})();
|
package/package.json
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yerofey/cryptowallet-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.1",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"homepage": "https://github.com/yerofey/cryptowallet-cli",
|
|
5
6
|
"author": "Yerofey S. <pm@yerofey.dev> (https://github.com/yerofey)",
|
|
7
|
+
"license": "MIT",
|
|
6
8
|
"bin": {
|
|
7
9
|
"cryptowallet": "cli.js",
|
|
8
10
|
"cw": "cli.js"
|
|
9
11
|
},
|
|
10
12
|
"engines": {
|
|
11
|
-
"node": ">=
|
|
13
|
+
"node": ">=14.13.1"
|
|
12
14
|
},
|
|
13
15
|
"scripts": {
|
|
14
16
|
"build:release": "./bin/generate.sh",
|
|
17
|
+
"lint": "pnpm exec eslint src/*.js",
|
|
15
18
|
"test": "ava"
|
|
16
19
|
},
|
|
17
20
|
"files": [
|
|
@@ -55,27 +58,27 @@
|
|
|
55
58
|
"bip39",
|
|
56
59
|
"bip84"
|
|
57
60
|
],
|
|
58
|
-
"license": "MIT",
|
|
59
61
|
"dependencies": {
|
|
60
|
-
"@binance-chain/javascript-sdk": "^4.
|
|
62
|
+
"@binance-chain/javascript-sdk": "^4.2.0",
|
|
61
63
|
"@harmony-js/account": "^0.1.57",
|
|
62
64
|
"@yerofey/dogecoin-bip84": "^0.0.5",
|
|
63
65
|
"@yerofey/litecoin-bip84": "^0.0.5",
|
|
64
66
|
"bip39": "3.0.4",
|
|
65
|
-
"bip84": "0.2.
|
|
66
|
-
"chalk": "
|
|
67
|
-
"coininfo": "5.1
|
|
67
|
+
"bip84": "0.2.7",
|
|
68
|
+
"chalk": "5.0.1",
|
|
69
|
+
"coininfo": "5.2.1",
|
|
68
70
|
"coinkey": "3.0.0",
|
|
69
|
-
"columnify": "1.
|
|
70
|
-
"commander": "
|
|
71
|
+
"columnify": "1.6.0",
|
|
72
|
+
"commander": "9.4.0",
|
|
71
73
|
"csv-writer": "^1.6.0",
|
|
72
74
|
"eth-lib": "0.1.29",
|
|
73
75
|
"ethereum-bip84": "0.0.3",
|
|
74
76
|
"ethereum-mnemonic-privatekey-utils": "1.0.5",
|
|
75
77
|
"tezos-sign": "1.4.1",
|
|
76
|
-
"tronweb": "4.
|
|
78
|
+
"tronweb": "4.4.0"
|
|
77
79
|
},
|
|
78
80
|
"devDependencies": {
|
|
79
|
-
"ava": "^3.
|
|
81
|
+
"ava": "^4.3.3",
|
|
82
|
+
"eslint": "^8.24.0"
|
|
80
83
|
}
|
|
81
84
|
}
|
package/src/CW.js
CHANGED
|
@@ -1,42 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import Chain from './Chain.js';
|
|
2
|
+
import { Wallet } from './Wallet.js';
|
|
3
3
|
|
|
4
4
|
class CW {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
this.chain = chain;
|
|
27
|
-
this.options = options;
|
|
28
|
-
this.row = new Chain(chain, options.format).row;
|
|
5
|
+
constructor(chain, options = {}) {
|
|
6
|
+
const defaultValues = {
|
|
7
|
+
chain: chain || options.chain || '',
|
|
8
|
+
filename: 'output',
|
|
9
|
+
format: '',
|
|
10
|
+
geek: false,
|
|
11
|
+
mnemonic: '',
|
|
12
|
+
number: 1,
|
|
13
|
+
output: undefined,
|
|
14
|
+
prefix: options.prefixSensitive || '',
|
|
15
|
+
prefixIsCaseSensitive: options.prefixSensitive !== undefined,
|
|
16
|
+
suffix: options.suffixSensitive || '',
|
|
17
|
+
suffixIsCaseSensitive: options.suffixSensitive !== undefined,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
for (const key of Object.keys(defaultValues)) {
|
|
21
|
+
// eslint-disable-next-line no-prototype-builtins
|
|
22
|
+
if (!options.hasOwnProperty(key)) {
|
|
23
|
+
options[key] = defaultValues[key];
|
|
24
|
+
}
|
|
29
25
|
}
|
|
30
26
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
27
|
+
this.chain = chain;
|
|
28
|
+
this.options = options;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async init() {
|
|
32
|
+
const chainData = await new Chain(this.chain, this.options.format).init();
|
|
33
|
+
this.row = chainData.row || {};
|
|
37
34
|
|
|
38
|
-
|
|
35
|
+
const w = await new Wallet(this).init();
|
|
36
|
+
|
|
37
|
+
for (const key of Object.keys(w)) {
|
|
38
|
+
this[key] = w[key];
|
|
39
39
|
}
|
|
40
|
+
|
|
41
|
+
return this;
|
|
42
|
+
}
|
|
40
43
|
}
|
|
41
44
|
|
|
42
|
-
|
|
45
|
+
export default CW;
|
package/src/Chain.js
CHANGED
|
@@ -1,28 +1,38 @@
|
|
|
1
|
+
import { loadJson } from './utils.js';
|
|
2
|
+
|
|
1
3
|
class Chain {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
if (format != '' && format != content.defaultFormat) {
|
|
7
|
-
// case-insensitive format
|
|
8
|
-
for (const key of Object.keys(content.formats)) {
|
|
9
|
-
if (format.toLowerCase() == key.toLowerCase()) {
|
|
10
|
-
return content.formats[key];
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
return content.formats[content.defaultFormat];
|
|
16
|
-
}
|
|
4
|
+
constructor(chain, format) {
|
|
5
|
+
this.chain = chain;
|
|
6
|
+
this.format = format;
|
|
7
|
+
}
|
|
17
8
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
9
|
+
async init() {
|
|
10
|
+
// eslint-disable-next-line no-undef
|
|
11
|
+
const content = await loadJson(`${process.cwd()}/src/chains/${this.chain}.json`);
|
|
12
|
+
const data = (() => {
|
|
13
|
+
if (content.formats !== undefined) {
|
|
14
|
+
if (this.format != '' && this.format != content.defaultFormat) {
|
|
15
|
+
// case-insensitive format
|
|
16
|
+
for (const key of Object.keys(content.formats)) {
|
|
17
|
+
if (this.format.toLowerCase() == key.toLowerCase()) {
|
|
18
|
+
return content.formats[key];
|
|
19
|
+
}
|
|
20
|
+
}
|
|
24
21
|
}
|
|
25
|
-
|
|
22
|
+
|
|
23
|
+
return content.formats[content.defaultFormat];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return content;
|
|
27
|
+
})();
|
|
28
|
+
|
|
29
|
+
this.row = {
|
|
30
|
+
...content,
|
|
31
|
+
...data,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
26
36
|
}
|
|
27
37
|
|
|
28
|
-
|
|
38
|
+
export default Chain;
|