@yerofey/cryptowallet-cli 1.4.1 → 1.5.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/cli.js +8 -7
- package/package.json +1 -1
- package/src/CW.js +5 -5
- package/src/{Coin.js → Chain.js} +4 -4
- package/src/Method.js +15 -15
- package/src/Wallet.js +9 -9
- package/src/{coins → chains}/BCH.json +0 -0
- package/src/{coins → chains}/BLK.json +0 -0
- package/src/{coins → chains}/BNB.json +0 -0
- package/src/{coins → chains}/BTC.json +0 -0
- package/src/{coins → chains}/BTG.json +0 -0
- package/src/{coins → chains}/DASH.json +0 -0
- package/src/{coins → chains}/DCR.json +0 -0
- package/src/{coins → chains}/DGB.json +0 -0
- package/src/{coins → chains}/DOGE.json +0 -0
- package/src/{coins → chains}/ERC.json +0 -0
- package/src/{coins → chains}/ETC.json +0 -0
- package/src/{coins → chains}/ETH.json +0 -0
- package/src/{coins → chains}/LTC.json +0 -0
- package/src/{coins → chains}/MONA.json +0 -0
- package/src/{coins → chains}/NBT.json +0 -0
- package/src/{coins → chains}/NMC.json +0 -0
- package/src/{coins → chains}/ONE.json +0 -0
- package/src/{coins → chains}/POLYGON.json +0 -0
- package/src/{coins → chains}/PPC.json +0 -0
- package/src/{coins → chains}/QTUM.json +0 -0
- package/src/{coins → chains}/RDD.json +0 -0
- package/src/{coins → chains}/TRX.json +0 -0
- package/src/{coins → chains}/VIA.json +0 -0
- package/src/{coins → chains}/VTC.json +0 -0
- package/src/{coins → chains}/XTZ.json +0 -0
- package/src/{coins → chains}/ZEC.json +0 -0
- package/src/utils.js +6 -6
package/cli.js
CHANGED
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
|
|
4
4
|
const { program } = require('commander');
|
|
5
5
|
const chalk = require('chalk');
|
|
6
|
-
const { log,
|
|
6
|
+
const { log, supportedChains } = require('./src/utils');
|
|
7
7
|
const Method = require('./src/Method');
|
|
8
8
|
|
|
9
|
-
program.option('-
|
|
9
|
+
program.option('-b, --chain <ticker>', 'Wallet for specific blockchain', 'ERC');
|
|
10
|
+
program.option('-c, --chain <ticker>', 'Wallet for specific blockchain', 'ERC');
|
|
10
11
|
program.option('-f, --format <format>', 'Wallet format type (for cryptos with multiple wallet formats)');
|
|
11
12
|
program.option('-g, --geek', 'Display some more info (geeky)');
|
|
12
13
|
program.option('-l, --list', 'List all supported cryptos');
|
|
@@ -34,13 +35,13 @@ program.parse();
|
|
|
34
35
|
return new Method('version').init();
|
|
35
36
|
}
|
|
36
37
|
|
|
37
|
-
const
|
|
38
|
-
if (
|
|
38
|
+
const chain = (options.chain).toUpperCase() || '';
|
|
39
|
+
if (supportedChains.includes(chain)) {
|
|
39
40
|
return new Method('wallet', {
|
|
40
|
-
|
|
41
|
-
options
|
|
41
|
+
chain,
|
|
42
|
+
options,
|
|
42
43
|
}).init();
|
|
43
44
|
}
|
|
44
45
|
|
|
45
|
-
log(chalk.red('⛔️ Error:
|
|
46
|
+
log(chalk.red('⛔️ Error: this blockchain is not supported!'));
|
|
46
47
|
})();
|
package/package.json
CHANGED
package/src/CW.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const
|
|
1
|
+
const Chain = require('./Chain');
|
|
2
2
|
const { Wallet } = require('./Wallet');
|
|
3
3
|
|
|
4
4
|
class CW {
|
|
5
|
-
constructor(
|
|
5
|
+
constructor(chain, options = {}) {
|
|
6
6
|
const defaultValues = {
|
|
7
|
-
|
|
7
|
+
chain: chain || options.chain || '',
|
|
8
8
|
format: '',
|
|
9
9
|
geek: false,
|
|
10
10
|
mnemonic: '',
|
|
@@ -21,9 +21,9 @@ class CW {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
this.
|
|
24
|
+
this.chain = chain;
|
|
25
25
|
this.options = options;
|
|
26
|
-
this.row = new
|
|
26
|
+
this.row = new Chain(chain, options.format).row;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
async init() {
|
package/src/{Coin.js → Chain.js}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
class
|
|
2
|
-
constructor(
|
|
3
|
-
const content = require('./
|
|
1
|
+
class Chain {
|
|
2
|
+
constructor(chain, format) {
|
|
3
|
+
const content = require('./chains/' + chain + '.json') || {};
|
|
4
4
|
const data = (() => {
|
|
5
5
|
if (content.formats !== undefined) {
|
|
6
6
|
if (format != '' && format != content.defaultFormat) {
|
|
@@ -25,4 +25,4 @@ class Coin {
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
module.exports =
|
|
28
|
+
module.exports = Chain;
|
package/src/Method.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const chalk = require('chalk');
|
|
2
2
|
const columnify = require('columnify');
|
|
3
|
-
const { log,
|
|
3
|
+
const { log, supportedChains } = require('./utils');
|
|
4
4
|
const { generateMnemonicString } = require('./Wallet');
|
|
5
5
|
const selfInfo = require('../package.json');
|
|
6
6
|
const CW = require('./CW');
|
|
@@ -15,10 +15,10 @@ class Method {
|
|
|
15
15
|
const callMethod = {
|
|
16
16
|
'_': () => {},
|
|
17
17
|
'list': () => {
|
|
18
|
-
log(`🔠 All supported
|
|
18
|
+
log(`🔠 All supported blockchains:\n`);
|
|
19
19
|
let cryptos = {};
|
|
20
|
-
for (const val of
|
|
21
|
-
const data = require('./
|
|
20
|
+
for (const val of supportedChains) {
|
|
21
|
+
const data = require('./chains/' + val + '.json');
|
|
22
22
|
let title = data.title || '';
|
|
23
23
|
if (title == '' || val == 'ERC') {
|
|
24
24
|
continue;
|
|
@@ -30,7 +30,7 @@ class Method {
|
|
|
30
30
|
columnSplitter: ' - ',
|
|
31
31
|
}));
|
|
32
32
|
log();
|
|
33
|
-
log(`ℹ️ Use flag "-c TICKER" to select specific
|
|
33
|
+
log(`ℹ️ Use flag "-c TICKER" to select specific blockchain`);
|
|
34
34
|
},
|
|
35
35
|
'mnemonic': () => {
|
|
36
36
|
log(`✨ ${chalk.green('Done!')} ${chalk.blueBright('Here is your randomly generated 12 words mnemonic string:')}\n`);
|
|
@@ -42,23 +42,23 @@ class Method {
|
|
|
42
42
|
log(selfInfo.version);
|
|
43
43
|
},
|
|
44
44
|
'wallet': async () => {
|
|
45
|
-
const
|
|
45
|
+
const chain = this.params.chain;
|
|
46
46
|
const options = this.params.options;
|
|
47
47
|
|
|
48
|
-
const cw = await new CW(
|
|
48
|
+
const cw = await new CW(chain, options).init();
|
|
49
49
|
|
|
50
|
-
let
|
|
50
|
+
let chainFullName = (cw.row.name || chain) + (cw.wallet.format !== undefined && cw.wallet.format != '' ? ' (' + cw.wallet.format + ')' : '');
|
|
51
51
|
|
|
52
52
|
if (cw.options.prefix && !cw.prefixFound) {
|
|
53
|
-
log(`😢 ${chalk.yellow('Sorry, ' +
|
|
53
|
+
log(`😢 ${chalk.yellow('Sorry, ' + chainFullName + ' does not support prefix yet...')}`);
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
if (cw.options.suffix && !cw.suffixFound) {
|
|
57
|
-
log(`😢 ${chalk.yellow('Sorry, ' +
|
|
57
|
+
log(`😢 ${chalk.yellow('Sorry, ' + chainFullName + ' does not support suffix yet...')}`);
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
if (cw.options.mnemonic != '' && cw.wallet.mnemonic == undefined) {
|
|
61
|
-
log(`😢 ${chalk.yellow('Sorry, ' +
|
|
61
|
+
log(`😢 ${chalk.yellow('Sorry, ' + chainFullName + ' does not support mnemonic yet...')}`);
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
if (cw.wallet.error !== undefined) {
|
|
@@ -68,13 +68,13 @@ class Method {
|
|
|
68
68
|
|
|
69
69
|
// prefix, suffix
|
|
70
70
|
if (cw.prefixFound && cw.suffixFound) {
|
|
71
|
-
log(`✨ ${chalk.green('Done!')} ${chalk.blueBright('Here is your brand new ' +
|
|
71
|
+
log(`✨ ${chalk.green('Done!')} ${chalk.blueBright('Here is your brand new ' + chainFullName + ' wallet with "' + cw.options.prefix + '" prefix and "' + cw.options.suffix + '" suffix:')}\n`);
|
|
72
72
|
} else if (cw.prefixFound) {
|
|
73
|
-
log(`✨ ${chalk.green('Done!')} ${chalk.blueBright('Here is your brand new ' +
|
|
73
|
+
log(`✨ ${chalk.green('Done!')} ${chalk.blueBright('Here is your brand new ' + chainFullName + ' wallet with "' + cw.options.prefix + '" prefix:')}\n`);
|
|
74
74
|
} else if (cw.suffixFound) {
|
|
75
|
-
log(`✨ ${chalk.green('Done!')} ${chalk.blueBright('Here is your brand new ' +
|
|
75
|
+
log(`✨ ${chalk.green('Done!')} ${chalk.blueBright('Here is your brand new ' + chainFullName + ' wallet with "' + cw.options.suffix + '" suffix:')}\n`);
|
|
76
76
|
} else {
|
|
77
|
-
log(`✨ ${chalk.green('Done!')} ${chalk.blueBright('Here is your brand new ' +
|
|
77
|
+
log(`✨ ${chalk.green('Done!')} ${chalk.blueBright('Here is your brand new ' + chainFullName + ' wallet:')}\n`);
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
// result
|
package/src/Wallet.js
CHANGED
|
@@ -120,7 +120,7 @@ class Wallet {
|
|
|
120
120
|
|
|
121
121
|
async createWallet() {
|
|
122
122
|
const cw = this.cw;
|
|
123
|
-
const
|
|
123
|
+
const chain = cw.chain;
|
|
124
124
|
const row = cw.row;
|
|
125
125
|
const options = cw.options;
|
|
126
126
|
|
|
@@ -131,7 +131,7 @@ class Wallet {
|
|
|
131
131
|
|
|
132
132
|
if (row.length == 0) {
|
|
133
133
|
return {
|
|
134
|
-
error: '
|
|
134
|
+
error: 'this blockchain is not found',
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
|
|
@@ -139,7 +139,7 @@ class Wallet {
|
|
|
139
139
|
const CoinKey = require('coinkey');
|
|
140
140
|
const CoinInfo = require('coininfo');
|
|
141
141
|
|
|
142
|
-
const wallet = CoinKey.createRandom(CoinInfo(
|
|
142
|
+
const wallet = CoinKey.createRandom(CoinInfo(chain).versions);
|
|
143
143
|
|
|
144
144
|
result = Object.assign(result, {
|
|
145
145
|
format,
|
|
@@ -149,7 +149,7 @@ class Wallet {
|
|
|
149
149
|
privateKey: wallet.privateWif,
|
|
150
150
|
}]
|
|
151
151
|
});
|
|
152
|
-
} else if (
|
|
152
|
+
} else if (chain == 'BTC') {
|
|
153
153
|
const bip39 = require('bip39');
|
|
154
154
|
const { fromMnemonic, fromZPrv } = require('bip84');
|
|
155
155
|
|
|
@@ -181,7 +181,7 @@ class Wallet {
|
|
|
181
181
|
privateExtendedKey: account.getAccountPrivateKey(),
|
|
182
182
|
mnemonic
|
|
183
183
|
});
|
|
184
|
-
} else if (
|
|
184
|
+
} else if (chain == 'DOGE' || chain == 'LTC') {
|
|
185
185
|
const bip39 = require('bip39');
|
|
186
186
|
const { fromMnemonic, fromZPrv } = require('@yerofey/' + row.title.toLowerCase() + '-bip84');
|
|
187
187
|
|
|
@@ -295,7 +295,7 @@ class Wallet {
|
|
|
295
295
|
addresses,
|
|
296
296
|
mnemonic,
|
|
297
297
|
});
|
|
298
|
-
} else if (
|
|
298
|
+
} else if (chain == 'ONE') {
|
|
299
299
|
const bip39 = require('bip39');
|
|
300
300
|
const { Wallet } = require('@harmony-js/account');
|
|
301
301
|
|
|
@@ -319,7 +319,7 @@ class Wallet {
|
|
|
319
319
|
}],
|
|
320
320
|
mnemonic,
|
|
321
321
|
});
|
|
322
|
-
} else if (
|
|
322
|
+
} else if (chain == 'TRX') {
|
|
323
323
|
const tronWeb = require('tronweb');
|
|
324
324
|
|
|
325
325
|
try {
|
|
@@ -337,7 +337,7 @@ class Wallet {
|
|
|
337
337
|
error
|
|
338
338
|
}
|
|
339
339
|
}
|
|
340
|
-
} else if (
|
|
340
|
+
} else if (chain == 'XTZ') {
|
|
341
341
|
const tezos = require('tezos-sign');
|
|
342
342
|
const wallet = tezos.generateKeysNoSeed();
|
|
343
343
|
|
|
@@ -350,7 +350,7 @@ class Wallet {
|
|
|
350
350
|
});
|
|
351
351
|
} else {
|
|
352
352
|
return {
|
|
353
|
-
error: '
|
|
353
|
+
error: 'your desired blockchain is not supported yet'
|
|
354
354
|
}
|
|
355
355
|
}
|
|
356
356
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/src/utils.js
CHANGED
|
@@ -13,13 +13,13 @@ const filesList = (dir) => {
|
|
|
13
13
|
|
|
14
14
|
const objectHasAllKeys = (obj, keysArray) => keysArray.every(item => obj.hasOwnProperty(item));
|
|
15
15
|
|
|
16
|
-
let
|
|
17
|
-
const
|
|
18
|
-
filesList(
|
|
19
|
-
const name = item.replace(
|
|
20
|
-
|
|
16
|
+
let supportedChains = [];
|
|
17
|
+
const chainsFolder = __dirname + '/chains/';
|
|
18
|
+
filesList(chainsFolder).forEach((item) => {
|
|
19
|
+
const name = item.replace(chainsFolder, '').replace('.json', '');
|
|
20
|
+
supportedChains.push(name);
|
|
21
21
|
});
|
|
22
22
|
|
|
23
23
|
module.exports.log = log;
|
|
24
24
|
module.exports.objectHasAllKeys = objectHasAllKeys;
|
|
25
|
-
module.exports.
|
|
25
|
+
module.exports.supportedChains = supportedChains;
|