@yerofey/cryptowallet-cli 1.2.11 → 1.2.12
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/package.json +4 -4
- package/src/Wallet.js +48 -8
- package/src/coins/BNB.json +3 -0
- package/src/coins/ERC.json +1 -0
- package/src/coins/ETC.json +1 -0
- package/src/coins/ETH.json +1 -0
- package/src/coins/POLYGON.json +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yerofey/cryptowallet-cli",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.12",
|
|
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/Wallet.js
CHANGED
|
@@ -169,19 +169,36 @@ class Wallet {
|
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
+
let addresses = [];
|
|
172
173
|
const mnemonic = mnemonicString || bip39.generateMnemonic();
|
|
173
|
-
|
|
174
|
-
|
|
174
|
+
|
|
175
|
+
if (number == 1) {
|
|
176
|
+
const privateKey = bCrypto.getPrivateKeyFromMnemonic(mnemonic, true, 0);
|
|
177
|
+
addresses.push({
|
|
178
|
+
address: bCrypto.getAddressFromPrivateKey(privateKey, 'bnb'),
|
|
179
|
+
privateKey
|
|
180
|
+
});
|
|
181
|
+
} else {
|
|
182
|
+
for (let i = 0; i <= number; i++) {
|
|
183
|
+
const privateKey = bCrypto.getPrivateKeyFromMnemonic(mnemonic, true, i);
|
|
184
|
+
addresses.push({
|
|
185
|
+
index: i,
|
|
186
|
+
address: bCrypto.getAddressFromPrivateKey(privateKey, 'bnb'),
|
|
187
|
+
privateKey
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
175
192
|
Object.assign(result, {
|
|
176
193
|
format: 'BEP2',
|
|
177
|
-
|
|
178
|
-
privateKey,
|
|
194
|
+
addresses,
|
|
179
195
|
mnemonic
|
|
180
196
|
});
|
|
181
197
|
} else if (row.network == 'EVM') {
|
|
182
198
|
const bip39 = require('bip39');
|
|
183
199
|
const pkutils = require('ethereum-mnemonic-privatekey-utils');
|
|
184
200
|
const { Account } = require('eth-lib/lib');
|
|
201
|
+
const { fromMnemonic, fromZPrv } = require('ethereum-bip84');
|
|
185
202
|
|
|
186
203
|
if (mnemonicString != '' && !bip39.validateMnemonic(mnemonicString)) {
|
|
187
204
|
return {
|
|
@@ -189,14 +206,37 @@ class Wallet {
|
|
|
189
206
|
}
|
|
190
207
|
}
|
|
191
208
|
|
|
209
|
+
let addresses = [];
|
|
192
210
|
const mnemonic = mnemonicString || bip39.generateMnemonic();
|
|
193
211
|
const privateKey = pkutils.getPrivateKeyFromMnemonic(mnemonic);
|
|
194
|
-
|
|
195
|
-
|
|
212
|
+
|
|
213
|
+
if (number == 1) {
|
|
214
|
+
const account = Account.fromPrivate('0x' + privateKey);
|
|
215
|
+
|
|
216
|
+
addresses.push({
|
|
217
|
+
address: account.address,
|
|
218
|
+
privateKey
|
|
219
|
+
});
|
|
220
|
+
} else {
|
|
221
|
+
// TODO: add variable for accountId
|
|
222
|
+
const root = new fromMnemonic(mnemonic, '');
|
|
223
|
+
const child = root.deriveAccount(0);
|
|
224
|
+
const account = new fromZPrv(child);
|
|
225
|
+
for (let walletId = 0; walletId <= number; walletId++) {
|
|
226
|
+
const walletAddress = account.getAddress(walletId);
|
|
227
|
+
const privateKey = account.getPrivateKey(walletId);
|
|
228
|
+
|
|
229
|
+
addresses.push({
|
|
230
|
+
index: walletId,
|
|
231
|
+
address: walletAddress,
|
|
232
|
+
privateKey
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
196
237
|
Object.assign(result, {
|
|
197
238
|
format: row.format || '',
|
|
198
|
-
|
|
199
|
-
privateKey: privateKey,
|
|
239
|
+
addresses,
|
|
200
240
|
mnemonic
|
|
201
241
|
});
|
|
202
242
|
} else if (coin == 'ONE') {
|
package/src/coins/BNB.json
CHANGED
package/src/coins/ERC.json
CHANGED
package/src/coins/ETC.json
CHANGED
package/src/coins/ETH.json
CHANGED