jcc_wallet 3.0.2 → 4.0.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/dist/jcc-wallet.min.js +24 -45
- package/lib/{constant/index.js → constant.js} +8 -8
- package/lib/constant.js.map +1 -0
- package/lib/hd/constant.js +4 -4
- package/lib/hd/constant.js.map +1 -1
- package/lib/hd/eos.plugin.js +36 -39
- package/lib/hd/eos.plugin.js.map +1 -1
- package/lib/hd/ethereum.plugin.d.ts +1 -0
- package/lib/hd/ethereum.plugin.js +86 -67
- package/lib/hd/ethereum.plugin.js.map +1 -1
- package/lib/hd/index.d.ts +1 -1
- package/lib/hd/index.js +167 -179
- package/lib/hd/index.js.map +1 -1
- package/lib/hd/plugins.d.ts +9 -0
- package/lib/hd/plugins.js +26 -22
- package/lib/hd/plugins.js.map +1 -1
- package/lib/hd/swtc.plugin.d.ts +1 -5
- package/lib/hd/swtc.plugin.js +74 -60
- package/lib/hd/swtc.plugin.js.map +1 -1
- package/lib/hd/tron.plugin.js +28 -33
- package/lib/hd/tron.plugin.js.map +1 -1
- package/lib/index.d.ts +3 -4
- package/lib/index.js +6 -8
- package/lib/index.js.map +1 -1
- package/lib/{jingchangWallet/index.d.ts → jingchangWallet.d.ts} +1 -1
- package/lib/jingchangWallet.js +531 -0
- package/lib/jingchangWallet.js.map +1 -0
- package/lib/minify-ethereumjs-util/account.d.ts +1 -0
- package/lib/minify-ethereumjs-util/account.js +22 -0
- package/lib/minify-ethereumjs-util/account.js.map +1 -0
- package/lib/minify-ethereumjs-util/bytes.d.ts +7 -0
- package/lib/minify-ethereumjs-util/bytes.js +100 -0
- package/lib/minify-ethereumjs-util/bytes.js.map +1 -0
- package/lib/minify-ethereumjs-util/constants.d.ts +4 -0
- package/lib/minify-ethereumjs-util/constants.js +9 -0
- package/lib/minify-ethereumjs-util/constants.js.map +1 -0
- package/lib/minify-ethereumjs-util/helper.d.ts +5 -0
- package/lib/minify-ethereumjs-util/helper.js +16 -0
- package/lib/minify-ethereumjs-util/helper.js.map +1 -0
- package/lib/minify-ethereumjs-util/internal.d.ts +8 -0
- package/lib/minify-ethereumjs-util/internal.js +33 -0
- package/lib/minify-ethereumjs-util/internal.js.map +1 -0
- package/lib/minify-ethereumjs-util/signature.d.ts +13 -0
- package/lib/minify-ethereumjs-util/signature.js +45 -0
- package/lib/minify-ethereumjs-util/signature.js.map +1 -0
- package/lib/minify-swtc-keypair/address-codec.d.ts +16 -0
- package/lib/minify-swtc-keypair/address-codec.js +166 -0
- package/lib/minify-swtc-keypair/address-codec.js.map +1 -0
- package/lib/minify-swtc-keypair/index.d.ts +25 -0
- package/lib/minify-swtc-keypair/index.js +178 -0
- package/lib/minify-swtc-keypair/index.js.map +1 -0
- package/lib/minify-swtc-keypair/sha512.d.ts +9 -0
- package/lib/minify-swtc-keypair/sha512.js +33 -0
- package/lib/minify-swtc-keypair/sha512.js.map +1 -0
- package/lib/minify-swtc-keypair/utils.d.ts +13 -0
- package/lib/minify-swtc-keypair/utils.js +63 -0
- package/lib/minify-swtc-keypair/utils.js.map +1 -0
- package/lib/minify-tron/address.d.ts +6 -0
- package/lib/minify-tron/address.js +11 -0
- package/lib/minify-tron/address.js.map +1 -0
- package/lib/minify-tron/base58.d.ts +2 -0
- package/lib/minify-tron/base58.js +67 -0
- package/lib/minify-tron/base58.js.map +1 -0
- package/lib/minify-tron/bytes.d.ts +2 -0
- package/lib/minify-tron/bytes.js +23 -0
- package/lib/minify-tron/bytes.js.map +1 -0
- package/lib/minify-tron/code.d.ts +3 -0
- package/lib/minify-tron/code.js +56 -0
- package/lib/minify-tron/code.js.map +1 -0
- package/lib/minify-tron/crypto.d.ts +7 -0
- package/lib/minify-tron/crypto.js +83 -0
- package/lib/minify-tron/crypto.js.map +1 -0
- package/lib/minify-tron/message.d.ts +4 -0
- package/lib/minify-tron/message.js +42 -0
- package/lib/minify-tron/message.js.map +1 -0
- package/lib/{types/index.d.ts → types.d.ts} +16 -3
- package/lib/types.js +16 -0
- package/lib/types.js.map +1 -0
- package/lib/util/index.js +40 -30
- package/lib/util/index.js.map +1 -1
- package/package.json +21 -16
- package/lib/constant/index.js.map +0 -1
- package/lib/eth/index.d.ts +0 -37
- package/lib/eth/index.js +0 -98
- package/lib/eth/index.js.map +0 -1
- package/lib/jingchangWallet/index.js +0 -713
- package/lib/jingchangWallet/index.js.map +0 -1
- package/lib/moac/index.d.ts +0 -29
- package/lib/moac/index.js +0 -58
- package/lib/moac/index.js.map +0 -1
- package/lib/types/index.js +0 -3
- package/lib/types/index.js.map +0 -1
- package/lib/x-wallet/index.d.ts +0 -22
- package/lib/x-wallet/index.js +0 -86
- package/lib/x-wallet/index.js.map +0 -1
- /package/lib/{constant/index.d.ts → constant.d.ts} +0 -0
package/lib/hd/index.js
CHANGED
|
@@ -22,22 +22,19 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
26
|
exports.HDWallet = exports.getBIP44Chain = exports.BIP44ChainMap = exports.BIP44Chain = void 0;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
var constant_1 = require("./constant");
|
|
27
|
+
const minify_swtc_keypair_1 = require("../minify-swtc-keypair");
|
|
28
|
+
const BIP39 = __importStar(require("bip39"));
|
|
29
|
+
const bip32_1 = require("@scure/bip32");
|
|
30
|
+
const constant_1 = require("./constant");
|
|
35
31
|
Object.defineProperty(exports, "BIP44Chain", { enumerable: true, get: function () { return constant_1.BIP44Chain; } });
|
|
36
32
|
Object.defineProperty(exports, "BIP44ChainMap", { enumerable: true, get: function () { return constant_1.BIP44ChainMap; } });
|
|
37
33
|
Object.defineProperty(exports, "getBIP44Chain", { enumerable: true, get: function () { return constant_1.getBIP44Chain; } });
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
34
|
+
const plugins_1 = require("./plugins");
|
|
35
|
+
const types_1 = require("../types");
|
|
36
|
+
const keypair = (0, minify_swtc_keypair_1.Factory)(types_1.Alphabet.JINGTUM);
|
|
37
|
+
class HDWallet {
|
|
41
38
|
/**
|
|
42
39
|
* generate hd wallet
|
|
43
40
|
*
|
|
@@ -56,15 +53,14 @@ var HDWallet = /** @class */ (function () {
|
|
|
56
53
|
* 3. {keypair: {....}, path:{....}}
|
|
57
54
|
* @returns {object} return hd wallet object
|
|
58
55
|
*/
|
|
59
|
-
|
|
60
|
-
var _this = this;
|
|
56
|
+
constructor(opt) {
|
|
61
57
|
/**
|
|
62
58
|
* hd wallet is root or not
|
|
63
59
|
*
|
|
64
60
|
* @returns {boolean} return hd wallet root or not
|
|
65
61
|
*/
|
|
66
|
-
this.isRoot =
|
|
67
|
-
return
|
|
62
|
+
this.isRoot = () => {
|
|
63
|
+
return this._path.chain + this._path.account + this._path.change + this._path.index === 0;
|
|
68
64
|
};
|
|
69
65
|
/**
|
|
70
66
|
* generate hd wallet by derive path, obey BIP44 protocol
|
|
@@ -78,11 +74,11 @@ var HDWallet = /** @class */ (function () {
|
|
|
78
74
|
* }
|
|
79
75
|
* @returns {object} return hd wallet object
|
|
80
76
|
*/
|
|
81
|
-
this.deriveWallet =
|
|
77
|
+
this.deriveWallet = (opt) => {
|
|
82
78
|
if (isNaN(opt.chain) || isNaN(opt.account) || isNaN(opt.index)) {
|
|
83
79
|
return null;
|
|
84
80
|
}
|
|
85
|
-
|
|
81
|
+
const hdKeypair = HDWallet.getHDKeypair(this._secret, opt.chain, opt.account, opt.index);
|
|
86
82
|
return new HDWallet({
|
|
87
83
|
keypair: hdKeypair,
|
|
88
84
|
path: { chain: opt.chain, account: opt.account, change: 0, index: opt.index }
|
|
@@ -93,44 +89,44 @@ var HDWallet = /** @class */ (function () {
|
|
|
93
89
|
*
|
|
94
90
|
* @returns {string} return wallet secret
|
|
95
91
|
*/
|
|
96
|
-
this.secret =
|
|
97
|
-
return
|
|
92
|
+
this.secret = () => {
|
|
93
|
+
return this._secret;
|
|
98
94
|
};
|
|
99
95
|
/**
|
|
100
96
|
* get wallet mnemonic
|
|
101
97
|
*
|
|
102
98
|
* @returns {IMnemonic} return IMnemonic object
|
|
103
99
|
*/
|
|
104
|
-
this.mnemonic =
|
|
105
|
-
return
|
|
100
|
+
this.mnemonic = () => {
|
|
101
|
+
return this._mnemonic;
|
|
106
102
|
};
|
|
107
103
|
/**
|
|
108
104
|
* get chain of hd wallet
|
|
109
105
|
*
|
|
110
106
|
* @returns {string} return chain of hd wallet
|
|
111
107
|
*/
|
|
112
|
-
this.chain =
|
|
113
|
-
return
|
|
108
|
+
this.chain = () => {
|
|
109
|
+
return this.isRoot() ? constant_1.BIP44ChainMap.get(constant_1.BIP44Chain.SWTC) : constant_1.BIP44ChainMap.get(this._path.chain);
|
|
114
110
|
};
|
|
115
111
|
/**
|
|
116
112
|
* get address of hd wallet
|
|
117
113
|
*
|
|
118
114
|
* @returns {string} return address of hd wallet
|
|
119
115
|
*/
|
|
120
|
-
this.address =
|
|
121
|
-
if (!
|
|
122
|
-
|
|
123
|
-
|
|
116
|
+
this.address = () => {
|
|
117
|
+
if (!this._address) {
|
|
118
|
+
const chain = this.chain();
|
|
119
|
+
this._address = (0, plugins_1.getPluginByType)(chain).address(this._secret ? this._secret : this._keypair, chain);
|
|
124
120
|
}
|
|
125
|
-
return
|
|
121
|
+
return this._address;
|
|
126
122
|
};
|
|
127
123
|
/**
|
|
128
124
|
* check address valid or not
|
|
129
125
|
* @param {string} address
|
|
130
126
|
* @returns {boolean} true valid, false invalid
|
|
131
127
|
*/
|
|
132
|
-
this.isValidAddress =
|
|
133
|
-
return (0, plugins_1.getPluginByType)(
|
|
128
|
+
this.isValidAddress = (address) => {
|
|
129
|
+
return (0, plugins_1.getPluginByType)(this.chain()).isValidAddress(address);
|
|
134
130
|
};
|
|
135
131
|
/**
|
|
136
132
|
* check secret valid or not
|
|
@@ -138,8 +134,8 @@ var HDWallet = /** @class */ (function () {
|
|
|
138
134
|
* @param {string} secret
|
|
139
135
|
* @returns {boolean} true valid, false invalid
|
|
140
136
|
*/
|
|
141
|
-
this.isValidSecret =
|
|
142
|
-
return (0, plugins_1.getPluginByType)(
|
|
137
|
+
this.isValidSecret = (address) => {
|
|
138
|
+
return (0, plugins_1.getPluginByType)(this.chain()).isValidSecret(address);
|
|
143
139
|
};
|
|
144
140
|
/**
|
|
145
141
|
* hash message
|
|
@@ -147,8 +143,8 @@ var HDWallet = /** @class */ (function () {
|
|
|
147
143
|
* @param {string} message
|
|
148
144
|
* @returns {string} return hash of message
|
|
149
145
|
*/
|
|
150
|
-
this.hash =
|
|
151
|
-
return (0, plugins_1.getPluginByType)(
|
|
146
|
+
this.hash = (message) => {
|
|
147
|
+
return (0, plugins_1.getPluginByType)(this.chain()).hash(message);
|
|
152
148
|
};
|
|
153
149
|
/**
|
|
154
150
|
* sign message
|
|
@@ -158,8 +154,8 @@ var HDWallet = /** @class */ (function () {
|
|
|
158
154
|
* @param {string} message
|
|
159
155
|
* @returns {string} return signature string
|
|
160
156
|
*/
|
|
161
|
-
this.sign =
|
|
162
|
-
return (0, plugins_1.getPluginByType)(
|
|
157
|
+
this.sign = (message) => {
|
|
158
|
+
return (0, plugins_1.getPluginByType)(this.chain()).sign(message, this._keypair.privateKey);
|
|
163
159
|
};
|
|
164
160
|
/**
|
|
165
161
|
* verify signature valid or not
|
|
@@ -171,14 +167,14 @@ var HDWallet = /** @class */ (function () {
|
|
|
171
167
|
*
|
|
172
168
|
* @returns {boolean} true valid, false invalid
|
|
173
169
|
*/
|
|
174
|
-
this.verify =
|
|
170
|
+
this.verify = (messgae, signature, address, keypair) => {
|
|
175
171
|
if (!address) {
|
|
176
|
-
address =
|
|
172
|
+
address = this.address();
|
|
177
173
|
}
|
|
178
174
|
if (!keypair) {
|
|
179
|
-
keypair =
|
|
175
|
+
keypair = this._keypair;
|
|
180
176
|
}
|
|
181
|
-
return (0, plugins_1.getPluginByType)(
|
|
177
|
+
return (0, plugins_1.getPluginByType)(this.chain()).verify(messgae, signature, address, keypair);
|
|
182
178
|
};
|
|
183
179
|
/**
|
|
184
180
|
* recover address/account from signature
|
|
@@ -188,39 +184,39 @@ var HDWallet = /** @class */ (function () {
|
|
|
188
184
|
*
|
|
189
185
|
* @returns {string} return address
|
|
190
186
|
*/
|
|
191
|
-
this.recover =
|
|
192
|
-
return (0, plugins_1.getPluginByType)(
|
|
187
|
+
this.recover = (messgae, signature) => {
|
|
188
|
+
return (0, plugins_1.getPluginByType)(this.chain()).recover(messgae, signature);
|
|
193
189
|
};
|
|
194
190
|
/**
|
|
195
191
|
* get specified chain wallet api
|
|
196
192
|
*
|
|
197
193
|
* @returns {IHDPlugin} return hd plugin object
|
|
198
194
|
*/
|
|
199
|
-
this.getWalletApi =
|
|
200
|
-
return (0, plugins_1.getPluginByType)(
|
|
195
|
+
this.getWalletApi = () => {
|
|
196
|
+
return (0, plugins_1.getPluginByType)(this.chain());
|
|
201
197
|
};
|
|
202
198
|
/**
|
|
203
199
|
* get keypair of hd wallet
|
|
204
200
|
*
|
|
205
201
|
* @returns {IKeyPair} return keypair of message
|
|
206
202
|
*/
|
|
207
|
-
this.keypair =
|
|
208
|
-
return
|
|
203
|
+
this.keypair = () => {
|
|
204
|
+
return this._keypair;
|
|
209
205
|
};
|
|
210
206
|
/**
|
|
211
207
|
* get path of hd wallet
|
|
212
208
|
*
|
|
213
209
|
* @returns {IBIP44Path} return path of wallet
|
|
214
210
|
*/
|
|
215
|
-
this.path =
|
|
216
|
-
return
|
|
211
|
+
this.path = () => {
|
|
212
|
+
return this._path;
|
|
217
213
|
};
|
|
218
214
|
/**
|
|
219
215
|
* set keypair
|
|
220
216
|
* @param {IKeyPair} keypair
|
|
221
217
|
*/
|
|
222
|
-
this.setKeypair =
|
|
223
|
-
|
|
218
|
+
this.setKeypair = (keypair) => {
|
|
219
|
+
this._keypair = keypair;
|
|
224
220
|
};
|
|
225
221
|
if (!opt) {
|
|
226
222
|
throw new Error("undefined parameters: " + opt);
|
|
@@ -261,134 +257,126 @@ var HDWallet = /** @class */ (function () {
|
|
|
261
257
|
// parameter error;
|
|
262
258
|
throw new Error("invalid parameters: " + opt);
|
|
263
259
|
}
|
|
264
|
-
|
|
265
|
-
* generate mnemonic
|
|
266
|
-
*
|
|
267
|
-
* @static
|
|
268
|
-
* @param {number} len strength of random bytes, default 128
|
|
269
|
-
* @param {string} language localized word list, default is english. see also https://github.com/bitcoinjs/BIP39
|
|
270
|
-
* @returns {string} return mnemonic string, spilt by blank
|
|
271
|
-
*/
|
|
272
|
-
HDWallet.generateMnemonic = function (len, language) {
|
|
273
|
-
if (len === void 0) { len = 128; }
|
|
274
|
-
if (language === void 0) { language = "english"; }
|
|
275
|
-
BIP39.setDefaultWordlist(language);
|
|
276
|
-
return BIP39.generateMnemonic(len);
|
|
277
|
-
};
|
|
278
|
-
/**
|
|
279
|
-
* get secret from mnemonic, obey encode rule base58 for jingtum
|
|
280
|
-
*
|
|
281
|
-
* @static
|
|
282
|
-
* @param {string} mnemonic mnemonic words
|
|
283
|
-
* @param {string} language localized word list, default is english. see also https://github.com/bitcoinjs/BIP39
|
|
284
|
-
* @returns {string} return secret string
|
|
285
|
-
*/
|
|
286
|
-
HDWallet.getSecretFromMnemonic = function (mnemonic, language) {
|
|
287
|
-
if (language === void 0) { language = "english"; }
|
|
288
|
-
BIP39.setDefaultWordlist(language);
|
|
289
|
-
var entropy = BIP39.mnemonicToEntropy(mnemonic);
|
|
290
|
-
return addressCodec.encodeSeed(Buffer.from(entropy, "hex"));
|
|
291
|
-
};
|
|
292
|
-
/**
|
|
293
|
-
* get mnemonic from secret, obey encode rule base58 for jingtum
|
|
294
|
-
*
|
|
295
|
-
* @static
|
|
296
|
-
* @param {string} secret secret string
|
|
297
|
-
* @param {string} language localized word list, default is english. see also https://github.com/bitcoinjs/BIP39
|
|
298
|
-
* @returns {string} return mnemonic word list
|
|
299
|
-
*/
|
|
300
|
-
HDWallet.getMnemonicFromSecret = function (secret, language) {
|
|
301
|
-
if (language === void 0) { language = "english"; }
|
|
302
|
-
BIP39.setDefaultWordlist(language);
|
|
303
|
-
var entropy = addressCodec.decodeSeed(secret).bytes;
|
|
304
|
-
return BIP39.entropyToMnemonic(entropy);
|
|
305
|
-
};
|
|
306
|
-
/**
|
|
307
|
-
* get keypair from secret
|
|
308
|
-
*
|
|
309
|
-
* @static
|
|
310
|
-
* @param {string} secret secret string
|
|
311
|
-
* @returns {object} return keypair object
|
|
312
|
-
*/
|
|
313
|
-
HDWallet.getKeypairFromSecret = function (secret) {
|
|
314
|
-
return wallet_1.KeyPair.deriveKeypair(secret);
|
|
315
|
-
};
|
|
316
|
-
/**
|
|
317
|
-
* get hd wallet key pair
|
|
318
|
-
*
|
|
319
|
-
* @static
|
|
320
|
-
* @param {string} rootSecret root secret
|
|
321
|
-
* @param {number} chain chain index number
|
|
322
|
-
* @param {number} account bip44 account index for purpose
|
|
323
|
-
* @param {number} index bip44 last level index
|
|
324
|
-
* @returns {IKeyPair} return keypair object
|
|
325
|
-
*/
|
|
326
|
-
HDWallet.getHDKeypair = function (rootSecret, chain, account, index) {
|
|
327
|
-
if (account === void 0) { account = 0; }
|
|
328
|
-
var bip44Chain = (0, constant_1.getBIP44Chain)(chain);
|
|
329
|
-
if (bip44Chain.length === 0) {
|
|
330
|
-
return null;
|
|
331
|
-
}
|
|
332
|
-
// eslint-disable-next-line no-bitwise
|
|
333
|
-
var chainIdx = (bip44Chain[0][0] << 1) >> 1;
|
|
334
|
-
var mnemonic = HDWallet.getMnemonicFromSecret(rootSecret);
|
|
335
|
-
var seed = BIP39.mnemonicToSeedSync(mnemonic);
|
|
336
|
-
var bip32 = (0, bip32_1.default)(ecc);
|
|
337
|
-
var b32 = bip32.fromSeed(seed);
|
|
338
|
-
var privateKey = b32.derivePath("m/44'/".concat(chainIdx, "'/").concat(account, "'/0/").concat(index)).privateKey;
|
|
339
|
-
return wallet_1.KeyPair.deriveKeypair(privateKey.toString("hex"));
|
|
340
|
-
};
|
|
341
|
-
/**
|
|
342
|
-
* generate hd wallet
|
|
343
|
-
*
|
|
344
|
-
* @static
|
|
345
|
-
* @param {any} opt options of generate, like:
|
|
346
|
-
* {
|
|
347
|
-
* len: 128/160/192/224/256, default is 128, determines number of mnemonic word
|
|
348
|
-
* language: english default/chinese_simplified/chinese_traditional/czech/korean/french/japanese/... see also:bip39 https://github.com/bitcoinjs/bip39/tree/master/ts_src/wordlists
|
|
349
|
-
* }
|
|
350
|
-
* @returns {object} return hd wallet object
|
|
351
|
-
*/
|
|
352
|
-
HDWallet.generate = function (opt) {
|
|
353
|
-
if (!opt) {
|
|
354
|
-
opt = {};
|
|
355
|
-
}
|
|
356
|
-
var mnemonic = HDWallet.generateMnemonic(opt.len, opt.language);
|
|
357
|
-
return new HDWallet({ mnemonic: mnemonic, language: opt.language });
|
|
358
|
-
};
|
|
359
|
-
/**
|
|
360
|
-
* create hd wallet from secret
|
|
361
|
-
*
|
|
362
|
-
* @static
|
|
363
|
-
* @param {string} secret secret string
|
|
364
|
-
* @returns {object} return hd wallet object
|
|
365
|
-
*/
|
|
366
|
-
HDWallet.fromSecret = function (secret) {
|
|
367
|
-
return new HDWallet({ secret: secret });
|
|
368
|
-
};
|
|
369
|
-
/**
|
|
370
|
-
* create hd wallet from mnemonic
|
|
371
|
-
*
|
|
372
|
-
* @static
|
|
373
|
-
* @param {IMnemonic} mnemonic object like
|
|
374
|
-
* {mnemonic: "abc abc ...", language: "english"}
|
|
375
|
-
* @returns {object} return hd wallet object
|
|
376
|
-
*/
|
|
377
|
-
HDWallet.fromMnemonic = function (mnemonic) {
|
|
378
|
-
return new HDWallet({ mnemonic: mnemonic.mnemonic, language: mnemonic.language });
|
|
379
|
-
};
|
|
380
|
-
/**
|
|
381
|
-
* create hd wallet from keypair
|
|
382
|
-
*
|
|
383
|
-
* @static
|
|
384
|
-
* @param {IKeyPair} keypair object like
|
|
385
|
-
* {publicKey: "public key...", privateKey: "private key..."}
|
|
386
|
-
* @returns {object} return hd wallet object
|
|
387
|
-
*/
|
|
388
|
-
HDWallet.fromKeypair = function (keypair) {
|
|
389
|
-
return new HDWallet({ keypair: keypair });
|
|
390
|
-
};
|
|
391
|
-
return HDWallet;
|
|
392
|
-
}());
|
|
260
|
+
}
|
|
393
261
|
exports.HDWallet = HDWallet;
|
|
262
|
+
/**
|
|
263
|
+
* generate mnemonic
|
|
264
|
+
*
|
|
265
|
+
* @static
|
|
266
|
+
* @param {number} len strength of random bytes, default 128
|
|
267
|
+
* @param {string} language localized word list, default is english. see also https://github.com/bitcoinjs/BIP39
|
|
268
|
+
* @returns {string} return mnemonic string, spilt by blank
|
|
269
|
+
*/
|
|
270
|
+
HDWallet.generateMnemonic = (len = 128, language = "english") => {
|
|
271
|
+
BIP39.setDefaultWordlist(language);
|
|
272
|
+
return BIP39.generateMnemonic(len);
|
|
273
|
+
};
|
|
274
|
+
/**
|
|
275
|
+
* get secret from mnemonic, obey encode rule base58 for jingtum
|
|
276
|
+
*
|
|
277
|
+
* @static
|
|
278
|
+
* @param {string} mnemonic mnemonic words
|
|
279
|
+
* @param {string} language localized word list, default is english. see also https://github.com/bitcoinjs/BIP39
|
|
280
|
+
* @returns {string} return secret string
|
|
281
|
+
*/
|
|
282
|
+
HDWallet.getSecretFromMnemonic = (mnemonic, language = "english") => {
|
|
283
|
+
BIP39.setDefaultWordlist(language);
|
|
284
|
+
const entropy = BIP39.mnemonicToEntropy(mnemonic);
|
|
285
|
+
return keypair.addressCodec.encodeSeed(Buffer.from(entropy, "hex"));
|
|
286
|
+
};
|
|
287
|
+
/**
|
|
288
|
+
* get mnemonic from secret, obey encode rule base58 for jingtum
|
|
289
|
+
*
|
|
290
|
+
* @static
|
|
291
|
+
* @param {string} secret secret string
|
|
292
|
+
* @param {string} language localized word list, default is english. see also https://github.com/bitcoinjs/BIP39
|
|
293
|
+
* @returns {string} return mnemonic word list
|
|
294
|
+
*/
|
|
295
|
+
HDWallet.getMnemonicFromSecret = (secret, language = "english") => {
|
|
296
|
+
BIP39.setDefaultWordlist(language);
|
|
297
|
+
const entropy = keypair.addressCodec.decodeSeed(secret).bytes;
|
|
298
|
+
return BIP39.entropyToMnemonic(entropy);
|
|
299
|
+
};
|
|
300
|
+
/**
|
|
301
|
+
* get keypair from secret
|
|
302
|
+
*
|
|
303
|
+
* @static
|
|
304
|
+
* @param {string} secret secret string
|
|
305
|
+
* @returns {object} return keypair object
|
|
306
|
+
*/
|
|
307
|
+
HDWallet.getKeypairFromSecret = (secret) => {
|
|
308
|
+
return keypair.deriveKeyPair(secret);
|
|
309
|
+
};
|
|
310
|
+
/**
|
|
311
|
+
* get hd wallet key pair
|
|
312
|
+
*
|
|
313
|
+
* @static
|
|
314
|
+
* @param {string} rootSecret root secret
|
|
315
|
+
* @param {number} chain chain index number
|
|
316
|
+
* @param {number} account bip44 account index for purpose
|
|
317
|
+
* @param {number} index bip44 last level index
|
|
318
|
+
* @returns {IKeyPair} return keypair object
|
|
319
|
+
*/
|
|
320
|
+
HDWallet.getHDKeypair = (rootSecret, chain, account = 0, index) => {
|
|
321
|
+
const bip44Chain = (0, constant_1.getBIP44Chain)(chain);
|
|
322
|
+
if (bip44Chain.length === 0) {
|
|
323
|
+
return null;
|
|
324
|
+
}
|
|
325
|
+
const chainIdx = (bip44Chain[0][0] << 1) >> 1;
|
|
326
|
+
const mnemonic = HDWallet.getMnemonicFromSecret(rootSecret);
|
|
327
|
+
const seed = BIP39.mnemonicToSeedSync(mnemonic);
|
|
328
|
+
const b32 = bip32_1.HDKey.fromMasterSeed(seed);
|
|
329
|
+
const privateKey = b32.derive(`m/44'/${chainIdx}'/${account}'/0/${index}`).privateKey;
|
|
330
|
+
return keypair.deriveKeyPair(Buffer.from(privateKey).toString("hex"));
|
|
331
|
+
};
|
|
332
|
+
/**
|
|
333
|
+
* generate hd wallet
|
|
334
|
+
*
|
|
335
|
+
* @static
|
|
336
|
+
* @param {any} opt options of generate, like:
|
|
337
|
+
* {
|
|
338
|
+
* len: 128/160/192/224/256, default is 128, determines number of mnemonic word
|
|
339
|
+
* language: english default/chinese_simplified/chinese_traditional/czech/korean/french/japanese/... see also:bip39 https://github.com/bitcoinjs/bip39/tree/master/ts_src/wordlists
|
|
340
|
+
* }
|
|
341
|
+
* @returns {object} return hd wallet object
|
|
342
|
+
*/
|
|
343
|
+
HDWallet.generate = (opt) => {
|
|
344
|
+
if (!opt) {
|
|
345
|
+
opt = {};
|
|
346
|
+
}
|
|
347
|
+
const mnemonic = HDWallet.generateMnemonic(opt.len, opt.language);
|
|
348
|
+
return new HDWallet({ mnemonic, language: opt.language });
|
|
349
|
+
};
|
|
350
|
+
/**
|
|
351
|
+
* create hd wallet from secret
|
|
352
|
+
*
|
|
353
|
+
* @static
|
|
354
|
+
* @param {string} secret secret string
|
|
355
|
+
* @returns {object} return hd wallet object
|
|
356
|
+
*/
|
|
357
|
+
HDWallet.fromSecret = (secret) => {
|
|
358
|
+
return new HDWallet({ secret });
|
|
359
|
+
};
|
|
360
|
+
/**
|
|
361
|
+
* create hd wallet from mnemonic
|
|
362
|
+
*
|
|
363
|
+
* @static
|
|
364
|
+
* @param {IMnemonic} mnemonic object like
|
|
365
|
+
* {mnemonic: "abc abc ...", language: "english"}
|
|
366
|
+
* @returns {object} return hd wallet object
|
|
367
|
+
*/
|
|
368
|
+
HDWallet.fromMnemonic = (mnemonic) => {
|
|
369
|
+
return new HDWallet({ mnemonic: mnemonic.mnemonic, language: mnemonic.language });
|
|
370
|
+
};
|
|
371
|
+
/**
|
|
372
|
+
* create hd wallet from keypair
|
|
373
|
+
*
|
|
374
|
+
* @static
|
|
375
|
+
* @param {IKeyPair} keypair object like
|
|
376
|
+
* {publicKey: "public key...", privateKey: "private key..."}
|
|
377
|
+
* @returns {object} return hd wallet object
|
|
378
|
+
*/
|
|
379
|
+
HDWallet.fromKeypair = (keypair) => {
|
|
380
|
+
return new HDWallet({ keypair });
|
|
381
|
+
};
|
|
394
382
|
//# sourceMappingURL=index.js.map
|
package/lib/hd/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hd/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hd/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gEAAiD;AACjD,6CAA+B;AAC/B,wCAAqC;AACrC,yCAAsE;AAM7D,2FANA,qBAAU,OAMA;AAAE,8FANA,wBAAa,OAMA;AAAE,8FANA,wBAAa,OAMA;AALjD,uCAA4C;AAC5C,oCAAgF;AAEhF,MAAM,OAAO,GAAG,IAAA,6BAAO,EAAC,gBAAQ,CAAC,OAAO,CAAC,CAAC;AAI1C,MAAa,QAAQ;IAOnB;;;;;;;;;;;;;;;;;OAiBG;IACH,YAAY,GAAQ;QA+KpB;;;;WAIG;QACI,WAAM,GAAG,GAAY,EAAE;YAC5B,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,KAAK,CAAC,CAAC;QAC5F,CAAC,CAAC;QAEF;;;;;;;;;;;WAWG;QACI,iBAAY,GAAG,CAAC,GAAQ,EAAY,EAAE;YAC3C,IAAI,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC/D,OAAO,IAAI,CAAC;YACd,CAAC;YAED,MAAM,SAAS,GAAG,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,OAAO,EA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EvB"}
|
package/lib/hd/plugins.d.ts
CHANGED
|
@@ -1,2 +1,11 @@
|
|
|
1
1
|
import { IHDPlugin } from "../types";
|
|
2
|
+
export declare const bvcadtWallet: IHDPlugin;
|
|
3
|
+
export declare const callWallet: IHDPlugin;
|
|
4
|
+
export declare const rippleWallet: IHDPlugin;
|
|
5
|
+
export declare const stmWallet: IHDPlugin;
|
|
6
|
+
export declare const bizainWallet: IHDPlugin;
|
|
7
|
+
export declare const jtWallet: IHDPlugin;
|
|
8
|
+
export declare const ethWallet: import("./ethereum.plugin").IEthereumPlugin;
|
|
9
|
+
export declare const moacWallet: import("./ethereum.plugin").IEthereumPlugin;
|
|
10
|
+
export declare const eosWallet: import("./eos.plugin").IEosPlugin;
|
|
2
11
|
export declare function getPluginByType<T extends IHDPlugin>(type: string): T;
|
package/lib/hd/plugins.js
CHANGED
|
@@ -1,35 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
3
|
+
exports.eosWallet = exports.moacWallet = exports.ethWallet = exports.jtWallet = exports.bizainWallet = exports.stmWallet = exports.rippleWallet = exports.callWallet = exports.bvcadtWallet = void 0;
|
|
4
|
+
exports.getPluginByType = getPluginByType;
|
|
5
|
+
const ethereum_plugin_1 = require("./ethereum.plugin");
|
|
6
|
+
const ethereum_plugin_2 = require("./ethereum.plugin");
|
|
7
|
+
const ethereum_plugin_3 = require("./ethereum.plugin");
|
|
8
|
+
const ethereum_plugin_4 = require("./ethereum.plugin");
|
|
9
|
+
const tron_plugin_1 = require("./tron.plugin");
|
|
10
|
+
const eos_plugin_1 = require("./eos.plugin");
|
|
11
|
+
const types_1 = require("../types");
|
|
12
|
+
const swtc_plugin_1 = require("./swtc.plugin");
|
|
13
|
+
exports.bvcadtWallet = (0, swtc_plugin_1.SWTCPlugin)(types_1.Alphabet.BVCADT);
|
|
14
|
+
exports.callWallet = (0, swtc_plugin_1.SWTCPlugin)(types_1.Alphabet.CALL);
|
|
15
|
+
exports.rippleWallet = (0, swtc_plugin_1.SWTCPlugin)(types_1.Alphabet.RIPPLE);
|
|
16
|
+
exports.stmWallet = (0, swtc_plugin_1.SWTCPlugin)(types_1.Alphabet.STREAM);
|
|
17
|
+
exports.bizainWallet = (0, swtc_plugin_1.SWTCPlugin)(types_1.Alphabet.BIZAIN);
|
|
18
|
+
exports.jtWallet = (0, swtc_plugin_1.SWTCPlugin)(types_1.Alphabet.JINGTUM);
|
|
19
|
+
exports.ethWallet = ethereum_plugin_1.plugin;
|
|
20
|
+
exports.moacWallet = ethereum_plugin_1.plugin;
|
|
21
|
+
exports.eosWallet = eos_plugin_1.plugin;
|
|
22
|
+
const pluginMap = {
|
|
18
23
|
ethereum: ethereum_plugin_1.plugin,
|
|
19
24
|
bsc: ethereum_plugin_2.plugin,
|
|
20
25
|
heco: ethereum_plugin_3.plugin,
|
|
21
26
|
polygon: ethereum_plugin_4.plugin,
|
|
22
27
|
tron: tron_plugin_1.plugin,
|
|
23
28
|
eos: eos_plugin_1.plugin,
|
|
24
|
-
bvcadt:
|
|
25
|
-
call:
|
|
26
|
-
ripple:
|
|
27
|
-
stream:
|
|
28
|
-
bizain:
|
|
29
|
-
jingtum:
|
|
29
|
+
bvcadt: exports.bvcadtWallet,
|
|
30
|
+
call: exports.callWallet,
|
|
31
|
+
ripple: exports.rippleWallet,
|
|
32
|
+
stream: exports.stmWallet,
|
|
33
|
+
bizain: exports.bizainWallet,
|
|
34
|
+
jingtum: exports.jtWallet
|
|
30
35
|
};
|
|
31
36
|
function getPluginByType(type) {
|
|
32
37
|
return pluginMap[type];
|
|
33
38
|
}
|
|
34
|
-
exports.getPluginByType = getPluginByType;
|
|
35
39
|
//# sourceMappingURL=plugins.js.map
|
package/lib/hd/plugins.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugins.js","sourceRoot":"","sources":["../../src/hd/plugins.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"plugins.js","sourceRoot":"","sources":["../../src/hd/plugins.ts"],"names":[],"mappings":";;;AAsCA,0CAEC;AAxCD,uDAA6D;AAC7D,uDAAwD;AACxD,uDAAyD;AACzD,uDAA4D;AAC5D,+CAAqD;AACrD,6CAAmD;AACnD,oCAA+C;AAC/C,+CAA2C;AAE9B,QAAA,YAAY,GAAG,IAAA,wBAAU,EAAC,gBAAQ,CAAC,MAAM,CAAC,CAAC;AAC3C,QAAA,UAAU,GAAG,IAAA,wBAAU,EAAC,gBAAQ,CAAC,IAAI,CAAC,CAAC;AACvC,QAAA,YAAY,GAAG,IAAA,wBAAU,EAAC,gBAAQ,CAAC,MAAM,CAAC,CAAC;AAC3C,QAAA,SAAS,GAAG,IAAA,wBAAU,EAAC,gBAAQ,CAAC,MAAM,CAAC,CAAC;AACxC,QAAA,YAAY,GAAG,IAAA,wBAAU,EAAC,gBAAQ,CAAC,MAAM,CAAC,CAAC;AAC3C,QAAA,QAAQ,GAAG,IAAA,wBAAU,EAAC,gBAAQ,CAAC,OAAO,CAAC,CAAC;AACxC,QAAA,SAAS,GAAG,wBAAc,CAAC;AAC3B,QAAA,UAAU,GAAG,wBAAc,CAAC;AAC5B,QAAA,SAAS,GAAG,mBAAS,CAAC;AAMnC,MAAM,SAAS,GAAe;IAC5B,QAAQ,EAAE,wBAAc;IACxB,GAAG,EAAE,wBAAS;IACd,IAAI,EAAE,wBAAU;IAChB,OAAO,EAAE,wBAAa;IACtB,IAAI,EAAE,oBAAU;IAChB,GAAG,EAAE,mBAAS;IACd,MAAM,EAAE,oBAAY;IACpB,IAAI,EAAE,kBAAU;IAChB,MAAM,EAAE,oBAAY;IACpB,MAAM,EAAE,iBAAS;IACjB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