@yerofey/cryptowallet-cli 1.3.0 → 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 CHANGED
@@ -26,10 +26,10 @@ $ cw -p aaa
26
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 sensitive)
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 insensitive)
32
+ # generate random BTC wallet with desired prefix (case-sensitive)
33
33
  $ cw -c BTC -P abc
34
34
 
35
35
  # generate BTC legacy wallet ("1...")
@@ -95,10 +95,10 @@ $ 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-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**)
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**)
102
102
  * `-v` or `--version`: Display the version of CW tool
103
103
 
104
104
  ## Highlights
package/cli.js CHANGED
@@ -12,10 +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 (case sensitive)');
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)');
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)');
19
19
  program.option('-v, --version', 'Display cryptowallet version');
20
20
  program.parse();
21
21
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yerofey/cryptowallet-cli",
3
- "version": "1.3.0",
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": {
package/src/CW.js CHANGED
@@ -9,10 +9,10 @@ class CW {
9
9
  geek: false,
10
10
  mnemonic: '',
11
11
  number: 1,
12
- prefix: options.prefixIgnorecase || '',
13
- prefixIgnoreCase: options.prefixIgnorecase !== undefined,
14
- suffix: options.suffixIgnorecase || '',
15
- suffixIgnoreCase: options.suffixIgnorecase !== undefined,
12
+ prefix: options.prefixSensitive || '',
13
+ prefixIsCaseSensitive: options.prefixSensitive !== undefined,
14
+ suffix: options.suffixSensitive || '',
15
+ suffixIsCaseSensitive: options.suffixSensitive !== undefined,
16
16
  }
17
17
 
18
18
  for (const key of Object.keys(defaultValues)) {
package/src/Method.js CHANGED
@@ -94,7 +94,6 @@ class Method {
94
94
 
95
95
  if (cw.prefixFound && cw.prefixFoundInWallets.includes(item.address) && cw.suffixFound && cw.suffixFoundInWallets.includes(item.address)) {
96
96
  // highlight found prefix
97
- // log(`👛 ${item.address}`);
98
97
  const addressCutPrefixLength = cw.row.startsWith.length + cw.options.prefix.length;
99
98
  const addressFirstPart = item.address.slice(cw.row.startsWith.length, addressCutPrefixLength);
100
99
  const addressLastPart = item.address.slice(item.address.length - cw.options.suffix.length);
package/src/Wallet.js CHANGED
@@ -11,7 +11,10 @@ class Wallet {
11
11
  const row = cw.row;
12
12
  const options = cw.options;
13
13
 
14
- const badSymbolsArray = (options.prefix != '' ? options.prefix.split('').filter(char => !RegExp(row.prefixTest, 'g').test(char)) : []);
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,8 +24,8 @@ class Wallet {
21
24
  let onlySuffix = false;
22
25
  let onlyBoth = false;
23
26
 
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));
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));
26
29
 
27
30
  if (options.prefix && row.flags.includes('p') || options.suffix && row.flags.includes('s')) {
28
31
  if (badSymbolsArray.length === 0) {
@@ -49,34 +52,34 @@ class Wallet {
49
52
  wallet = await this.createWallet();
50
53
  for (let firstSymbol of startsWithSymbols) {
51
54
  if (wallet.address !== undefined) { // one address
52
- if (onlyPrefix && prefixFoundInAddress(wallet.address, options.prefixIgnoreCase, options.prefix, firstSymbol)) {
55
+ if (onlyPrefix && prefixFoundInAddress(wallet.address, options.prefixIsCaseSensitive, options.prefix, firstSymbol)) {
53
56
  prefixFound = true;
54
57
  break loop;
55
58
  }
56
59
 
57
- if (onlySuffix && suffixFoundInAddress(wallet.address, options.suffixIgnoreCase, options.suffix)) {
60
+ if (onlySuffix && suffixFoundInAddress(wallet.address, options.suffixIsCaseSensitive, options.suffix)) {
58
61
  suffixFound = true;
59
62
  break loop;
60
63
  }
61
64
 
62
- if (onlyBoth && prefixFoundInAddress(wallet.address, options.prefixIgnoreCase, options.prefix, firstSymbol) && suffixFoundInAddress(wallet.address, options.suffixIgnoreCase, options.suffix)) {
65
+ if (onlyBoth && prefixFoundInAddress(wallet.address, options.prefixIsCaseSensitive, options.prefix, firstSymbol) && suffixFoundInAddress(wallet.address, options.suffixIsCaseSensitive, options.suffix)) {
63
66
  prefixFound = true;
64
67
  suffixFound = true;
65
68
  break loop;
66
69
  }
67
70
  } else if (wallet.addresses !== undefined) { // multiple addresses
68
71
  for (let item of wallet.addresses) {
69
- if (onlyPrefix && prefixFoundInAddress(item.address, options.prefixIgnoreCase, options.prefix, firstSymbol)) {
72
+ if (onlyPrefix && prefixFoundInAddress(item.address, options.prefixIsCaseSensitive, options.prefix, firstSymbol)) {
70
73
  prefixFound = true;
71
74
  prefixFoundInWallets.push(item.address);
72
75
  }
73
76
 
74
- if (onlySuffix && suffixFoundInAddress(item.address, options.suffixIgnoreCase, options.suffix)) {
77
+ if (onlySuffix && suffixFoundInAddress(item.address, options.suffixIsCaseSensitive, options.suffix)) {
75
78
  suffixFound = true;
76
79
  suffixFoundInWallets.push(item.address);
77
80
  }
78
81
 
79
- if (onlyBoth && prefixFoundInAddress(item.address, options.prefixIgnoreCase, options.prefix, firstSymbol) && suffixFoundInAddress(item.address, options.suffixIgnoreCase, options.suffix)) {
82
+ if (onlyBoth && prefixFoundInAddress(item.address, options.prefixIsCaseSensitive, options.prefix, firstSymbol) && suffixFoundInAddress(item.address, options.suffixIsCaseSensitive, options.suffix)) {
80
83
  prefixFound = true;
81
84
  prefixFoundInWallets.push(item.address);
82
85
  suffixFound = true;