@yerofey/cryptowallet-cli 1.2.11 → 1.4.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 +11 -9
- package/cli.js +4 -2
- package/package.json +4 -4
- package/src/CW.js +4 -2
- package/src/Method.js +29 -15
- package/src/Wallet.js +141 -36
- package/src/coins/BCH.json +2 -1
- package/src/coins/BLK.json +2 -1
- package/src/coins/BNB.json +9 -3
- package/src/coins/BTC.json +6 -3
- package/src/coins/BTG.json +2 -1
- package/src/coins/DASH.json +2 -1
- package/src/coins/DCR.json +2 -1
- package/src/coins/DGB.json +2 -1
- package/src/coins/DOGE.json +6 -3
- package/src/coins/ERC.json +3 -1
- package/src/coins/ETC.json +3 -1
- package/src/coins/ETH.json +3 -1
- package/src/coins/LTC.json +6 -3
- package/src/coins/MONA.json +2 -1
- package/src/coins/NBT.json +2 -1
- package/src/coins/NMC.json +2 -1
- package/src/coins/ONE.json +2 -1
- package/src/coins/POLYGON.json +3 -1
- package/src/coins/PPC.json +2 -1
- package/src/coins/QTUM.json +2 -1
- package/src/coins/RDD.json +2 -1
- package/src/coins/TRX.json +2 -1
- package/src/coins/VIA.json +2 -1
- package/src/coins/VTC.json +2 -1
- package/src/coins/XTZ.json +2 -1
- package/src/coins/ZEC.json +2 -1
package/README.md
CHANGED
|
@@ -23,19 +23,19 @@ $ cw
|
|
|
23
23
|
# generate random ERC-like wallet with desired prefix
|
|
24
24
|
$ cw -p aaa
|
|
25
25
|
|
|
26
|
-
# generate random BTC wallet (default format: bech32 -
|
|
26
|
+
# generate random BTC wallet (default format: bech32 - "bc1q...")
|
|
27
27
|
$ cw -c BTC
|
|
28
28
|
|
|
29
|
-
# generate random BTC wallet with desired prefix (case
|
|
29
|
+
# generate random BTC wallet with desired prefix (case-insensitive)
|
|
30
30
|
$ cw -c BTC -p ABC
|
|
31
31
|
|
|
32
|
-
# generate random BTC wallet with desired prefix (case
|
|
32
|
+
# generate random BTC wallet with desired prefix (case-sensitive)
|
|
33
33
|
$ cw -c BTC -P abc
|
|
34
34
|
|
|
35
|
-
# generate BTC legacy wallet (1...)
|
|
35
|
+
# generate BTC legacy wallet ("1...")
|
|
36
36
|
$ cw -c BTC -f legacy
|
|
37
37
|
|
|
38
|
-
# generate BTC segwit wallet (3...)
|
|
38
|
+
# generate BTC segwit wallet ("3...")
|
|
39
39
|
$ cw -c BTC -f segwit
|
|
40
40
|
|
|
41
41
|
# generate BTC bech32 wallet from mnemonic string
|
|
@@ -95,13 +95,15 @@ $ cw -l
|
|
|
95
95
|
* `-l` or `--list`: List all supported cryptocurrencies
|
|
96
96
|
* `-m` or `--mnemonic`: Use a bip39 mnemonic phrase (if is set) to generate wallet, or leave it empty to generate new one
|
|
97
97
|
* `-n` or `--number`: Specify number of wallets to display (works for HD wallets only, like BTC/LTC/DOGE)
|
|
98
|
-
* `-p` or `--prefix`: Specify desired prefix of an wallet address (case
|
|
99
|
-
* `-P` or `--prefix-
|
|
98
|
+
* `-p` or `--prefix`: Specify desired prefix of an wallet address (**case-insensitive**)
|
|
99
|
+
* `-P` or `--prefix-sensitive`: Specify desired prefix of an wallet address (**case-sensitive**)
|
|
100
|
+
* `-s` or `--suffix`: Specify desired suffix of an wallet address (**case-insensitive**)
|
|
101
|
+
* `-S` or `--suffix-sensitive`: Specify desired suffix of an wallet address (**case-sensitive**)
|
|
100
102
|
* `-v` or `--version`: Display the version of CW tool
|
|
101
103
|
|
|
102
104
|
## Highlights
|
|
103
|
-
- 24 blockchains supported
|
|
104
|
-
- Generate wallet with desired prefix
|
|
105
|
+
- 24+ blockchains supported
|
|
106
|
+
- Generate wallet with desired prefix/suffix
|
|
105
107
|
- Generate wallet from mnemonic
|
|
106
108
|
- Generate just a mnemonic
|
|
107
109
|
- Works fully offline
|
package/cli.js
CHANGED
|
@@ -12,8 +12,10 @@ program.option('-g, --geek', 'Display some more info (geeky)');
|
|
|
12
12
|
program.option('-l, --list', 'List all supported cryptos');
|
|
13
13
|
program.option('-m, --mnemonic [mnemonic]', 'Generate wallet from mnemonic string OR just a mnemonic string');
|
|
14
14
|
program.option('-n, --number <number>', 'Number of wallets to generate (if supported)');
|
|
15
|
-
program.option('-p, --prefix <prefix>', 'Desired wallet prefix
|
|
16
|
-
program.option('-P, --prefix-
|
|
15
|
+
program.option('-p, --prefix <prefix>', 'Desired wallet prefix');
|
|
16
|
+
program.option('-P, --prefix-sensitive <prefix>', 'Desired wallet prefix (case-sensitive)');
|
|
17
|
+
program.option('-s, --suffix <suffix>', 'Desired wallet suffix');
|
|
18
|
+
program.option('-S, --suffix-sensitive <suffix>', 'Desired wallet suffix (case-sensitive)');
|
|
17
19
|
program.option('-v, --version', 'Display cryptowallet version');
|
|
18
20
|
program.parse();
|
|
19
21
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yerofey/cryptowallet-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"homepage": "https://github.com/yerofey/cryptowallet-cli",
|
|
5
5
|
"author": "Yerofey S. <pm@yerofey.dev> (https://github.com/yerofey)",
|
|
6
6
|
"bin": {
|
|
@@ -61,19 +61,19 @@
|
|
|
61
61
|
"@yerofey/dogecoin-bip84": "^0.0.5",
|
|
62
62
|
"@yerofey/litecoin-bip84": "^0.0.5",
|
|
63
63
|
"bip39": "3.0.4",
|
|
64
|
-
"bip84": "
|
|
64
|
+
"bip84": "0.2.6",
|
|
65
65
|
"chalk": "4.1.2",
|
|
66
66
|
"coininfo": "5.1.0",
|
|
67
67
|
"coinkey": "3.0.0",
|
|
68
68
|
"columnify": "1.5.4",
|
|
69
69
|
"commander": "8.1.0",
|
|
70
70
|
"eth-lib": "0.1.29",
|
|
71
|
+
"ethereum-bip84": "0.0.3",
|
|
71
72
|
"ethereum-mnemonic-privatekey-utils": "1.0.5",
|
|
72
73
|
"tezos-sign": "1.4.1",
|
|
73
74
|
"tronweb": "4.0.0"
|
|
74
75
|
},
|
|
75
76
|
"devDependencies": {
|
|
76
|
-
"ava": "^3.15.0"
|
|
77
|
-
"ethereum-bip84": "0.0.2"
|
|
77
|
+
"ava": "^3.15.0"
|
|
78
78
|
}
|
|
79
79
|
}
|
package/src/CW.js
CHANGED
|
@@ -9,8 +9,10 @@ class CW {
|
|
|
9
9
|
geek: false,
|
|
10
10
|
mnemonic: '',
|
|
11
11
|
number: 1,
|
|
12
|
-
prefix: options.
|
|
13
|
-
|
|
12
|
+
prefix: options.prefixSensitive || '',
|
|
13
|
+
prefixIsCaseSensitive: options.prefixSensitive !== undefined,
|
|
14
|
+
suffix: options.suffixSensitive || '',
|
|
15
|
+
suffixIsCaseSensitive: options.suffixSensitive !== undefined,
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
for (const key of Object.keys(defaultValues)) {
|
package/src/Method.js
CHANGED
|
@@ -53,6 +53,10 @@ class Method {
|
|
|
53
53
|
log(`😢 ${chalk.yellow('Sorry, ' + coinFullName + ' does not support prefix yet...')}`);
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
if (cw.options.suffix && !cw.suffixFound) {
|
|
57
|
+
log(`😢 ${chalk.yellow('Sorry, ' + coinFullName + ' does not support suffix yet...')}`);
|
|
58
|
+
}
|
|
59
|
+
|
|
56
60
|
if (cw.options.mnemonic != '' && cw.wallet.mnemonic == undefined) {
|
|
57
61
|
log(`😢 ${chalk.yellow('Sorry, ' + coinFullName + ' does not support mnemonic yet...')}`);
|
|
58
62
|
}
|
|
@@ -62,9 +66,19 @@ class Method {
|
|
|
62
66
|
return;
|
|
63
67
|
}
|
|
64
68
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
69
|
+
// prefix, suffix
|
|
70
|
+
if (cw.prefixFound && cw.suffixFound) {
|
|
71
|
+
log(`✨ ${chalk.green('Done!')} ${chalk.blueBright('Here is your brand new ' + coinFullName + ' wallet with "' + cw.options.prefix + '" prefix and "' + cw.options.suffix + '" suffix:')}\n`);
|
|
72
|
+
} else if (cw.prefixFound) {
|
|
73
|
+
log(`✨ ${chalk.green('Done!')} ${chalk.blueBright('Here is your brand new ' + coinFullName + ' wallet with "' + cw.options.prefix + '" prefix:')}\n`);
|
|
74
|
+
} else if (cw.suffixFound) {
|
|
75
|
+
log(`✨ ${chalk.green('Done!')} ${chalk.blueBright('Here is your brand new ' + coinFullName + ' wallet with "' + cw.options.suffix + '" suffix:')}\n`);
|
|
76
|
+
} else {
|
|
77
|
+
log(`✨ ${chalk.green('Done!')} ${chalk.blueBright('Here is your brand new ' + coinFullName + ' wallet:')}\n`);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// result
|
|
81
|
+
if (cw.wallet.addresses !== undefined) {
|
|
68
82
|
if (cw.wallet.privateExtendedKey) {
|
|
69
83
|
log(`🔐 ${cw.wallet.privateExtendedKey}`);
|
|
70
84
|
}
|
|
@@ -77,9 +91,20 @@ class Method {
|
|
|
77
91
|
if (cw.wallet.addresses.length > 1) {
|
|
78
92
|
log(`🆔 ${item.index}`);
|
|
79
93
|
}
|
|
80
|
-
|
|
94
|
+
|
|
95
|
+
if (cw.prefixFound && cw.prefixFoundInWallets.includes(item.address) && cw.suffixFound && cw.suffixFoundInWallets.includes(item.address)) {
|
|
96
|
+
// highlight found prefix
|
|
97
|
+
const addressCutPrefixLength = cw.row.startsWith.length + cw.options.prefix.length;
|
|
98
|
+
const addressFirstPart = item.address.slice(cw.row.startsWith.length, addressCutPrefixLength);
|
|
99
|
+
const addressLastPart = item.address.slice(item.address.length - cw.options.suffix.length);
|
|
100
|
+
log(`👛 ${cw.row.startsWith}${chalk.magenta(addressFirstPart)}${item.address.substring(cw.row.startsWith.length + addressFirstPart.length, item.address.length - addressLastPart.length)}${chalk.magenta(addressLastPart)}`);
|
|
101
|
+
} else if (cw.prefixFound && cw.prefixFoundInWallets.includes(item.address)) {
|
|
102
|
+
// highlight found prefix
|
|
81
103
|
const addressCutLength = cw.row.startsWith.length + cw.options.prefix.length;
|
|
82
104
|
log(`👛 ${cw.row.startsWith}${chalk.magenta(item.address.slice(cw.row.startsWith.length, addressCutLength))}${item.address.slice(addressCutLength)}`);
|
|
105
|
+
} else if (cw.suffixFound && cw.suffixFoundInWallets.includes(item.address)) {
|
|
106
|
+
// highlight found suffix
|
|
107
|
+
log(`👛 ${item.address.slice(0, item.address.length - cw.options.suffix.length)}${chalk.magenta(item.address.slice(item.address.length - cw.options.suffix.length))}`);
|
|
83
108
|
} else {
|
|
84
109
|
log(`👛 ${item.address}`);
|
|
85
110
|
}
|
|
@@ -90,17 +115,6 @@ class Method {
|
|
|
90
115
|
log();
|
|
91
116
|
log(`🗂 wallet address path: ${cw.row.path}'/0'/0/ID`);
|
|
92
117
|
}
|
|
93
|
-
} else { // single address wallet
|
|
94
|
-
if (cw.prefixFound) {
|
|
95
|
-
const addressCutLength = cw.row.startsWith.length + cw.options.prefix.length;
|
|
96
|
-
log(`👛 ${cw.row.startsWith}${chalk.magenta(cw.wallet.address.slice(cw.row.startsWith.length, addressCutLength))}${cw.wallet.address.slice(addressCutLength)}`);
|
|
97
|
-
} else {
|
|
98
|
-
log(`👛 ${cw.wallet.address}`);
|
|
99
|
-
}
|
|
100
|
-
log(`🔑 ${cw.wallet.privateKey}`);
|
|
101
|
-
if (cw.wallet.mnemonic) {
|
|
102
|
-
log(`📄 ${cw.wallet.mnemonic}`);
|
|
103
|
-
}
|
|
104
118
|
}
|
|
105
119
|
|
|
106
120
|
if (cw.row.formats !== undefined || cw.row.network == 'EVM' || cw.row.apps || cw.wallet.tested !== undefined) {
|
package/src/Wallet.js
CHANGED
|
@@ -11,34 +11,82 @@ class Wallet {
|
|
|
11
11
|
const row = cw.row;
|
|
12
12
|
const options = cw.options;
|
|
13
13
|
|
|
14
|
-
const
|
|
14
|
+
const desiredSymbolsArray = (options.prefix.length > 0 || options.suffix.length > 0) ? options.prefix.split('').concat(options.suffix.split('')) : [];
|
|
15
|
+
const desiredSymbolsUniqueArray = desiredSymbolsArray.filter((item, pos) => desiredSymbolsArray.indexOf(item) === pos);
|
|
16
|
+
const badSymbolsArray = desiredSymbolsUniqueArray.filter(char => !RegExp(row.prefixTest, 'g').test(char)) || [];
|
|
17
|
+
|
|
15
18
|
let wallet = {};
|
|
16
19
|
let prefixFound = false;
|
|
17
20
|
let prefixFoundInWallets = [];
|
|
21
|
+
let suffixFound = false;
|
|
22
|
+
let suffixFoundInWallets = [];
|
|
23
|
+
let onlyPrefix = false;
|
|
24
|
+
let onlySuffix = false;
|
|
25
|
+
let onlyBoth = false;
|
|
26
|
+
|
|
27
|
+
const prefixFoundInAddress = (address, isCaseSensitive, prefix, symbol) => (isCaseSensitive && address.startsWith(symbol + '' + prefix) || !isCaseSensitive && (address).toUpperCase().startsWith((symbol + '' + prefix).toUpperCase()));
|
|
28
|
+
const suffixFoundInAddress = (address, isCaseSensitive, suffix) => (isCaseSensitive && address.endsWith(suffix) || !isCaseSensitive && (address).toUpperCase().endsWith(suffix));
|
|
18
29
|
|
|
19
|
-
if (options.prefix && row.flags.includes('p')) {
|
|
20
|
-
if (
|
|
21
|
-
if (options.prefix
|
|
22
|
-
|
|
30
|
+
if (options.prefix && row.flags.includes('p') || options.suffix && row.flags.includes('s')) {
|
|
31
|
+
if (badSymbolsArray.length === 0) {
|
|
32
|
+
if (options.prefix && options.suffix) {
|
|
33
|
+
// prefix & suffix
|
|
34
|
+
log(`⏳ Generating wallet with "${options.prefix}" prefix and "${options.suffix}" suffix, this for sure will take a while...`);
|
|
35
|
+
onlyBoth = true;
|
|
36
|
+
} else {
|
|
37
|
+
// prefix
|
|
38
|
+
if (options.prefix.length > 0 || 'rareSymbols' in row && RegExp(row.rareSymbols, 'g').test(options.prefix)) {
|
|
39
|
+
log(`⏳ Generating wallet with "${options.prefix}" prefix, this might take a while...`);
|
|
40
|
+
onlyPrefix = true;
|
|
41
|
+
}
|
|
42
|
+
// suffix
|
|
43
|
+
if (options.suffix.length > 0 || 'rareSymbols' in row && RegExp(row.rareSymbols, 'g').test(options.suffix)) {
|
|
44
|
+
log(`⏳ Generating wallet with "${options.suffix}" suffix, this might take a while...`);
|
|
45
|
+
onlySuffix = true;
|
|
46
|
+
}
|
|
23
47
|
}
|
|
48
|
+
|
|
24
49
|
const startsWithSymbols = row.startsWith.split('|');
|
|
25
50
|
loop:
|
|
26
51
|
while (true) {
|
|
27
52
|
wallet = await this.createWallet();
|
|
28
53
|
for (let firstSymbol of startsWithSymbols) {
|
|
29
|
-
if (wallet.address !== undefined) {
|
|
30
|
-
if (
|
|
54
|
+
if (wallet.address !== undefined) { // one address
|
|
55
|
+
if (onlyPrefix && prefixFoundInAddress(wallet.address, options.prefixIsCaseSensitive, options.prefix, firstSymbol)) {
|
|
56
|
+
prefixFound = true;
|
|
57
|
+
break loop;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (onlySuffix && suffixFoundInAddress(wallet.address, options.suffixIsCaseSensitive, options.suffix)) {
|
|
61
|
+
suffixFound = true;
|
|
62
|
+
break loop;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (onlyBoth && prefixFoundInAddress(wallet.address, options.prefixIsCaseSensitive, options.prefix, firstSymbol) && suffixFoundInAddress(wallet.address, options.suffixIsCaseSensitive, options.suffix)) {
|
|
31
66
|
prefixFound = true;
|
|
67
|
+
suffixFound = true;
|
|
32
68
|
break loop;
|
|
33
69
|
}
|
|
34
|
-
} else if (wallet.addresses !== undefined) {
|
|
70
|
+
} else if (wallet.addresses !== undefined) { // multiple addresses
|
|
35
71
|
for (let item of wallet.addresses) {
|
|
36
|
-
if (
|
|
72
|
+
if (onlyPrefix && prefixFoundInAddress(item.address, options.prefixIsCaseSensitive, options.prefix, firstSymbol)) {
|
|
37
73
|
prefixFound = true;
|
|
38
74
|
prefixFoundInWallets.push(item.address);
|
|
39
75
|
}
|
|
76
|
+
|
|
77
|
+
if (onlySuffix && suffixFoundInAddress(item.address, options.suffixIsCaseSensitive, options.suffix)) {
|
|
78
|
+
suffixFound = true;
|
|
79
|
+
suffixFoundInWallets.push(item.address);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (onlyBoth && prefixFoundInAddress(item.address, options.prefixIsCaseSensitive, options.prefix, firstSymbol) && suffixFoundInAddress(item.address, options.suffixIsCaseSensitive, options.suffix)) {
|
|
83
|
+
prefixFound = true;
|
|
84
|
+
prefixFoundInWallets.push(item.address);
|
|
85
|
+
suffixFound = true;
|
|
86
|
+
suffixFoundInWallets.push(item.address);
|
|
87
|
+
}
|
|
40
88
|
}
|
|
41
|
-
if (prefixFound) {
|
|
89
|
+
if (onlyPrefix && prefixFound || onlySuffix && suffixFound || onlyBoth && prefixFound && suffixFound) {
|
|
42
90
|
break loop;
|
|
43
91
|
}
|
|
44
92
|
} else {
|
|
@@ -48,12 +96,13 @@ class Wallet {
|
|
|
48
96
|
}
|
|
49
97
|
}
|
|
50
98
|
} else {
|
|
51
|
-
let
|
|
52
|
-
for (const symbol of
|
|
53
|
-
|
|
99
|
+
let badSymbolsString = '';
|
|
100
|
+
for (const symbol of badSymbolsArray) {
|
|
101
|
+
badSymbolsString += '"' + symbol + '", ';
|
|
54
102
|
}
|
|
55
103
|
|
|
56
|
-
|
|
104
|
+
// TODO: add prefix/suffix own message log
|
|
105
|
+
log(chalk.red('⛔️ Error: prefix or suffix contains non-supported characters (' + badSymbolsString.substr(0, badSymbolsString.length - 2) + ')!'));
|
|
57
106
|
process.exit(1);
|
|
58
107
|
}
|
|
59
108
|
} else {
|
|
@@ -63,7 +112,9 @@ class Wallet {
|
|
|
63
112
|
return {
|
|
64
113
|
wallet,
|
|
65
114
|
prefixFound,
|
|
66
|
-
prefixFoundInWallets
|
|
115
|
+
prefixFoundInWallets,
|
|
116
|
+
suffixFound,
|
|
117
|
+
suffixFoundInWallets,
|
|
67
118
|
};
|
|
68
119
|
}
|
|
69
120
|
|
|
@@ -80,7 +131,7 @@ class Wallet {
|
|
|
80
131
|
|
|
81
132
|
if (row.length == 0) {
|
|
82
133
|
return {
|
|
83
|
-
error: 'coin not found'
|
|
134
|
+
error: 'coin not found',
|
|
84
135
|
}
|
|
85
136
|
}
|
|
86
137
|
|
|
@@ -92,8 +143,11 @@ class Wallet {
|
|
|
92
143
|
|
|
93
144
|
result = Object.assign(result, {
|
|
94
145
|
format,
|
|
95
|
-
|
|
96
|
-
|
|
146
|
+
addresses: [{
|
|
147
|
+
index: 0,
|
|
148
|
+
address: wallet.publicAddress,
|
|
149
|
+
privateKey: wallet.privateWif,
|
|
150
|
+
}]
|
|
97
151
|
});
|
|
98
152
|
} else if (coin == 'BTC') {
|
|
99
153
|
const bip39 = require('bip39');
|
|
@@ -169,35 +223,77 @@ class Wallet {
|
|
|
169
223
|
}
|
|
170
224
|
}
|
|
171
225
|
|
|
226
|
+
let addresses = [];
|
|
172
227
|
const mnemonic = mnemonicString || bip39.generateMnemonic();
|
|
173
|
-
|
|
174
|
-
|
|
228
|
+
|
|
229
|
+
if (number == 1) {
|
|
230
|
+
const privateKey = bCrypto.getPrivateKeyFromMnemonic(mnemonic, true, 0);
|
|
231
|
+
addresses.push({
|
|
232
|
+
index: 0,
|
|
233
|
+
address: bCrypto.getAddressFromPrivateKey(privateKey, 'bnb'),
|
|
234
|
+
privateKey
|
|
235
|
+
});
|
|
236
|
+
} else {
|
|
237
|
+
for (let i = 0; i <= number; i++) {
|
|
238
|
+
const privateKey = bCrypto.getPrivateKeyFromMnemonic(mnemonic, true, i);
|
|
239
|
+
addresses.push({
|
|
240
|
+
index: i,
|
|
241
|
+
address: bCrypto.getAddressFromPrivateKey(privateKey, 'bnb'),
|
|
242
|
+
privateKey
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
175
247
|
Object.assign(result, {
|
|
176
248
|
format: 'BEP2',
|
|
177
|
-
|
|
178
|
-
privateKey,
|
|
249
|
+
addresses,
|
|
179
250
|
mnemonic
|
|
180
251
|
});
|
|
181
252
|
} else if (row.network == 'EVM') {
|
|
182
253
|
const bip39 = require('bip39');
|
|
183
254
|
const pkutils = require('ethereum-mnemonic-privatekey-utils');
|
|
184
255
|
const { Account } = require('eth-lib/lib');
|
|
256
|
+
const { fromMnemonic, fromZPrv } = require('ethereum-bip84');
|
|
185
257
|
|
|
186
258
|
if (mnemonicString != '' && !bip39.validateMnemonic(mnemonicString)) {
|
|
187
259
|
return {
|
|
188
|
-
error: 'mnemonic is not valid'
|
|
260
|
+
error: 'mnemonic is not valid',
|
|
189
261
|
}
|
|
190
262
|
}
|
|
191
263
|
|
|
264
|
+
let addresses = [];
|
|
192
265
|
const mnemonic = mnemonicString || bip39.generateMnemonic();
|
|
193
266
|
const privateKey = pkutils.getPrivateKeyFromMnemonic(mnemonic);
|
|
194
|
-
|
|
195
|
-
|
|
267
|
+
|
|
268
|
+
if (number == 1) {
|
|
269
|
+
const account = Account.fromPrivate('0x' + privateKey);
|
|
270
|
+
|
|
271
|
+
addresses.push({
|
|
272
|
+
index: 0,
|
|
273
|
+
address: account.address,
|
|
274
|
+
privateKey,
|
|
275
|
+
});
|
|
276
|
+
} else {
|
|
277
|
+
// TODO: add variable for accountId
|
|
278
|
+
const root = new fromMnemonic(mnemonic, '');
|
|
279
|
+
const child = root.deriveAccount(0);
|
|
280
|
+
const account = new fromZPrv(child);
|
|
281
|
+
for (let walletId = 0; walletId <= number; walletId++) {
|
|
282
|
+
const walletAddress = account.getAddress(walletId);
|
|
283
|
+
const privateKey = account.getPrivateKey(walletId);
|
|
284
|
+
|
|
285
|
+
addresses.push({
|
|
286
|
+
index: walletId,
|
|
287
|
+
address: walletAddress,
|
|
288
|
+
privateKey,
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
196
293
|
Object.assign(result, {
|
|
197
294
|
format: row.format || '',
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
mnemonic
|
|
295
|
+
addresses,
|
|
296
|
+
mnemonic,
|
|
201
297
|
});
|
|
202
298
|
} else if (coin == 'ONE') {
|
|
203
299
|
const bip39 = require('bip39');
|
|
@@ -216,9 +312,12 @@ class Wallet {
|
|
|
216
312
|
const account = wallet.getAccount(publicKey);
|
|
217
313
|
|
|
218
314
|
Object.assign(result, {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
315
|
+
addresses: [{
|
|
316
|
+
index: 0,
|
|
317
|
+
address: account.bech32Address,
|
|
318
|
+
privateKey: account.privateKey,
|
|
319
|
+
}],
|
|
320
|
+
mnemonic,
|
|
222
321
|
});
|
|
223
322
|
} else if (coin == 'TRX') {
|
|
224
323
|
const tronWeb = require('tronweb');
|
|
@@ -227,8 +326,11 @@ class Wallet {
|
|
|
227
326
|
const wallet = await tronWeb.createAccount();
|
|
228
327
|
|
|
229
328
|
Object.assign(result, {
|
|
230
|
-
|
|
231
|
-
|
|
329
|
+
addresses: [{
|
|
330
|
+
index: 0,
|
|
331
|
+
address: wallet.address.base58,
|
|
332
|
+
privateKey: wallet.privateKey
|
|
333
|
+
}],
|
|
232
334
|
});
|
|
233
335
|
} catch (error) {
|
|
234
336
|
return {
|
|
@@ -240,8 +342,11 @@ class Wallet {
|
|
|
240
342
|
const wallet = tezos.generateKeysNoSeed();
|
|
241
343
|
|
|
242
344
|
Object.assign(result, {
|
|
243
|
-
|
|
244
|
-
|
|
345
|
+
addresses: [{
|
|
346
|
+
index: 0,
|
|
347
|
+
address: wallet.pkh,
|
|
348
|
+
privateKey: wallet.sk,
|
|
349
|
+
}],
|
|
245
350
|
});
|
|
246
351
|
} else {
|
|
247
352
|
return {
|
|
@@ -251,7 +356,7 @@ class Wallet {
|
|
|
251
356
|
|
|
252
357
|
if (row.tested !== undefined && row.tested == false) {
|
|
253
358
|
Object.assign(result, {
|
|
254
|
-
tested: false
|
|
359
|
+
tested: false,
|
|
255
360
|
});
|
|
256
361
|
}
|
|
257
362
|
|
package/src/coins/BCH.json
CHANGED
package/src/coins/BLK.json
CHANGED
package/src/coins/BNB.json
CHANGED
|
@@ -14,7 +14,9 @@
|
|
|
14
14
|
"flags": [
|
|
15
15
|
"f",
|
|
16
16
|
"m",
|
|
17
|
-
"
|
|
17
|
+
"n",
|
|
18
|
+
"p",
|
|
19
|
+
"s"
|
|
18
20
|
]
|
|
19
21
|
},
|
|
20
22
|
"BEP20": {
|
|
@@ -30,7 +32,9 @@
|
|
|
30
32
|
"flags": [
|
|
31
33
|
"f",
|
|
32
34
|
"m",
|
|
33
|
-
"
|
|
35
|
+
"n",
|
|
36
|
+
"p",
|
|
37
|
+
"s"
|
|
34
38
|
]
|
|
35
39
|
},
|
|
36
40
|
"ERC20": {
|
|
@@ -46,7 +50,9 @@
|
|
|
46
50
|
"flags": [
|
|
47
51
|
"f",
|
|
48
52
|
"m",
|
|
49
|
-
"
|
|
53
|
+
"n",
|
|
54
|
+
"p",
|
|
55
|
+
"s"
|
|
50
56
|
]
|
|
51
57
|
}
|
|
52
58
|
}
|
package/src/coins/BTC.json
CHANGED
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
"g",
|
|
18
18
|
"m",
|
|
19
19
|
"n",
|
|
20
|
-
"p"
|
|
20
|
+
"p",
|
|
21
|
+
"s"
|
|
21
22
|
]
|
|
22
23
|
},
|
|
23
24
|
"legacy": {
|
|
@@ -32,7 +33,8 @@
|
|
|
32
33
|
"g",
|
|
33
34
|
"m",
|
|
34
35
|
"n",
|
|
35
|
-
"p"
|
|
36
|
+
"p",
|
|
37
|
+
"s"
|
|
36
38
|
]
|
|
37
39
|
},
|
|
38
40
|
"segwit": {
|
|
@@ -47,7 +49,8 @@
|
|
|
47
49
|
"g",
|
|
48
50
|
"m",
|
|
49
51
|
"n",
|
|
50
|
-
"p"
|
|
52
|
+
"p",
|
|
53
|
+
"s"
|
|
51
54
|
]
|
|
52
55
|
}
|
|
53
56
|
}
|
package/src/coins/BTG.json
CHANGED
package/src/coins/DASH.json
CHANGED
package/src/coins/DCR.json
CHANGED
package/src/coins/DGB.json
CHANGED
package/src/coins/DOGE.json
CHANGED
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
"g",
|
|
15
15
|
"m",
|
|
16
16
|
"n",
|
|
17
|
-
"p"
|
|
17
|
+
"p",
|
|
18
|
+
"s"
|
|
18
19
|
]
|
|
19
20
|
},
|
|
20
21
|
"legacy": {
|
|
@@ -29,7 +30,8 @@
|
|
|
29
30
|
"g",
|
|
30
31
|
"m",
|
|
31
32
|
"n",
|
|
32
|
-
"p"
|
|
33
|
+
"p",
|
|
34
|
+
"s"
|
|
33
35
|
]
|
|
34
36
|
},
|
|
35
37
|
"segwit": {
|
|
@@ -44,7 +46,8 @@
|
|
|
44
46
|
"g",
|
|
45
47
|
"m",
|
|
46
48
|
"n",
|
|
47
|
-
"p"
|
|
49
|
+
"p",
|
|
50
|
+
"s"
|
|
48
51
|
]
|
|
49
52
|
}
|
|
50
53
|
}
|
package/src/coins/ERC.json
CHANGED
package/src/coins/ETC.json
CHANGED
package/src/coins/ETH.json
CHANGED
package/src/coins/LTC.json
CHANGED
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
"g",
|
|
18
18
|
"m",
|
|
19
19
|
"n",
|
|
20
|
-
"p"
|
|
20
|
+
"p",
|
|
21
|
+
"s"
|
|
21
22
|
]
|
|
22
23
|
},
|
|
23
24
|
"legacy": {
|
|
@@ -32,7 +33,8 @@
|
|
|
32
33
|
"g",
|
|
33
34
|
"m",
|
|
34
35
|
"n",
|
|
35
|
-
"p"
|
|
36
|
+
"p",
|
|
37
|
+
"s"
|
|
36
38
|
]
|
|
37
39
|
},
|
|
38
40
|
"segwit": {
|
|
@@ -47,7 +49,8 @@
|
|
|
47
49
|
"g",
|
|
48
50
|
"m",
|
|
49
51
|
"n",
|
|
50
|
-
"p"
|
|
52
|
+
"p",
|
|
53
|
+
"s"
|
|
51
54
|
]
|
|
52
55
|
}
|
|
53
56
|
}
|
package/src/coins/MONA.json
CHANGED
package/src/coins/NBT.json
CHANGED
package/src/coins/NMC.json
CHANGED
package/src/coins/ONE.json
CHANGED
package/src/coins/POLYGON.json
CHANGED
package/src/coins/PPC.json
CHANGED
package/src/coins/QTUM.json
CHANGED
package/src/coins/RDD.json
CHANGED
package/src/coins/TRX.json
CHANGED
package/src/coins/VIA.json
CHANGED
package/src/coins/VTC.json
CHANGED
package/src/coins/XTZ.json
CHANGED