jcc_wallet 1.3.1 → 3.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/package.json +32 -23
- package/dist/jcc-wallet.min.js +0 -78
- package/lib/constant/index.d.ts +0 -8
- package/lib/constant/index.js +0 -18
- package/lib/constant/index.js.map +0 -1
- package/lib/eth/index.d.ts +0 -36
- package/lib/eth/index.js +0 -98
- package/lib/eth/index.js.map +0 -1
- package/lib/hd/constant.d.ts +0 -25
- package/lib/hd/constant.js +0 -54
- package/lib/hd/constant.js.map +0 -1
- package/lib/hd/ethereum.plugin.d.ts +0 -4
- package/lib/hd/ethereum.plugin.js +0 -101
- package/lib/hd/ethereum.plugin.js.map +0 -1
- package/lib/hd/index.d.ts +0 -227
- package/lib/hd/index.js +0 -394
- package/lib/hd/index.js.map +0 -1
- package/lib/hd/plugins.d.ts +0 -1
- package/lib/hd/plugins.js +0 -31
- package/lib/hd/plugins.js.map +0 -1
- package/lib/hd/swtc.plugin.d.ts +0 -5
- package/lib/hd/swtc.plugin.js +0 -72
- package/lib/hd/swtc.plugin.js.map +0 -1
- package/lib/index.d.ts +0 -26
- package/lib/index.js +0 -62
- package/lib/index.js.map +0 -1
- package/lib/jingchangWallet/index.d.ts +0 -272
- package/lib/jingchangWallet/index.js +0 -758
- package/lib/jingchangWallet/index.js.map +0 -1
- package/lib/moac/index.d.ts +0 -28
- package/lib/moac/index.js +0 -58
- package/lib/moac/index.js.map +0 -1
- package/lib/types/index.d.ts +0 -90
- package/lib/types/index.js +0 -1
- package/lib/types/index.js.map +0 -1
- package/lib/util/index.d.ts +0 -21
- package/lib/util/index.js +0 -90
- package/lib/util/index.js.map +0 -1
- package/lib/x-wallet/index.d.ts +0 -21
- package/lib/x-wallet/index.js +0 -84
- package/lib/x-wallet/index.js.map +0 -1
package/lib/constant/index.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
declare const PASSWORD_IS_REQUIRED = "password is required";
|
|
2
|
-
declare const WALLET_IS_EMPTY = "wallet is empty";
|
|
3
|
-
declare const PASSWORD_IS_WRONG = "password is wrong";
|
|
4
|
-
declare const KEYSTORE_IS_INVALID = "keystore is invalid";
|
|
5
|
-
declare const ETH_PASSWORD_IS_WRONG = "ethereum password is wrong";
|
|
6
|
-
declare const SECRET_IS_INVALID = "secret is invalid";
|
|
7
|
-
declare const ADDRESS_IS_EXISTENT = "address is existent";
|
|
8
|
-
export { ADDRESS_IS_EXISTENT, ETH_PASSWORD_IS_WRONG, KEYSTORE_IS_INVALID, PASSWORD_IS_REQUIRED, PASSWORD_IS_WRONG, SECRET_IS_INVALID, WALLET_IS_EMPTY };
|
package/lib/constant/index.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WALLET_IS_EMPTY = exports.SECRET_IS_INVALID = exports.PASSWORD_IS_WRONG = exports.PASSWORD_IS_REQUIRED = exports.KEYSTORE_IS_INVALID = exports.ETH_PASSWORD_IS_WRONG = exports.ADDRESS_IS_EXISTENT = void 0;
|
|
4
|
-
var PASSWORD_IS_REQUIRED = "password is required";
|
|
5
|
-
exports.PASSWORD_IS_REQUIRED = PASSWORD_IS_REQUIRED;
|
|
6
|
-
var WALLET_IS_EMPTY = "wallet is empty";
|
|
7
|
-
exports.WALLET_IS_EMPTY = WALLET_IS_EMPTY;
|
|
8
|
-
var PASSWORD_IS_WRONG = "password is wrong";
|
|
9
|
-
exports.PASSWORD_IS_WRONG = PASSWORD_IS_WRONG;
|
|
10
|
-
var KEYSTORE_IS_INVALID = "keystore is invalid";
|
|
11
|
-
exports.KEYSTORE_IS_INVALID = KEYSTORE_IS_INVALID;
|
|
12
|
-
var ETH_PASSWORD_IS_WRONG = "ethereum ".concat(PASSWORD_IS_WRONG);
|
|
13
|
-
exports.ETH_PASSWORD_IS_WRONG = ETH_PASSWORD_IS_WRONG;
|
|
14
|
-
var SECRET_IS_INVALID = "secret is invalid";
|
|
15
|
-
exports.SECRET_IS_INVALID = SECRET_IS_INVALID;
|
|
16
|
-
var ADDRESS_IS_EXISTENT = "address is existent";
|
|
17
|
-
exports.ADDRESS_IS_EXISTENT = ADDRESS_IS_EXISTENT;
|
|
18
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/constant/index.ts"],"names":[],"mappings":";;;AAAA,IAAM,oBAAoB,GAAG,sBAAsB,CAAC;AAYlD,oDAAoB;AAXtB,IAAM,eAAe,GAAG,iBAAiB,CAAC;AAcxC,0CAAe;AAbjB,IAAM,iBAAiB,GAAG,mBAAmB,CAAC;AAW5C,8CAAiB;AAVnB,IAAM,mBAAmB,GAAG,qBAAqB,CAAC;AAQhD,kDAAmB;AAPrB,IAAM,qBAAqB,GAAG,mBAAY,iBAAiB,CAAE,CAAC;AAM5D,sDAAqB;AALvB,IAAM,iBAAiB,GAAG,mBAAmB,CAAC;AAS5C,8CAAiB;AARnB,IAAM,mBAAmB,GAAG,qBAAqB,CAAC;AAGhD,kDAAmB"}
|
package/lib/eth/index.d.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* check eth secret is valid or not
|
|
3
|
-
*
|
|
4
|
-
* @param {string} secret
|
|
5
|
-
* @returns {boolean} return true if valid
|
|
6
|
-
*/
|
|
7
|
-
declare const isValidSecret: (secret: string) => boolean;
|
|
8
|
-
/**
|
|
9
|
-
* check eth address is valid or not
|
|
10
|
-
*
|
|
11
|
-
* @param {string} address
|
|
12
|
-
* @returns {boolean} return true if valid
|
|
13
|
-
*/
|
|
14
|
-
declare const isValidAddress: (address: string) => boolean;
|
|
15
|
-
/**
|
|
16
|
-
* get eth address with secret
|
|
17
|
-
* @param {string} secret
|
|
18
|
-
* @returns {string | null} return address if valid, otherwise return null
|
|
19
|
-
*/
|
|
20
|
-
declare const getAddress: (secret: string) => string | null;
|
|
21
|
-
/**
|
|
22
|
-
* decrypt ethereum keystore file with ethereum password
|
|
23
|
-
*
|
|
24
|
-
* @param {string} password
|
|
25
|
-
* @param {*} encryptData
|
|
26
|
-
* @returns {string} return secret if success, otherwise throws `keystore is invalid` if the keystore is invalid or
|
|
27
|
-
* throws `ethereum password is wrong` if the password is wrong
|
|
28
|
-
*/
|
|
29
|
-
declare const decryptKeystore: (password: string, encryptData: any) => string;
|
|
30
|
-
/**
|
|
31
|
-
* create eth wallet
|
|
32
|
-
*
|
|
33
|
-
* @returns {IWalletModel}
|
|
34
|
-
*/
|
|
35
|
-
declare const createWallet: () => IWalletModel;
|
|
36
|
-
export { isValidSecret, isValidAddress, getAddress, decryptKeystore, createWallet };
|
package/lib/eth/index.js
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.createWallet = exports.decryptKeystore = exports.getAddress = exports.isValidAddress = exports.isValidSecret = void 0;
|
|
7
|
-
var crypto_1 = __importDefault(require("crypto"));
|
|
8
|
-
var util_1 = require("@ethereumjs/util");
|
|
9
|
-
var wallet_1 = require("@ethereumjs/wallet");
|
|
10
|
-
var jcc_common_1 = require("jcc_common");
|
|
11
|
-
var keccak_1 = __importDefault(require("keccak"));
|
|
12
|
-
var scryptsy_1 = __importDefault(require("scryptsy"));
|
|
13
|
-
var constant_1 = require("../constant");
|
|
14
|
-
var isObject = function (obj) {
|
|
15
|
-
return Object.prototype.toString.call(obj) === "[object Object]";
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* check eth secret is valid or not
|
|
19
|
-
*
|
|
20
|
-
* @param {string} secret
|
|
21
|
-
* @returns {boolean} return true if valid
|
|
22
|
-
*/
|
|
23
|
-
var isValidSecret = function (secret) {
|
|
24
|
-
secret = (0, jcc_common_1.filterOx)(secret);
|
|
25
|
-
try {
|
|
26
|
-
return (0, util_1.isValidPrivate)(Buffer.from(secret, "hex"));
|
|
27
|
-
}
|
|
28
|
-
catch (error) {
|
|
29
|
-
return false;
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
exports.isValidSecret = isValidSecret;
|
|
33
|
-
/**
|
|
34
|
-
* check eth address is valid or not
|
|
35
|
-
*
|
|
36
|
-
* @param {string} address
|
|
37
|
-
* @returns {boolean} return true if valid
|
|
38
|
-
*/
|
|
39
|
-
var isValidAddress = function (address) {
|
|
40
|
-
return (0, util_1.isValidAddress)(address);
|
|
41
|
-
};
|
|
42
|
-
exports.isValidAddress = isValidAddress;
|
|
43
|
-
/**
|
|
44
|
-
* get eth address with secret
|
|
45
|
-
* @param {string} secret
|
|
46
|
-
* @returns {string | null} return address if valid, otherwise return null
|
|
47
|
-
*/
|
|
48
|
-
var getAddress = function (secret) {
|
|
49
|
-
secret = (0, jcc_common_1.filterOx)(secret);
|
|
50
|
-
if (!isValidSecret(secret)) {
|
|
51
|
-
return null;
|
|
52
|
-
}
|
|
53
|
-
var wallet = wallet_1.Wallet.fromPrivateKey(Buffer.from(secret, "hex"));
|
|
54
|
-
return wallet.getAddressString();
|
|
55
|
-
};
|
|
56
|
-
exports.getAddress = getAddress;
|
|
57
|
-
/**
|
|
58
|
-
* decrypt ethereum keystore file with ethereum password
|
|
59
|
-
*
|
|
60
|
-
* @param {string} password
|
|
61
|
-
* @param {*} encryptData
|
|
62
|
-
* @returns {string} return secret if success, otherwise throws `keystore is invalid` if the keystore is invalid or
|
|
63
|
-
* throws `ethereum password is wrong` if the password is wrong
|
|
64
|
-
*/
|
|
65
|
-
var decryptKeystore = function (password, encryptData) {
|
|
66
|
-
if (!isObject(encryptData)) {
|
|
67
|
-
throw new Error(constant_1.KEYSTORE_IS_INVALID);
|
|
68
|
-
}
|
|
69
|
-
var cryptoData = encryptData.Crypto || encryptData.crypto;
|
|
70
|
-
if ((0, jcc_common_1.isEmptyObject)(cryptoData) || (0, jcc_common_1.isEmptyObject)(cryptoData.cipherparams) || (0, jcc_common_1.isEmptyObject)(cryptoData.kdfparams)) {
|
|
71
|
-
throw new Error(constant_1.KEYSTORE_IS_INVALID);
|
|
72
|
-
}
|
|
73
|
-
var iv = Buffer.from(cryptoData.cipherparams.iv, "hex");
|
|
74
|
-
var kdfparams = cryptoData.kdfparams;
|
|
75
|
-
var derivedKey = (0, scryptsy_1.default)(Buffer.from(password), Buffer.from(kdfparams.salt, "hex"), kdfparams.n, kdfparams.r, kdfparams.p, kdfparams.dklen);
|
|
76
|
-
var ciphertext = Buffer.from(cryptoData.ciphertext, "hex");
|
|
77
|
-
var mac = (0, keccak_1.default)("keccak256")
|
|
78
|
-
.update(Buffer.concat([derivedKey.slice(16, 32), ciphertext]))
|
|
79
|
-
.digest();
|
|
80
|
-
if (mac.toString("hex") !== cryptoData.mac) {
|
|
81
|
-
throw new Error(constant_1.ETH_PASSWORD_IS_WRONG);
|
|
82
|
-
}
|
|
83
|
-
var decipher = crypto_1.default.createDecipheriv("aes-128-ctr", derivedKey.slice(0, 16), iv);
|
|
84
|
-
var seed = Buffer.concat([decipher.update(ciphertext), decipher.final()]);
|
|
85
|
-
return seed.toString("hex");
|
|
86
|
-
};
|
|
87
|
-
exports.decryptKeystore = decryptKeystore;
|
|
88
|
-
/**
|
|
89
|
-
* create eth wallet
|
|
90
|
-
*
|
|
91
|
-
* @returns {IWalletModel}
|
|
92
|
-
*/
|
|
93
|
-
var createWallet = function () {
|
|
94
|
-
var _w = wallet_1.Wallet.generate();
|
|
95
|
-
return { address: _w.getAddressString(), secret: _w.getPrivateKeyString() };
|
|
96
|
-
};
|
|
97
|
-
exports.createWallet = createWallet;
|
|
98
|
-
//# sourceMappingURL=index.js.map
|
package/lib/eth/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":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EAAE,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;IACrF,IAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IAC5E,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC,CAAC;AAYkD,0CAAe;AAVnE;;;;GAIG;AACH,IAAM,YAAY,GAAG;IACnB,IAAM,EAAE,GAAG,eAAM,CAAC,QAAQ,EAAE,CAAC;IAC7B,OAAO,EAAE,OAAO,EAAE,EAAE,CAAC,gBAAgB,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC,mBAAmB,EAAE,EAAE,CAAC;AAC9E,CAAC,CAAC;AAEmE,oCAAY"}
|
package/lib/hd/constant.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
declare enum BIP44Chain {
|
|
2
|
-
BITCOIN = 2147483648,
|
|
3
|
-
BSC = 2147492654,
|
|
4
|
-
EOS = 2147483842,
|
|
5
|
-
ETC = 2147483709,
|
|
6
|
-
ETH = 2147483708,
|
|
7
|
-
HECO = 2147484658,
|
|
8
|
-
MOAC = 2147483962,
|
|
9
|
-
POLYGON = 2147484614,
|
|
10
|
-
RIPPLE = 2147483792,
|
|
11
|
-
SWTC = 2147483963,
|
|
12
|
-
CALL = 2147484281,
|
|
13
|
-
BVCADT = 2399141888,
|
|
14
|
-
STREAM = 2399141889,
|
|
15
|
-
BIZAIN = 2399141890
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* get bip44 chain constant
|
|
19
|
-
*
|
|
20
|
-
* @param {number} chain chain index number
|
|
21
|
-
* @returns {number} bip44 chain constant
|
|
22
|
-
*/
|
|
23
|
-
declare const getBIP44Chain: (chain: number) => any;
|
|
24
|
-
declare const BIP44ChainMap: Map<BIP44Chain, string>;
|
|
25
|
-
export { BIP44Chain, BIP44ChainMap, getBIP44Chain };
|
package/lib/hd/constant.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getBIP44Chain = exports.BIP44ChainMap = exports.BIP44Chain = void 0;
|
|
7
|
-
var bip44_constants_1 = __importDefault(require("bip44-constants"));
|
|
8
|
-
// BIP44 链常量定义
|
|
9
|
-
var BIP44Chain;
|
|
10
|
-
(function (BIP44Chain) {
|
|
11
|
-
BIP44Chain[BIP44Chain["BITCOIN"] = 2147483648] = "BITCOIN";
|
|
12
|
-
BIP44Chain[BIP44Chain["BSC"] = 2147492654] = "BSC";
|
|
13
|
-
BIP44Chain[BIP44Chain["EOS"] = 2147483842] = "EOS";
|
|
14
|
-
BIP44Chain[BIP44Chain["ETC"] = 2147483709] = "ETC";
|
|
15
|
-
BIP44Chain[BIP44Chain["ETH"] = 2147483708] = "ETH";
|
|
16
|
-
BIP44Chain[BIP44Chain["HECO"] = 2147484658] = "HECO";
|
|
17
|
-
BIP44Chain[BIP44Chain["MOAC"] = 2147483962] = "MOAC";
|
|
18
|
-
BIP44Chain[BIP44Chain["POLYGON"] = 2147484614] = "POLYGON";
|
|
19
|
-
BIP44Chain[BIP44Chain["RIPPLE"] = 2147483792] = "RIPPLE";
|
|
20
|
-
BIP44Chain[BIP44Chain["SWTC"] = 2147483963] = "SWTC";
|
|
21
|
-
BIP44Chain[BIP44Chain["CALL"] = 2147484281] = "CALL";
|
|
22
|
-
// not register in bip44, customize setting range: 0x8f000000-0x8fffffff
|
|
23
|
-
BIP44Chain[BIP44Chain["BVCADT"] = 2399141888] = "BVCADT";
|
|
24
|
-
BIP44Chain[BIP44Chain["STREAM"] = 2399141889] = "STREAM";
|
|
25
|
-
BIP44Chain[BIP44Chain["BIZAIN"] = 2399141890] = "BIZAIN";
|
|
26
|
-
})(BIP44Chain || (exports.BIP44Chain = BIP44Chain = {}));
|
|
27
|
-
/**
|
|
28
|
-
* get bip44 chain constant
|
|
29
|
-
*
|
|
30
|
-
* @param {number} chain chain index number
|
|
31
|
-
* @returns {number} bip44 chain constant
|
|
32
|
-
*/
|
|
33
|
-
var getBIP44Chain = function (chain) {
|
|
34
|
-
return bip44_constants_1.default.filter(function (e) { return e[0] === chain; });
|
|
35
|
-
};
|
|
36
|
-
exports.getBIP44Chain = getBIP44Chain;
|
|
37
|
-
var BIP44ChainMap = new Map([
|
|
38
|
-
[BIP44Chain.BITCOIN, "bitcoin"],
|
|
39
|
-
[BIP44Chain.BSC, "bsc"],
|
|
40
|
-
[BIP44Chain.EOS, "eos"],
|
|
41
|
-
[BIP44Chain.ETC, "etc"],
|
|
42
|
-
[BIP44Chain.ETH, "ethereum"],
|
|
43
|
-
[BIP44Chain.HECO, "heco"],
|
|
44
|
-
[BIP44Chain.MOAC, "moac"],
|
|
45
|
-
[BIP44Chain.POLYGON, "polygon"],
|
|
46
|
-
[BIP44Chain.RIPPLE, "ripple"],
|
|
47
|
-
[BIP44Chain.SWTC, "jingtum"],
|
|
48
|
-
[BIP44Chain.CALL, "call"],
|
|
49
|
-
[BIP44Chain.BVCADT, "bvcadt"],
|
|
50
|
-
[BIP44Chain.STREAM, "stream"],
|
|
51
|
-
[BIP44Chain.BIZAIN, "bizain"]
|
|
52
|
-
]);
|
|
53
|
-
exports.BIP44ChainMap = BIP44ChainMap;
|
|
54
|
-
//# sourceMappingURL=constant.js.map
|
package/lib/hd/constant.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constant.js","sourceRoot":"","sources":["../../src/hd/constant.ts"],"names":[],"mappings":";;;;;;AAAA,oEAAwC;AAExC,cAAc;AACd,IAAK,UAiBJ;AAjBD,WAAK,UAAU;IACb,0DAAoB,CAA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AAU,CAAC,MAAM,EAAE,QAAQ,CAAC;CAC9B,CAAC,CAAC;AAEkB,sCAAa"}
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.plugin = void 0;
|
|
27
|
-
var wallet_1 = require("@ethereumjs/wallet");
|
|
28
|
-
var ethUtil = __importStar(require("@ethereumjs/util"));
|
|
29
|
-
var keccak_js_1 = require("ethereum-cryptography/keccak.js");
|
|
30
|
-
var jcc_common_1 = require("jcc_common");
|
|
31
|
-
exports.plugin = {
|
|
32
|
-
checkPrivateKey: function (privateKey) {
|
|
33
|
-
// check and cut swtc keypair lib add prefix 00
|
|
34
|
-
return privateKey.length === 66 ? privateKey.substring(2) : privateKey;
|
|
35
|
-
},
|
|
36
|
-
address: function (key) {
|
|
37
|
-
if (key.privateKey) {
|
|
38
|
-
var privateKey = this.checkPrivateKey(key.privateKey);
|
|
39
|
-
var buffer = Buffer.from(privateKey, "hex");
|
|
40
|
-
var wallet = wallet_1.Wallet.fromPrivateKey(buffer);
|
|
41
|
-
// console.log("get public key:", wallet.getPublicKeyString());
|
|
42
|
-
return wallet.getAddressString();
|
|
43
|
-
}
|
|
44
|
-
if (key.publicKey) {
|
|
45
|
-
// TODO: length of ethereum publick key of keypaire is 128, but swtc lib keypair is 64
|
|
46
|
-
// so, if you want get address from public key, get it from private first
|
|
47
|
-
var wallet = wallet_1.Wallet.fromPublicKey(Buffer.from(key.publicKey, "hex"));
|
|
48
|
-
return wallet.getAddressString();
|
|
49
|
-
}
|
|
50
|
-
return null;
|
|
51
|
-
},
|
|
52
|
-
isValidAddress: function (address) {
|
|
53
|
-
return ethUtil.isValidAddress(address);
|
|
54
|
-
},
|
|
55
|
-
isValidSecret: function (secret) {
|
|
56
|
-
try {
|
|
57
|
-
return ethUtil.isValidPrivate(Buffer.from((0, jcc_common_1.filterOx)(secret), "hex"));
|
|
58
|
-
}
|
|
59
|
-
catch (error) {
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
hash: function (message) {
|
|
64
|
-
var hash = ethUtil.bytesToHex((0, keccak_js_1.keccak256)(Buffer.from(message, "utf-8")));
|
|
65
|
-
return ethUtil.stripHexPrefix(hash);
|
|
66
|
-
},
|
|
67
|
-
/**
|
|
68
|
-
*
|
|
69
|
-
* @param message message content, let message is "\x19Ethereum Signed Message:\n" + message.length + message, match web3.accounts.sign function
|
|
70
|
-
* @param privateKey private key
|
|
71
|
-
* @returns signature string
|
|
72
|
-
*/
|
|
73
|
-
sign: function (message, privateKey) {
|
|
74
|
-
var key = this.checkPrivateKey(privateKey).toLowerCase();
|
|
75
|
-
var hash = (0, keccak_js_1.keccak256)(Buffer.from(message, "utf-8"));
|
|
76
|
-
var signed = ethUtil.ecsign(hash, Buffer.from(key, "hex"));
|
|
77
|
-
return (ethUtil.stripHexPrefix(ethUtil.bytesToHex(signed.r)) +
|
|
78
|
-
ethUtil.stripHexPrefix(ethUtil.bytesToHex(signed.s)) +
|
|
79
|
-
signed.v.toString(16));
|
|
80
|
-
},
|
|
81
|
-
verify: function (message, signature, address) {
|
|
82
|
-
return this.recover(message, signature) === address;
|
|
83
|
-
},
|
|
84
|
-
recover: function (message, signature) {
|
|
85
|
-
var hash = (0, keccak_js_1.keccak256)(Buffer.from(message, "utf-8"));
|
|
86
|
-
var r = Buffer.from(Buffer.from(signature.substring(0, 64), "hex"));
|
|
87
|
-
var s = Buffer.from(Buffer.from(signature.substring(64, 128), "hex"));
|
|
88
|
-
var bytes = ethUtil.hexToBytes("0x" + signature.substring(128, 130));
|
|
89
|
-
var pk = ethUtil.ecrecover(hash, ethUtil.bytesToBigInt(bytes), r, s);
|
|
90
|
-
var wallet = wallet_1.Wallet.fromPublicKey(pk);
|
|
91
|
-
return wallet.getAddressString();
|
|
92
|
-
},
|
|
93
|
-
proxy: function (functionName) {
|
|
94
|
-
var args = [];
|
|
95
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
96
|
-
args[_i - 1] = arguments[_i];
|
|
97
|
-
}
|
|
98
|
-
return ethUtil[functionName].apply(ethUtil, args);
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
//# sourceMappingURL=ethereum.plugin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ethereum.plugin.js","sourceRoot":"","sources":["../../src/hd/ethereum.plugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA4C;AAC5C,wDAA4C;AAC5C,6DAA4D;AAC5D,yCAAsC;AAMzB,QAAA,MAAM,GAAoB;IACrC,eAAe,YAAC,UAAkB;QACh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E,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;QACxE,IAAM,KAAK,GAAG,OAAO,CAAC,UAAU,CAAC,IAAI,GAAG,SAAS,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;QACvE,IAAM,EAAE,GAAG,OAAO,CAAC,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QACvE,IAAM,MAAM,GAAG,eAAM,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;QACxC,OAAO,MAAM,CAAC,gBAAgB,EAAE,CAAC;IACnC,CAAC;IACD,KAAK,YAAC,YAAY;QAAE,cAAO;aAAP,UAAO,EAAP,qBAAO,EAAP,IAAO;YAAP,6BAAO;;QACzB,OAAO,OAAO,CAAC,YAAY,CAAC,OAArB,OAAO,EAAkB,IAAI,EAAE;IACxC,CAAC;CACF,CAAC"}
|
package/lib/hd/index.d.ts
DELETED
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
import { BIP44Chain, BIP44ChainMap, getBIP44Chain } from "./constant";
|
|
2
|
-
export { BIP44Chain, BIP44ChainMap, getBIP44Chain };
|
|
3
|
-
export declare class HDWallet {
|
|
4
|
-
private _secret;
|
|
5
|
-
private _mnemonic;
|
|
6
|
-
private _address;
|
|
7
|
-
private _keypair;
|
|
8
|
-
private _path;
|
|
9
|
-
/**
|
|
10
|
-
* generate mnemonic
|
|
11
|
-
*
|
|
12
|
-
* @static
|
|
13
|
-
* @param {number} len strength of random bytes, default 128
|
|
14
|
-
* @param {string} language localized word list, default is english. see also https://github.com/bitcoinjs/BIP39
|
|
15
|
-
* @returns {string} return mnemonic string, spilt by blank
|
|
16
|
-
*/
|
|
17
|
-
static generateMnemonic: (len?: number, language?: string) => string;
|
|
18
|
-
/**
|
|
19
|
-
* get secret from mnemonic, obey encode rule base58 for jingtum
|
|
20
|
-
*
|
|
21
|
-
* @static
|
|
22
|
-
* @param {string} mnemonic mnemonic words
|
|
23
|
-
* @param {string} language localized word list, default is english. see also https://github.com/bitcoinjs/BIP39
|
|
24
|
-
* @returns {string} return secret string
|
|
25
|
-
*/
|
|
26
|
-
static getSecretFromMnemonic: (mnemonic: string, language?: string) => string;
|
|
27
|
-
/**
|
|
28
|
-
* get mnemonic from secret, obey encode rule base58 for jingtum
|
|
29
|
-
*
|
|
30
|
-
* @static
|
|
31
|
-
* @param {string} secret secret string
|
|
32
|
-
* @param {string} language localized word list, default is english. see also https://github.com/bitcoinjs/BIP39
|
|
33
|
-
* @returns {string} return mnemonic word list
|
|
34
|
-
*/
|
|
35
|
-
static getMnemonicFromSecret: (secret: string, language?: string) => string;
|
|
36
|
-
/**
|
|
37
|
-
* get keypair from secret
|
|
38
|
-
*
|
|
39
|
-
* @static
|
|
40
|
-
* @param {string} secret secret string
|
|
41
|
-
* @returns {object} return keypair object
|
|
42
|
-
*/
|
|
43
|
-
static getKeypairFromSecret: (secret: string) => any;
|
|
44
|
-
/**
|
|
45
|
-
* get hd wallet key pair
|
|
46
|
-
*
|
|
47
|
-
* @static
|
|
48
|
-
* @param {string} rootSecret root secret
|
|
49
|
-
* @param {number} chain chain index number
|
|
50
|
-
* @param {number} account bip44 account index for purpose
|
|
51
|
-
* @param {number} index bip44 last level index
|
|
52
|
-
* @returns {IKeyPair} return keypair object
|
|
53
|
-
*/
|
|
54
|
-
static getHDKeypair: (rootSecret: string, chain: number, account: number, index: number) => IKeyPair;
|
|
55
|
-
/**
|
|
56
|
-
* generate hd wallet
|
|
57
|
-
*
|
|
58
|
-
* @static
|
|
59
|
-
* @param {any} opt options of generate, like:
|
|
60
|
-
* {
|
|
61
|
-
* len: 128/160/192/224/256, default is 128, determines number of mnemonic word
|
|
62
|
-
* language: english default/chinese_simplified/chinese_traditional/czech/korean/french/japanese/... see also:bip39 https://github.com/bitcoinjs/bip39/tree/master/ts_src/wordlists
|
|
63
|
-
* }
|
|
64
|
-
* @returns {object} return hd wallet object
|
|
65
|
-
*/
|
|
66
|
-
static generate: (opt: any) => HDWallet;
|
|
67
|
-
/**
|
|
68
|
-
* create hd wallet from secret
|
|
69
|
-
*
|
|
70
|
-
* @static
|
|
71
|
-
* @param {string} secret secret string
|
|
72
|
-
* @returns {object} return hd wallet object
|
|
73
|
-
*/
|
|
74
|
-
static fromSecret: (secret: string) => HDWallet;
|
|
75
|
-
/**
|
|
76
|
-
* create hd wallet from mnemonic
|
|
77
|
-
*
|
|
78
|
-
* @static
|
|
79
|
-
* @param {IMnemonic} mnemonic object like
|
|
80
|
-
* {mnemonic: "abc abc ...", language: "english"}
|
|
81
|
-
* @returns {object} return hd wallet object
|
|
82
|
-
*/
|
|
83
|
-
static fromMnemonic: (mnemonic: IMnemonic) => HDWallet;
|
|
84
|
-
/**
|
|
85
|
-
* create hd wallet from keypair
|
|
86
|
-
*
|
|
87
|
-
* @static
|
|
88
|
-
* @param {IKeyPair} keypair object like
|
|
89
|
-
* {publicKey: "public key...", privateKey: "private key..."}
|
|
90
|
-
* @returns {object} return hd wallet object
|
|
91
|
-
*/
|
|
92
|
-
static fromKeypair: (keypair: IKeyPair) => HDWallet;
|
|
93
|
-
/**
|
|
94
|
-
* generate hd wallet
|
|
95
|
-
*
|
|
96
|
-
* @param {any} opt options of generate, like:
|
|
97
|
-
* {
|
|
98
|
-
* mnemonic: "world list", // optional
|
|
99
|
-
* // see also:bip39 https://github.com/bitcoinjs/bip39/tree/master/ts_src/wordlists
|
|
100
|
-
* // language attribute appears with mnemonic attribute
|
|
101
|
-
* language: english default/chinese_simplified/...
|
|
102
|
-
* secret: "secret string", // optional, default this coding rules of SWTC chain
|
|
103
|
-
* keypair: {privateKey: "xxxx", publicKey: "xxxx"}
|
|
104
|
-
* }
|
|
105
|
-
* way of create hd wallet
|
|
106
|
-
* 1. {mnemonic: "xxx", language:"english"}
|
|
107
|
-
* 2. {secret: "xxxx"}
|
|
108
|
-
* 3. {keypair: {....}, path:{....}}
|
|
109
|
-
* @returns {object} return hd wallet object
|
|
110
|
-
*/
|
|
111
|
-
constructor(opt: any);
|
|
112
|
-
/**
|
|
113
|
-
* hd wallet is root or not
|
|
114
|
-
*
|
|
115
|
-
* @returns {boolean} return hd wallet root or not
|
|
116
|
-
*/
|
|
117
|
-
isRoot: () => boolean;
|
|
118
|
-
/**
|
|
119
|
-
* generate hd wallet by derive path, obey BIP44 protocol
|
|
120
|
-
*
|
|
121
|
-
* @param {any} opt options of derive, like:
|
|
122
|
-
* {
|
|
123
|
-
* chain: BIP44Chain.ETH, //chain code defined in bip44
|
|
124
|
-
* account: 0, // account for what purpose
|
|
125
|
-
* change: 0, // optional attrube,default always 0, for change account after transfer
|
|
126
|
-
* index: 0, // accout index
|
|
127
|
-
* }
|
|
128
|
-
* @returns {object} return hd wallet object
|
|
129
|
-
*/
|
|
130
|
-
deriveWallet: (opt: any) => HDWallet;
|
|
131
|
-
/**
|
|
132
|
-
* get wallet secret
|
|
133
|
-
*
|
|
134
|
-
* @returns {string} return wallet secret
|
|
135
|
-
*/
|
|
136
|
-
secret: () => string;
|
|
137
|
-
/**
|
|
138
|
-
* get wallet mnemonic
|
|
139
|
-
*
|
|
140
|
-
* @returns {IMnemonic} return IMnemonic object
|
|
141
|
-
*/
|
|
142
|
-
mnemonic: () => IMnemonic;
|
|
143
|
-
/**
|
|
144
|
-
* get chain of hd wallet
|
|
145
|
-
*
|
|
146
|
-
* @returns {string} return chain of hd wallet
|
|
147
|
-
*/
|
|
148
|
-
chain: () => string;
|
|
149
|
-
/**
|
|
150
|
-
* get address of hd wallet
|
|
151
|
-
*
|
|
152
|
-
* @returns {string} return address of hd wallet
|
|
153
|
-
*/
|
|
154
|
-
address: () => string;
|
|
155
|
-
/**
|
|
156
|
-
* check address valid or not
|
|
157
|
-
* @param {string} address
|
|
158
|
-
* @returns {boolean} true valid, false invalid
|
|
159
|
-
*/
|
|
160
|
-
isValidAddress: (address: string) => boolean;
|
|
161
|
-
/**
|
|
162
|
-
* check secret valid or not
|
|
163
|
-
*
|
|
164
|
-
* @param {string} secret
|
|
165
|
-
* @returns {boolean} true valid, false invalid
|
|
166
|
-
*/
|
|
167
|
-
isValidSecret: (address: string) => boolean;
|
|
168
|
-
/**
|
|
169
|
-
* hash message
|
|
170
|
-
*
|
|
171
|
-
* @param {string} message
|
|
172
|
-
* @returns {string} return hash of message
|
|
173
|
-
*/
|
|
174
|
-
hash: (message: string) => string;
|
|
175
|
-
/**
|
|
176
|
-
* sign message
|
|
177
|
-
* @notice how to operate message(raw or hashed) is different in native sdk of different chain
|
|
178
|
-
* to avoid confusion, we assume that native sdk will automatically hashed message
|
|
179
|
-
* if not the case of native sdk, we hash this message in lower level(plugin), for example ethereum sdk
|
|
180
|
-
* @param {string} message
|
|
181
|
-
* @returns {string} return signature string
|
|
182
|
-
*/
|
|
183
|
-
sign: (message: string) => string;
|
|
184
|
-
/**
|
|
185
|
-
* verify signature valid or not
|
|
186
|
-
*
|
|
187
|
-
* @param {string} message origin message
|
|
188
|
-
* @param {string} signature signature
|
|
189
|
-
* @param {string} address account which sign
|
|
190
|
-
* @param {IKeyPair} keypair keypair object, usually to provide public key, private key not required
|
|
191
|
-
*
|
|
192
|
-
* @returns {boolean} true valid, false invalid
|
|
193
|
-
*/
|
|
194
|
-
verify: (messgae: string, signature: string, address?: string, keypair?: IKeyPair) => boolean;
|
|
195
|
-
/**
|
|
196
|
-
* recover address/account from signature
|
|
197
|
-
*
|
|
198
|
-
* @param {string} message origin message
|
|
199
|
-
* @param {string} signature signature
|
|
200
|
-
*
|
|
201
|
-
* @returns {string} return address
|
|
202
|
-
*/
|
|
203
|
-
recover: (messgae: string, signature: string) => string;
|
|
204
|
-
/**
|
|
205
|
-
* get specified chain wallet api
|
|
206
|
-
*
|
|
207
|
-
* @returns {IHDPlugin} return hd plugin object
|
|
208
|
-
*/
|
|
209
|
-
getWalletApi: () => IHDPlugin;
|
|
210
|
-
/**
|
|
211
|
-
* get keypair of hd wallet
|
|
212
|
-
*
|
|
213
|
-
* @returns {IKeyPair} return keypair of message
|
|
214
|
-
*/
|
|
215
|
-
keypair: () => IKeyPair;
|
|
216
|
-
/**
|
|
217
|
-
* get path of hd wallet
|
|
218
|
-
*
|
|
219
|
-
* @returns {IBIP44Path} return path of wallet
|
|
220
|
-
*/
|
|
221
|
-
path: () => IBIP44Path;
|
|
222
|
-
/**
|
|
223
|
-
* set keypair
|
|
224
|
-
* @param {IKeyPair} keypair
|
|
225
|
-
*/
|
|
226
|
-
setKeypair: (keypair: IKeyPair) => void;
|
|
227
|
-
}
|