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