jcc_wallet 4.0.6 → 4.0.8
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 -24
- package/lib/hd/eos.plugin.d.ts +2 -1
- package/lib/hd/eos.plugin.js +20 -0
- package/lib/hd/ethereum.plugin.d.ts +2 -1
- package/lib/hd/ethereum.plugin.js +16 -0
- package/lib/hd/swtc.plugin.js +10 -1
- package/lib/hd/tron.plugin.d.ts +2 -1
- package/lib/hd/tron.plugin.js +19 -0
- package/lib/types.d.ts +1 -0
- package/package.json +1 -1
package/lib/hd/eos.plugin.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { IHDPlugin } from "../types";
|
|
1
|
+
import { IHDPlugin, IKeyPair } from "../types";
|
|
2
2
|
export interface IEosPlugin extends IHDPlugin {
|
|
3
3
|
checkPrivateKey(privateKey: string): string;
|
|
4
4
|
privateKeyToLegacyString(privateKey: string): string;
|
|
5
|
+
getKeyPairFromPrivateKey(privateKey: string): IKeyPair | null;
|
|
5
6
|
}
|
|
6
7
|
export declare const plugin: IEosPlugin;
|
package/lib/hd/eos.plugin.js
CHANGED
|
@@ -77,5 +77,25 @@ exports.plugin = {
|
|
|
77
77
|
recover(message, signature) {
|
|
78
78
|
const s = Signature_1.Signature.fromString(signature);
|
|
79
79
|
return s.recover(message).toLegacyString();
|
|
80
|
+
},
|
|
81
|
+
getKeyPairFromPrivateKey(privateKey) {
|
|
82
|
+
try {
|
|
83
|
+
const key = exports.plugin.checkPrivateKey(privateKey);
|
|
84
|
+
if (!exports.plugin.isValidSecret(key)) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
const eosPrivateKey = exports.plugin.privateKeyToLegacyString(key);
|
|
88
|
+
const pk = PrivateKey_1.PrivateKey.fromString(eosPrivateKey);
|
|
89
|
+
const pubKey = pk.getPublicKey();
|
|
90
|
+
const point = pubKey.toPoint();
|
|
91
|
+
const publicKey = point.toHex(true);
|
|
92
|
+
return {
|
|
93
|
+
privateKey: key,
|
|
94
|
+
publicKey
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
catch (_a) {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
80
100
|
}
|
|
81
101
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { IHDPlugin } from "../types";
|
|
1
|
+
import { IKeyPair, IHDPlugin } from "../types";
|
|
2
2
|
export interface IEthereumPlugin extends IHDPlugin {
|
|
3
3
|
checkPrivateKey(privateKey: string): string;
|
|
4
4
|
decryptKeystore(password: string, encryptData: any): Promise<string>;
|
|
5
|
+
getKeyPairFromPrivateKey(privateKey: string): IKeyPair | null;
|
|
5
6
|
}
|
|
6
7
|
export declare const plugin: IEthereumPlugin;
|
|
@@ -111,5 +111,21 @@ exports.plugin = {
|
|
|
111
111
|
const priv = (0, utils_js_1.randomBytes)(32);
|
|
112
112
|
const address = exports.plugin.getAddress((0, bytes_1.bytesToHex)(priv));
|
|
113
113
|
return { address, secret: (0, bytes_1.bytesToHex)(priv) };
|
|
114
|
+
},
|
|
115
|
+
getKeyPairFromPrivateKey(privateKey) {
|
|
116
|
+
try {
|
|
117
|
+
const key = exports.plugin.checkPrivateKey(privateKey);
|
|
118
|
+
if (!exports.plugin.isValidSecret(key)) {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
const publicKey = secp256k1_js_1.secp256k1.ProjectivePoint.fromPrivateKey(Buffer.from((0, internal_1.stripHexPrefix)(key), "hex")).toHex(true);
|
|
122
|
+
return {
|
|
123
|
+
privateKey: key,
|
|
124
|
+
publicKey: publicKey.substring(2)
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
catch (_a) {
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
114
130
|
}
|
|
115
131
|
};
|
package/lib/hd/swtc.plugin.js
CHANGED
|
@@ -70,6 +70,14 @@ const SWTCPlugin = (alphabet) => {
|
|
|
70
70
|
return null;
|
|
71
71
|
}
|
|
72
72
|
};
|
|
73
|
+
const getKeyPairFromPrivateKey = (privateKey) => {
|
|
74
|
+
try {
|
|
75
|
+
return Wallet.deriveKeyPair(privateKey);
|
|
76
|
+
}
|
|
77
|
+
catch (_a) {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
};
|
|
73
81
|
return {
|
|
74
82
|
isValidAddress,
|
|
75
83
|
isValidSecret,
|
|
@@ -79,7 +87,8 @@ const SWTCPlugin = (alphabet) => {
|
|
|
79
87
|
createWallet,
|
|
80
88
|
getAddress,
|
|
81
89
|
recover,
|
|
82
|
-
address
|
|
90
|
+
address,
|
|
91
|
+
getKeyPairFromPrivateKey
|
|
83
92
|
};
|
|
84
93
|
};
|
|
85
94
|
exports.SWTCPlugin = SWTCPlugin;
|
package/lib/hd/tron.plugin.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { IHDPlugin } from "../types";
|
|
1
|
+
import { IHDPlugin, IKeyPair } from "../types";
|
|
2
2
|
export interface ITronPlugin extends IHDPlugin {
|
|
3
3
|
checkPrivateKey(privateKey: string): string;
|
|
4
|
+
getKeyPairFromPrivateKey(privateKey: string): IKeyPair | null;
|
|
4
5
|
}
|
|
5
6
|
export declare const plugin: ITronPlugin;
|
package/lib/hd/tron.plugin.js
CHANGED
|
@@ -57,5 +57,24 @@ exports.plugin = {
|
|
|
57
57
|
},
|
|
58
58
|
recover(message, signature) {
|
|
59
59
|
return (0, message_1.verifyMessage)(message, signature);
|
|
60
|
+
},
|
|
61
|
+
getKeyPairFromPrivateKey(privateKey) {
|
|
62
|
+
try {
|
|
63
|
+
const key = exports.plugin.checkPrivateKey(privateKey);
|
|
64
|
+
if (!exports.plugin.isValidSecret(key)) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
const pubBytes = (0, crypto_1.getPubKeyFromPriKey)((0, code_1.hexStr2byteArray)(key));
|
|
68
|
+
const publicKey = Array.from(pubBytes)
|
|
69
|
+
.map((b) => b.toString(16).padStart(2, "0"))
|
|
70
|
+
.join("");
|
|
71
|
+
return {
|
|
72
|
+
privateKey: key,
|
|
73
|
+
publicKey
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
catch (_a) {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
60
79
|
}
|
|
61
80
|
};
|
package/lib/types.d.ts
CHANGED
|
@@ -89,6 +89,7 @@ export interface IHDPlugin {
|
|
|
89
89
|
getAddress?(secret: string): string;
|
|
90
90
|
createWallet?(opts?: ICreateOptionsModel): IWalletModel;
|
|
91
91
|
proxy?(functionName: string, ...args: any[]): any;
|
|
92
|
+
getKeyPairFromPrivateKey?(privateKey: string): IKeyPair | null;
|
|
92
93
|
}
|
|
93
94
|
export declare enum Alphabet {
|
|
94
95
|
JINGTUM = "jpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65rkm8oFqi1tuvAxyz",
|