@yerofey/cryptowallet-cli 1.6.2 → 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,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
- - `BTC` (Bitcoin) [legacy, segwit, bech32]
72
- - `ETH` (Ethereum)
73
- - `BNB` (Binance Coin) [BEP2, BEP20, ERC20]
74
- - `DOGE` (Dogecoin) [legacy, segwit, bech32]
75
- - `BCH` (Bitcoin Cash)
76
- - `LTC` (Litecoin) [legacy, segwit, bech32]
77
- - `POLYGON` (Polygon)
78
- - `TRX` (Tron)
79
- - `XTZ` (Tezos)
80
- - `DASH` (Dash)
81
- - `DCR` (Decred)
82
- - `ZEC` (Zcash)
83
- - `QTUM` (Qtum)
84
- - `BTG` (Bitcoin Gold)
85
- - `ONE` (Harmony)
86
- - `DGB` (DigiByte)
87
- - `RDD` (ReddCoin)
88
- - `VTC` (Vertcoin)
89
- - `MONA` (MonaCoin)
90
- - `NMC` (NameCoin)
91
- - `PPC` (PeerCoin)
92
- - `BLK` (BlackCoin)
93
- - `VIA` (Viacoin)
94
- - `NBT` (NIX Bridge Token)
95
-
96
- *\*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)_
97
103
 
98
104
  ## Options
99
- * `-b` or `-c` or `--chain`: Specify the blockchain ticker to generate a wallet for
100
- * `-f` or `--format`: Specify the blockchain wallet format (for BTC: legacy, segwit, bech32)
101
- * `-F` or `--filename`: Specify a filename (without extension) to output the data (works only with `-o` argument)
102
- * `-g` or `--geek`: Display some additional "geeky" info
103
- * `-l` or `--list`: List all supported blockchains
104
- * `-m` or `--mnemonic`: Use a bip39 mnemonic phrase (if is set) to generate wallet, or leave it empty to generate new one
105
- * `-n` or `--number`: Specify number of wallets to display (works for HD wallets only, like BTC/LTC/DOGE)
106
- * `-o` or `--output`: Specify a file format (currently only `csv` supported) to output the generated data
107
- * `-p` or `--prefix`: Specify desired prefix for the wallet address (**case-insensitive**)
108
- * `-P` or `--prefix-sensitive`: Specify desired prefix of the wallet address (**case-sensitive**)
109
- * `-s` or `--suffix`: Specify desired suffix for the wallet address (**case-insensitive**)
110
- * `-S` or `--suffix-sensitive`: Specify desired suffix for the wallet address (**case-sensitive**)
111
- * `-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
112
119
 
113
120
  ## Tested setups
114
- * Node
115
- - [x] v16.12.0
116
- * NPM
117
- - [x] v8.1.0
118
- * Yarn
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
- - 24+ blockchains supported
123
- - Generate wallet with desired prefix/suffix
124
- - Generate wallet from mnemonic
125
- - Generate just a mnemonic
126
- - 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
127
134
 
128
135
  ## TODO
129
- - Windows support
130
- - Show SegWit Bech32 BTC change addresses with additional flag
131
- - SegWit Bech32 wallet address support for all Bitcoin forks
132
- - More EVM compatible cryptos
133
- - 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
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
- 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,17 +1,20 @@
1
1
  {
2
2
  "name": "@yerofey/cryptowallet-cli",
3
- "version": "1.6.2",
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": {
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.1.1",
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.6",
66
- "chalk": "4.1.2",
67
- "coininfo": "5.1.0",
67
+ "bip84": "0.2.7",
68
+ "chalk": "5.0.1",
69
+ "coininfo": "5.2.1",
68
70
  "coinkey": "3.0.0",
69
- "columnify": "1.5.4",
70
- "commander": "8.1.0",
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.0.0"
78
+ "tronweb": "4.4.0"
77
79
  },
78
80
  "devDependencies": {
79
- "ava": "^3.15.0"
81
+ "ava": "^4.3.3",
82
+ "eslint": "^8.24.0"
80
83
  }
81
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;