@yerofey/cryptowallet-cli 1.2.10 → 1.3.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 +9 -7
- package/cli.js +2 -0
- package/package.json +4 -4
- package/src/CW.js +3 -1
- package/src/Method.js +30 -15
- package/src/Wallet.js +142 -40
- 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,7 +23,7 @@ $ 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
29
|
# generate random BTC wallet with desired prefix (case sensitive)
|
|
@@ -32,10 +32,10 @@ $ cw -c BTC -p ABC
|
|
|
32
32
|
# generate random BTC wallet with desired prefix (case insensitive)
|
|
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-ignorecase`: Specify desired prefix of an wallet address (case
|
|
98
|
+
* `-p` or `--prefix`: Specify desired prefix of an wallet address (**case-sensitive**)
|
|
99
|
+
* `-P` or `--prefix-ignorecase`: Specify desired prefix of an wallet address (**case-insensitive**)
|
|
100
|
+
* `-s` or `--suffix`: Specify desired suffix of an wallet address (**case-sensitive**)
|
|
101
|
+
* `-S` or `--suffix-ignorecase`: Specify desired suffix of an wallet address (**case-insensitive**)
|
|
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
|
@@ -14,6 +14,8 @@ program.option('-m, --mnemonic [mnemonic]', 'Generate wallet from mnemonic strin
|
|
|
14
14
|
program.option('-n, --number <number>', 'Number of wallets to generate (if supported)');
|
|
15
15
|
program.option('-p, --prefix <prefix>', 'Desired wallet prefix (case sensitive)');
|
|
16
16
|
program.option('-P, --prefix-ignorecase <prefix>', 'Desired wallet prefix (case insensitive)');
|
|
17
|
+
program.option('-s, --suffix <suffix>', 'Desired wallet suffix (case sensitive)');
|
|
18
|
+
program.option('-S, --suffix-ignorecase <suffix>', 'Desired wallet suffix (case insensitive)');
|
|
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.3.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": "0.2.
|
|
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
|
@@ -10,7 +10,9 @@ class CW {
|
|
|
10
10
|
mnemonic: '',
|
|
11
11
|
number: 1,
|
|
12
12
|
prefix: options.prefixIgnorecase || '',
|
|
13
|
-
prefixIgnoreCase: options.prefixIgnorecase !== undefined
|
|
13
|
+
prefixIgnoreCase: options.prefixIgnorecase !== undefined,
|
|
14
|
+
suffix: options.suffixIgnorecase || '',
|
|
15
|
+
suffixIgnoreCase: options.suffixIgnorecase !== 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,21 @@ 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
|
+
// log(`👛 ${item.address}`);
|
|
98
|
+
const addressCutPrefixLength = cw.row.startsWith.length + cw.options.prefix.length;
|
|
99
|
+
const addressFirstPart = item.address.slice(cw.row.startsWith.length, addressCutPrefixLength);
|
|
100
|
+
const addressLastPart = item.address.slice(item.address.length - cw.options.suffix.length);
|
|
101
|
+
log(`👛 ${cw.row.startsWith}${chalk.magenta(addressFirstPart)}${item.address.substring(cw.row.startsWith.length + addressFirstPart.length, item.address.length - addressLastPart.length)}${chalk.magenta(addressLastPart)}`);
|
|
102
|
+
} else if (cw.prefixFound && cw.prefixFoundInWallets.includes(item.address)) {
|
|
103
|
+
// highlight found prefix
|
|
81
104
|
const addressCutLength = cw.row.startsWith.length + cw.options.prefix.length;
|
|
82
105
|
log(`👛 ${cw.row.startsWith}${chalk.magenta(item.address.slice(cw.row.startsWith.length, addressCutLength))}${item.address.slice(addressCutLength)}`);
|
|
106
|
+
} else if (cw.suffixFound && cw.suffixFoundInWallets.includes(item.address)) {
|
|
107
|
+
// highlight found suffix
|
|
108
|
+
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
109
|
} else {
|
|
84
110
|
log(`👛 ${item.address}`);
|
|
85
111
|
}
|
|
@@ -90,17 +116,6 @@ class Method {
|
|
|
90
116
|
log();
|
|
91
117
|
log(`🗂 wallet address path: ${cw.row.path}'/0'/0/ID`);
|
|
92
118
|
}
|
|
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
119
|
}
|
|
105
120
|
|
|
106
121
|
if (cw.row.formats !== undefined || cw.row.network == 'EVM' || cw.row.apps || cw.wallet.tested !== undefined) {
|
package/src/Wallet.js
CHANGED
|
@@ -11,34 +11,79 @@ class Wallet {
|
|
|
11
11
|
const row = cw.row;
|
|
12
12
|
const options = cw.options;
|
|
13
13
|
|
|
14
|
-
const
|
|
14
|
+
const badSymbolsArray = (options.prefix != '' ? options.prefix.split('').filter(char => !RegExp(row.prefixTest, 'g').test(char)) : []);
|
|
15
15
|
let wallet = {};
|
|
16
16
|
let prefixFound = false;
|
|
17
17
|
let prefixFoundInWallets = [];
|
|
18
|
+
let suffixFound = false;
|
|
19
|
+
let suffixFoundInWallets = [];
|
|
20
|
+
let onlyPrefix = false;
|
|
21
|
+
let onlySuffix = false;
|
|
22
|
+
let onlyBoth = false;
|
|
18
23
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
const prefixFoundInAddress = (address, isIgnoringCase, prefix, symbol) => (!isIgnoringCase && address.startsWith(symbol + '' + prefix) || isIgnoringCase && (address).toUpperCase().startsWith((symbol + '' + prefix).toUpperCase()));
|
|
25
|
+
const suffixFoundInAddress = (address, isIgnoringCase, suffix) => (!isIgnoringCase && address.endsWith(suffix) || isIgnoringCase && (address).toUpperCase().endsWith(suffix));
|
|
26
|
+
|
|
27
|
+
if (options.prefix && row.flags.includes('p') || options.suffix && row.flags.includes('s')) {
|
|
28
|
+
if (badSymbolsArray.length === 0) {
|
|
29
|
+
if (options.prefix && options.suffix) {
|
|
30
|
+
// prefix & suffix
|
|
31
|
+
log(`⏳ Generating wallet with "${options.prefix}" prefix and "${options.suffix}" suffix, this for sure will take a while...`);
|
|
32
|
+
onlyBoth = true;
|
|
33
|
+
} else {
|
|
34
|
+
// prefix
|
|
35
|
+
if (options.prefix.length > 0 || 'rareSymbols' in row && RegExp(row.rareSymbols, 'g').test(options.prefix)) {
|
|
36
|
+
log(`⏳ Generating wallet with "${options.prefix}" prefix, this might take a while...`);
|
|
37
|
+
onlyPrefix = true;
|
|
38
|
+
}
|
|
39
|
+
// suffix
|
|
40
|
+
if (options.suffix.length > 0 || 'rareSymbols' in row && RegExp(row.rareSymbols, 'g').test(options.suffix)) {
|
|
41
|
+
log(`⏳ Generating wallet with "${options.suffix}" suffix, this might take a while...`);
|
|
42
|
+
onlySuffix = true;
|
|
43
|
+
}
|
|
23
44
|
}
|
|
45
|
+
|
|
24
46
|
const startsWithSymbols = row.startsWith.split('|');
|
|
25
47
|
loop:
|
|
26
48
|
while (true) {
|
|
27
49
|
wallet = await this.createWallet();
|
|
28
50
|
for (let firstSymbol of startsWithSymbols) {
|
|
29
|
-
if (wallet.address !== undefined) {
|
|
30
|
-
if (
|
|
51
|
+
if (wallet.address !== undefined) { // one address
|
|
52
|
+
if (onlyPrefix && prefixFoundInAddress(wallet.address, options.prefixIgnoreCase, options.prefix, firstSymbol)) {
|
|
53
|
+
prefixFound = true;
|
|
54
|
+
break loop;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (onlySuffix && suffixFoundInAddress(wallet.address, options.suffixIgnoreCase, options.suffix)) {
|
|
58
|
+
suffixFound = true;
|
|
59
|
+
break loop;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (onlyBoth && prefixFoundInAddress(wallet.address, options.prefixIgnoreCase, options.prefix, firstSymbol) && suffixFoundInAddress(wallet.address, options.suffixIgnoreCase, options.suffix)) {
|
|
31
63
|
prefixFound = true;
|
|
64
|
+
suffixFound = true;
|
|
32
65
|
break loop;
|
|
33
66
|
}
|
|
34
|
-
} else if (wallet.addresses !== undefined) {
|
|
67
|
+
} else if (wallet.addresses !== undefined) { // multiple addresses
|
|
35
68
|
for (let item of wallet.addresses) {
|
|
36
|
-
if (
|
|
69
|
+
if (onlyPrefix && prefixFoundInAddress(item.address, options.prefixIgnoreCase, options.prefix, firstSymbol)) {
|
|
37
70
|
prefixFound = true;
|
|
38
71
|
prefixFoundInWallets.push(item.address);
|
|
39
72
|
}
|
|
73
|
+
|
|
74
|
+
if (onlySuffix && suffixFoundInAddress(item.address, options.suffixIgnoreCase, options.suffix)) {
|
|
75
|
+
suffixFound = true;
|
|
76
|
+
suffixFoundInWallets.push(item.address);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (onlyBoth && prefixFoundInAddress(item.address, options.prefixIgnoreCase, options.prefix, firstSymbol) && suffixFoundInAddress(item.address, options.suffixIgnoreCase, options.suffix)) {
|
|
80
|
+
prefixFound = true;
|
|
81
|
+
prefixFoundInWallets.push(item.address);
|
|
82
|
+
suffixFound = true;
|
|
83
|
+
suffixFoundInWallets.push(item.address);
|
|
84
|
+
}
|
|
40
85
|
}
|
|
41
|
-
if (prefixFound) {
|
|
86
|
+
if (onlyPrefix && prefixFound || onlySuffix && suffixFound || onlyBoth && prefixFound && suffixFound) {
|
|
42
87
|
break loop;
|
|
43
88
|
}
|
|
44
89
|
} else {
|
|
@@ -48,12 +93,13 @@ class Wallet {
|
|
|
48
93
|
}
|
|
49
94
|
}
|
|
50
95
|
} else {
|
|
51
|
-
let
|
|
52
|
-
for (const symbol of
|
|
53
|
-
|
|
96
|
+
let badSymbolsString = '';
|
|
97
|
+
for (const symbol of badSymbolsArray) {
|
|
98
|
+
badSymbolsString += '"' + symbol + '", ';
|
|
54
99
|
}
|
|
55
100
|
|
|
56
|
-
|
|
101
|
+
// TODO: add prefix/suffix own message log
|
|
102
|
+
log(chalk.red('⛔️ Error: prefix or suffix contains non-supported characters (' + badSymbolsString.substr(0, badSymbolsString.length - 2) + ')!'));
|
|
57
103
|
process.exit(1);
|
|
58
104
|
}
|
|
59
105
|
} else {
|
|
@@ -63,7 +109,9 @@ class Wallet {
|
|
|
63
109
|
return {
|
|
64
110
|
wallet,
|
|
65
111
|
prefixFound,
|
|
66
|
-
prefixFoundInWallets
|
|
112
|
+
prefixFoundInWallets,
|
|
113
|
+
suffixFound,
|
|
114
|
+
suffixFoundInWallets,
|
|
67
115
|
};
|
|
68
116
|
}
|
|
69
117
|
|
|
@@ -80,7 +128,7 @@ class Wallet {
|
|
|
80
128
|
|
|
81
129
|
if (row.length == 0) {
|
|
82
130
|
return {
|
|
83
|
-
error: 'coin not found'
|
|
131
|
+
error: 'coin not found',
|
|
84
132
|
}
|
|
85
133
|
}
|
|
86
134
|
|
|
@@ -92,12 +140,15 @@ class Wallet {
|
|
|
92
140
|
|
|
93
141
|
result = Object.assign(result, {
|
|
94
142
|
format,
|
|
95
|
-
|
|
96
|
-
|
|
143
|
+
addresses: [{
|
|
144
|
+
index: 0,
|
|
145
|
+
address: wallet.publicAddress,
|
|
146
|
+
privateKey: wallet.privateWif,
|
|
147
|
+
}]
|
|
97
148
|
});
|
|
98
149
|
} else if (coin == 'BTC') {
|
|
99
150
|
const bip39 = require('bip39');
|
|
100
|
-
const
|
|
151
|
+
const { fromMnemonic, fromZPrv } = require('bip84');
|
|
101
152
|
|
|
102
153
|
if (mnemonicString != '' && !bip39.validateMnemonic(mnemonicString)) {
|
|
103
154
|
return {
|
|
@@ -106,9 +157,9 @@ class Wallet {
|
|
|
106
157
|
}
|
|
107
158
|
|
|
108
159
|
const mnemonic = mnemonicString || bip39.generateMnemonic();
|
|
109
|
-
const root = new
|
|
160
|
+
const root = new fromMnemonic(mnemonic, '');
|
|
110
161
|
const child = root.deriveAccount(0);
|
|
111
|
-
const account = new
|
|
162
|
+
const account = new fromZPrv(child);
|
|
112
163
|
|
|
113
164
|
let addresses = [];
|
|
114
165
|
if (number >= 1) {
|
|
@@ -129,7 +180,7 @@ class Wallet {
|
|
|
129
180
|
});
|
|
130
181
|
} else if (coin == 'DOGE' || coin == 'LTC') {
|
|
131
182
|
const bip39 = require('bip39');
|
|
132
|
-
const { fromMnemonic, fromZPrv } = require(row.title.toLowerCase() + '-bip84');
|
|
183
|
+
const { fromMnemonic, fromZPrv } = require('@yerofey/' + row.title.toLowerCase() + '-bip84');
|
|
133
184
|
|
|
134
185
|
if (mnemonicString != '' && !bip39.validateMnemonic(mnemonicString)) {
|
|
135
186
|
return {
|
|
@@ -169,35 +220,77 @@ class Wallet {
|
|
|
169
220
|
}
|
|
170
221
|
}
|
|
171
222
|
|
|
223
|
+
let addresses = [];
|
|
172
224
|
const mnemonic = mnemonicString || bip39.generateMnemonic();
|
|
173
|
-
|
|
174
|
-
|
|
225
|
+
|
|
226
|
+
if (number == 1) {
|
|
227
|
+
const privateKey = bCrypto.getPrivateKeyFromMnemonic(mnemonic, true, 0);
|
|
228
|
+
addresses.push({
|
|
229
|
+
index: 0,
|
|
230
|
+
address: bCrypto.getAddressFromPrivateKey(privateKey, 'bnb'),
|
|
231
|
+
privateKey
|
|
232
|
+
});
|
|
233
|
+
} else {
|
|
234
|
+
for (let i = 0; i <= number; i++) {
|
|
235
|
+
const privateKey = bCrypto.getPrivateKeyFromMnemonic(mnemonic, true, i);
|
|
236
|
+
addresses.push({
|
|
237
|
+
index: i,
|
|
238
|
+
address: bCrypto.getAddressFromPrivateKey(privateKey, 'bnb'),
|
|
239
|
+
privateKey
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
175
244
|
Object.assign(result, {
|
|
176
245
|
format: 'BEP2',
|
|
177
|
-
|
|
178
|
-
privateKey,
|
|
246
|
+
addresses,
|
|
179
247
|
mnemonic
|
|
180
248
|
});
|
|
181
249
|
} else if (row.network == 'EVM') {
|
|
182
250
|
const bip39 = require('bip39');
|
|
183
251
|
const pkutils = require('ethereum-mnemonic-privatekey-utils');
|
|
184
252
|
const { Account } = require('eth-lib/lib');
|
|
253
|
+
const { fromMnemonic, fromZPrv } = require('ethereum-bip84');
|
|
185
254
|
|
|
186
255
|
if (mnemonicString != '' && !bip39.validateMnemonic(mnemonicString)) {
|
|
187
256
|
return {
|
|
188
|
-
error: 'mnemonic is not valid'
|
|
257
|
+
error: 'mnemonic is not valid',
|
|
189
258
|
}
|
|
190
259
|
}
|
|
191
260
|
|
|
261
|
+
let addresses = [];
|
|
192
262
|
const mnemonic = mnemonicString || bip39.generateMnemonic();
|
|
193
263
|
const privateKey = pkutils.getPrivateKeyFromMnemonic(mnemonic);
|
|
194
|
-
|
|
195
|
-
|
|
264
|
+
|
|
265
|
+
if (number == 1) {
|
|
266
|
+
const account = Account.fromPrivate('0x' + privateKey);
|
|
267
|
+
|
|
268
|
+
addresses.push({
|
|
269
|
+
index: 0,
|
|
270
|
+
address: account.address,
|
|
271
|
+
privateKey,
|
|
272
|
+
});
|
|
273
|
+
} else {
|
|
274
|
+
// TODO: add variable for accountId
|
|
275
|
+
const root = new fromMnemonic(mnemonic, '');
|
|
276
|
+
const child = root.deriveAccount(0);
|
|
277
|
+
const account = new fromZPrv(child);
|
|
278
|
+
for (let walletId = 0; walletId <= number; walletId++) {
|
|
279
|
+
const walletAddress = account.getAddress(walletId);
|
|
280
|
+
const privateKey = account.getPrivateKey(walletId);
|
|
281
|
+
|
|
282
|
+
addresses.push({
|
|
283
|
+
index: walletId,
|
|
284
|
+
address: walletAddress,
|
|
285
|
+
privateKey,
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
196
290
|
Object.assign(result, {
|
|
197
291
|
format: row.format || '',
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
mnemonic
|
|
292
|
+
addresses,
|
|
293
|
+
mnemonic,
|
|
201
294
|
});
|
|
202
295
|
} else if (coin == 'ONE') {
|
|
203
296
|
const bip39 = require('bip39');
|
|
@@ -216,9 +309,12 @@ class Wallet {
|
|
|
216
309
|
const account = wallet.getAccount(publicKey);
|
|
217
310
|
|
|
218
311
|
Object.assign(result, {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
312
|
+
addresses: [{
|
|
313
|
+
index: 0,
|
|
314
|
+
address: account.bech32Address,
|
|
315
|
+
privateKey: account.privateKey,
|
|
316
|
+
}],
|
|
317
|
+
mnemonic,
|
|
222
318
|
});
|
|
223
319
|
} else if (coin == 'TRX') {
|
|
224
320
|
const tronWeb = require('tronweb');
|
|
@@ -227,8 +323,11 @@ class Wallet {
|
|
|
227
323
|
const wallet = await tronWeb.createAccount();
|
|
228
324
|
|
|
229
325
|
Object.assign(result, {
|
|
230
|
-
|
|
231
|
-
|
|
326
|
+
addresses: [{
|
|
327
|
+
index: 0,
|
|
328
|
+
address: wallet.address.base58,
|
|
329
|
+
privateKey: wallet.privateKey
|
|
330
|
+
}],
|
|
232
331
|
});
|
|
233
332
|
} catch (error) {
|
|
234
333
|
return {
|
|
@@ -240,8 +339,11 @@ class Wallet {
|
|
|
240
339
|
const wallet = tezos.generateKeysNoSeed();
|
|
241
340
|
|
|
242
341
|
Object.assign(result, {
|
|
243
|
-
|
|
244
|
-
|
|
342
|
+
addresses: [{
|
|
343
|
+
index: 0,
|
|
344
|
+
address: wallet.pkh,
|
|
345
|
+
privateKey: wallet.sk,
|
|
346
|
+
}],
|
|
245
347
|
});
|
|
246
348
|
} else {
|
|
247
349
|
return {
|
|
@@ -251,7 +353,7 @@ class Wallet {
|
|
|
251
353
|
|
|
252
354
|
if (row.tested !== undefined && row.tested == false) {
|
|
253
355
|
Object.assign(result, {
|
|
254
|
-
tested: false
|
|
356
|
+
tested: false,
|
|
255
357
|
});
|
|
256
358
|
}
|
|
257
359
|
|
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