@yerofey/cryptowallet-cli 1.17.4 → 1.17.7
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 +1 -0
- package/package.json +2 -2
- package/src/Method.js +61 -29
- package/src/Wallet.js +84 -116
- package/src/chains/ERC.json +1 -1
- package/src/chains/TON.json +1 -1
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yerofey/cryptowallet-cli",
|
|
3
|
-
"version": "1.17.
|
|
3
|
+
"version": "1.17.7",
|
|
4
4
|
"description": "Crypto wallet generator CLI tool",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"homepage": "https://github.com/yerofey/cryptowallet-cli",
|
|
@@ -77,7 +77,6 @@
|
|
|
77
77
|
"@solana/web3.js": "^1.89.1",
|
|
78
78
|
"@ton/core": "^0.54.0",
|
|
79
79
|
"@ton/crypto": "^3.2.0",
|
|
80
|
-
"@ton/ton": "^13.9.0",
|
|
81
80
|
"@yerofey/dogecoin-bip84": "^0.0.5",
|
|
82
81
|
"@yerofey/litecoin-bip84": "^0.0.5",
|
|
83
82
|
"bip39": "3.1.0",
|
|
@@ -94,6 +93,7 @@
|
|
|
94
93
|
"ethereum-bip84": "0.0.3",
|
|
95
94
|
"ethereum-mnemonic-privatekey-utils": "1.0.5",
|
|
96
95
|
"tezos-sign": "1.4.1",
|
|
96
|
+
"tonweb": "^0.0.62",
|
|
97
97
|
"tronweb": "5.3.1"
|
|
98
98
|
},
|
|
99
99
|
"devDependencies": {
|
package/src/Method.js
CHANGED
|
@@ -93,6 +93,8 @@ class Method {
|
|
|
93
93
|
|
|
94
94
|
const cw = await new CW(chain, options).init();
|
|
95
95
|
|
|
96
|
+
const startsWithSymbols = cw.row.startsWith.split('|') || [];
|
|
97
|
+
|
|
96
98
|
let chainFullName =
|
|
97
99
|
(cw.row.name || chain) +
|
|
98
100
|
(cw.wallet.format !== undefined && cw.wallet.format != ''
|
|
@@ -196,7 +198,16 @@ class Method {
|
|
|
196
198
|
for (const item of cw.wallet.addresses) {
|
|
197
199
|
if (cw.wallet.addresses.length > 1) {
|
|
198
200
|
log();
|
|
199
|
-
|
|
201
|
+
|
|
202
|
+
// Display index
|
|
203
|
+
if (item.index !== undefined) {
|
|
204
|
+
log(`🆔 ${item.index}`);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// Display address details
|
|
208
|
+
if (item.title) {
|
|
209
|
+
log(`🏷 ${item.title}`);
|
|
210
|
+
}
|
|
200
211
|
}
|
|
201
212
|
|
|
202
213
|
if (
|
|
@@ -205,51 +216,61 @@ class Method {
|
|
|
205
216
|
cw.suffixFound &&
|
|
206
217
|
cw.suffixFoundInWallets.includes(item.address)
|
|
207
218
|
) {
|
|
208
|
-
// highlight found prefix
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
219
|
+
// highlight found prefix and suffix
|
|
220
|
+
const addressStartingSymbol = startsWithSymbols.filter((symbol) =>
|
|
221
|
+
item.address.startsWith(symbol)
|
|
222
|
+
)[0];
|
|
223
|
+
const addressCutPrefixLength = addressStartingSymbol.length;
|
|
224
|
+
const addressHighlightedPart = item.address.substring(
|
|
225
|
+
addressCutPrefixLength + cw.options.prefix.length,
|
|
226
|
+
cw.options.prefix.length + 1
|
|
214
227
|
);
|
|
215
228
|
const addressLastPart = item.address.slice(
|
|
229
|
+
cw.options.prefix.length + addressCutPrefixLength,
|
|
230
|
+
item.address.length - cw.options.suffix.length
|
|
231
|
+
);
|
|
232
|
+
const addressHighlightedSuffix = item.address.slice(
|
|
216
233
|
item.address.length - cw.options.suffix.length
|
|
217
234
|
);
|
|
218
235
|
log(
|
|
219
|
-
`👛 ${
|
|
220
|
-
|
|
221
|
-
)}${
|
|
222
|
-
cw.row.startsWith.length + addressFirstPart.length,
|
|
223
|
-
item.address.length - addressLastPart.length
|
|
224
|
-
)}${magenta(addressLastPart)}`
|
|
236
|
+
`👛 ${addressStartingSymbol}${magenta(
|
|
237
|
+
addressHighlightedPart
|
|
238
|
+
)}${addressLastPart}${magenta(addressHighlightedSuffix)}`
|
|
225
239
|
);
|
|
226
240
|
} else if (
|
|
227
241
|
cw.prefixFound &&
|
|
228
242
|
cw.prefixFoundInWallets.includes(item.address)
|
|
229
243
|
) {
|
|
230
244
|
// highlight found prefix
|
|
231
|
-
const
|
|
232
|
-
|
|
245
|
+
const addressStartingSymbol = startsWithSymbols.filter((symbol) =>
|
|
246
|
+
item.address.startsWith(symbol)
|
|
247
|
+
)[0];
|
|
248
|
+
const addressCutPrefixLength = addressStartingSymbol.length;
|
|
249
|
+
const addressHighlightedPart = item.address.substring(
|
|
250
|
+
addressCutPrefixLength + cw.options.prefix.length,
|
|
251
|
+
cw.options.prefix.length + 1
|
|
252
|
+
);
|
|
253
|
+
const addressLastPart = item.address.slice(
|
|
254
|
+
cw.options.prefix.length + addressCutPrefixLength
|
|
255
|
+
);
|
|
233
256
|
log(
|
|
234
|
-
`👛 ${
|
|
235
|
-
|
|
236
|
-
)}${
|
|
257
|
+
`👛 ${addressStartingSymbol}${magenta(
|
|
258
|
+
addressHighlightedPart
|
|
259
|
+
)}${addressLastPart}`
|
|
237
260
|
);
|
|
238
261
|
} else if (
|
|
239
262
|
cw.suffixFound &&
|
|
240
263
|
cw.suffixFoundInWallets.includes(item.address)
|
|
241
264
|
) {
|
|
242
265
|
// highlight found suffix
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
item.address.length - cw.options.suffix.length
|
|
250
|
-
)
|
|
251
|
-
)}`
|
|
266
|
+
const addressLastPart = item.address.slice(
|
|
267
|
+
0,
|
|
268
|
+
item.address.length - cw.options.suffix.length
|
|
269
|
+
);
|
|
270
|
+
const addressHighlightedSuffix = item.address.slice(
|
|
271
|
+
item.address.length - cw.options.suffix.length
|
|
252
272
|
);
|
|
273
|
+
log(`👛 ${addressLastPart}${magenta(addressHighlightedSuffix)}`);
|
|
253
274
|
} else {
|
|
254
275
|
log(`👛 ${item.address}`);
|
|
255
276
|
}
|
|
@@ -261,6 +282,7 @@ class Method {
|
|
|
261
282
|
outputData.wallets = cw.wallet.addresses;
|
|
262
283
|
}
|
|
263
284
|
|
|
285
|
+
// display path
|
|
264
286
|
if (displayAsText && cw.row.path !== undefined && cw.options.geek) {
|
|
265
287
|
log();
|
|
266
288
|
log(`🗂 wallet address path: ${cw.row.path}'/0'/0/ID`);
|
|
@@ -324,8 +346,18 @@ class Method {
|
|
|
324
346
|
log();
|
|
325
347
|
}
|
|
326
348
|
|
|
349
|
+
// attempts
|
|
350
|
+
if (cw.attempts !== undefined && cw.attempts > 0 && cw.options.geek) {
|
|
351
|
+
log(
|
|
352
|
+
`🔍 It took ${cw.attempts} attempt${
|
|
353
|
+
cw.attempts !== 1 ? 's' : ''
|
|
354
|
+
} to generate this wallet`
|
|
355
|
+
);
|
|
356
|
+
log();
|
|
357
|
+
}
|
|
358
|
+
|
|
327
359
|
// tested
|
|
328
|
-
if (cw.wallet.tested !== undefined) {
|
|
360
|
+
if (cw.wallet.tested !== undefined && cw.wallet.tested == false) {
|
|
329
361
|
log(
|
|
330
362
|
red(
|
|
331
363
|
'‼️ This wallet generation format was not tested yet, do not use it!'
|
|
@@ -391,7 +423,7 @@ class Method {
|
|
|
391
423
|
log();
|
|
392
424
|
log(
|
|
393
425
|
blueBright(
|
|
394
|
-
'🙏 Consider supporting
|
|
426
|
+
'🙏 Consider supporting this project - check donations options with: cw --donate'
|
|
395
427
|
)
|
|
396
428
|
);
|
|
397
429
|
}
|
package/src/Wallet.js
CHANGED
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
PublicKey as SolanaPublickey,
|
|
24
24
|
} from '@solana/web3.js';
|
|
25
25
|
import bs58 from 'bs58';
|
|
26
|
-
import
|
|
26
|
+
import TonWeb from 'tonweb';
|
|
27
27
|
import {
|
|
28
28
|
mnemonicNew as newTonMnemonic,
|
|
29
29
|
mnemonicToPrivateKey as TonMnemonicToPrivateKey,
|
|
@@ -53,8 +53,10 @@ class Wallet {
|
|
|
53
53
|
desiredSymbolsUniqueArray.filter(
|
|
54
54
|
(char) => !RegExp(row.prefixTest, 'g').test(char)
|
|
55
55
|
) || [];
|
|
56
|
+
const startsWithSymbols = row.startsWith.split('|');
|
|
56
57
|
|
|
57
58
|
let wallet = {};
|
|
59
|
+
let loops = 0;
|
|
58
60
|
let prefixFound = false;
|
|
59
61
|
let prefixFoundInWallets = [];
|
|
60
62
|
let suffixFound = false;
|
|
@@ -63,13 +65,24 @@ class Wallet {
|
|
|
63
65
|
let onlySuffix = false;
|
|
64
66
|
let onlyBoth = false;
|
|
65
67
|
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
68
|
+
const prefixFoundInAddresses = (addresses, isCaseSensitive, prefix) => {
|
|
69
|
+
return addresses.filter((address) => {
|
|
70
|
+
return startsWithSymbols.some((symbol) => {
|
|
71
|
+
const fullPrefix = `${symbol}${prefix}`;
|
|
72
|
+
return isCaseSensitive
|
|
73
|
+
? address.startsWith(fullPrefix)
|
|
74
|
+
: address.toUpperCase().startsWith(fullPrefix.toUpperCase());
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const suffixFoundInAddresses = (addresses, isCaseSensitive, suffix) => {
|
|
80
|
+
return addresses.filter((address) => {
|
|
81
|
+
return isCaseSensitive
|
|
82
|
+
? address.endsWith(suffix)
|
|
83
|
+
: address.toUpperCase().endsWith(suffix.toUpperCase());
|
|
84
|
+
});
|
|
85
|
+
};
|
|
73
86
|
|
|
74
87
|
if (
|
|
75
88
|
(options.prefix && row.flags.includes('p')) ||
|
|
@@ -107,114 +120,68 @@ class Wallet {
|
|
|
107
120
|
}
|
|
108
121
|
}
|
|
109
122
|
|
|
110
|
-
const startsWithSymbols = row.startsWith.split('|');
|
|
111
123
|
// eslint-disable-next-line no-constant-condition
|
|
112
124
|
loop: while (true) {
|
|
113
125
|
wallet = await this.createWallet();
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
+
loops++;
|
|
127
|
+
|
|
128
|
+
if (!wallet.error) {
|
|
129
|
+
let addresses = [];
|
|
130
|
+
if (wallet.addresses === undefined) {
|
|
131
|
+
addresses.push(wallet.address);
|
|
132
|
+
} else {
|
|
133
|
+
addresses = wallet.addresses.map((item) => item.address);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (onlyPrefix) {
|
|
137
|
+
prefixFoundInWallets = prefixFoundInAddresses(
|
|
138
|
+
addresses,
|
|
139
|
+
options.prefixIsCaseSensitive,
|
|
140
|
+
options.prefix
|
|
141
|
+
);
|
|
142
|
+
if (prefixFoundInWallets.length > 0) {
|
|
126
143
|
prefixFound = true;
|
|
127
|
-
break loop;
|
|
128
144
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
)
|
|
137
|
-
) {
|
|
145
|
+
} else if (onlySuffix) {
|
|
146
|
+
suffixFoundInWallets = suffixFoundInAddresses(
|
|
147
|
+
addresses,
|
|
148
|
+
options.suffixIsCaseSensitive,
|
|
149
|
+
options.suffix
|
|
150
|
+
);
|
|
151
|
+
if (suffixFoundInWallets.length > 0) {
|
|
138
152
|
suffixFound = true;
|
|
139
|
-
break loop;
|
|
140
153
|
}
|
|
141
|
-
|
|
154
|
+
} else if (onlyBoth) {
|
|
155
|
+
prefixFoundInWallets = prefixFoundInAddresses(
|
|
156
|
+
addresses,
|
|
157
|
+
options.prefixIsCaseSensitive,
|
|
158
|
+
options.prefix
|
|
159
|
+
);
|
|
160
|
+
suffixFoundInWallets = suffixFoundInAddresses(
|
|
161
|
+
addresses,
|
|
162
|
+
options.suffixIsCaseSensitive,
|
|
163
|
+
options.suffix
|
|
164
|
+
);
|
|
142
165
|
if (
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
wallet.address,
|
|
146
|
-
options.prefixIsCaseSensitive,
|
|
147
|
-
options.prefix,
|
|
148
|
-
firstSymbol
|
|
149
|
-
) &&
|
|
150
|
-
suffixFoundInAddress(
|
|
151
|
-
wallet.address,
|
|
152
|
-
options.suffixIsCaseSensitive,
|
|
153
|
-
options.suffix
|
|
154
|
-
)
|
|
166
|
+
prefixFoundInWallets.length > 0 &&
|
|
167
|
+
suffixFoundInWallets.length > 0
|
|
155
168
|
) {
|
|
156
169
|
prefixFound = true;
|
|
157
170
|
suffixFound = true;
|
|
158
|
-
break loop;
|
|
159
171
|
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
options.prefixIsCaseSensitive,
|
|
168
|
-
options.prefix,
|
|
169
|
-
firstSymbol
|
|
170
|
-
)
|
|
171
|
-
) {
|
|
172
|
-
prefixFound = true;
|
|
173
|
-
prefixFoundInWallets.push(item.address);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
if (
|
|
177
|
-
onlySuffix &&
|
|
178
|
-
suffixFoundInAddress(
|
|
179
|
-
item.address,
|
|
180
|
-
options.suffixIsCaseSensitive,
|
|
181
|
-
options.suffix
|
|
182
|
-
)
|
|
183
|
-
) {
|
|
184
|
-
suffixFound = true;
|
|
185
|
-
suffixFoundInWallets.push(item.address);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
if (
|
|
189
|
-
onlyBoth &&
|
|
190
|
-
prefixFoundInAddress(
|
|
191
|
-
item.address,
|
|
192
|
-
options.prefixIsCaseSensitive,
|
|
193
|
-
options.prefix,
|
|
194
|
-
firstSymbol
|
|
195
|
-
) &&
|
|
196
|
-
suffixFoundInAddress(
|
|
197
|
-
item.address,
|
|
198
|
-
options.suffixIsCaseSensitive,
|
|
199
|
-
options.suffix
|
|
200
|
-
)
|
|
201
|
-
) {
|
|
202
|
-
prefixFound = true;
|
|
203
|
-
prefixFoundInWallets.push(item.address);
|
|
204
|
-
suffixFound = true;
|
|
205
|
-
suffixFoundInWallets.push(item.address);
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
if (
|
|
209
|
-
(onlyPrefix && prefixFound) ||
|
|
210
|
-
(onlySuffix && suffixFound) ||
|
|
211
|
-
(onlyBoth && prefixFound && suffixFound)
|
|
212
|
-
) {
|
|
213
|
-
break loop;
|
|
214
|
-
}
|
|
215
|
-
} else {
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
if (
|
|
175
|
+
(onlyPrefix && prefixFound) ||
|
|
176
|
+
(onlySuffix && suffixFound) ||
|
|
177
|
+
(onlyBoth && prefixFound && suffixFound)
|
|
178
|
+
) {
|
|
216
179
|
break loop;
|
|
217
180
|
}
|
|
181
|
+
} else {
|
|
182
|
+
log(red('⛔️ Error: ' + wallet.error));
|
|
183
|
+
// eslint-disable-next-line no-undef
|
|
184
|
+
process.exit(1);
|
|
218
185
|
}
|
|
219
186
|
}
|
|
220
187
|
} else {
|
|
@@ -244,6 +211,7 @@ class Wallet {
|
|
|
244
211
|
prefixFoundInWallets,
|
|
245
212
|
suffixFound,
|
|
246
213
|
suffixFoundInWallets,
|
|
214
|
+
attempts: loops,
|
|
247
215
|
};
|
|
248
216
|
}
|
|
249
217
|
|
|
@@ -260,7 +228,9 @@ class Wallet {
|
|
|
260
228
|
const mnemonicWordsCount = (mnemonic.split(' ') || []).length || 0;
|
|
261
229
|
if (mnemonicWordsCount == 1) {
|
|
262
230
|
const mnemonicInput = parseInt(mnemonic.split(' ')[0], 10);
|
|
263
|
-
mnemonicLength = supportedMnemonicLengths.includes(mnemonicInput)
|
|
231
|
+
mnemonicLength = supportedMnemonicLengths.includes(mnemonicInput)
|
|
232
|
+
? mnemonicInput
|
|
233
|
+
: 12;
|
|
264
234
|
} else {
|
|
265
235
|
mnemonicString = mnemonic;
|
|
266
236
|
mnemonicLength = mnemonicWordsCount;
|
|
@@ -475,23 +445,21 @@ class Wallet {
|
|
|
475
445
|
mnemonicString = mnemonics.join(' ');
|
|
476
446
|
}
|
|
477
447
|
const keyPair = await TonMnemonicToPrivateKey(mnemonics);
|
|
478
|
-
|
|
479
|
-
const
|
|
480
|
-
|
|
481
|
-
const
|
|
482
|
-
|
|
483
|
-
publicKey: keyPair.publicKey,
|
|
484
|
-
});
|
|
485
|
-
// Get the wallet address
|
|
486
|
-
const address = wallet.address.toString();
|
|
487
|
-
|
|
488
|
-
// TODO: add support for new UQ address format
|
|
448
|
+
const tonweb = new TonWeb();
|
|
449
|
+
const wallet = tonweb.wallet.create({ publicKey: keyPair.publicKey });
|
|
450
|
+
const address = await wallet.getAddress();
|
|
451
|
+
const nonBounceableAddress = address.toString(true, true, false);
|
|
452
|
+
const bouncableAddress = address.toString(true, true, true);
|
|
489
453
|
|
|
490
454
|
Object.assign(result, {
|
|
491
455
|
addresses: [
|
|
492
456
|
{
|
|
493
|
-
|
|
494
|
-
address,
|
|
457
|
+
title: 'UQ format (new): best for wallets, - non-bounceable',
|
|
458
|
+
address: nonBounceableAddress,
|
|
459
|
+
},
|
|
460
|
+
{
|
|
461
|
+
title: 'EQ format (old): best for smart contracts, - bounceable',
|
|
462
|
+
address: bouncableAddress,
|
|
495
463
|
},
|
|
496
464
|
],
|
|
497
465
|
mnemonic: mnemonicString,
|
package/src/chains/ERC.json
CHANGED