增加eth-lib对本地account的支持
This commit is contained in:
parent
488d41e052
commit
a82495fc1d
18
patches/eth-lib+0.2.8.patch
Normal file
18
patches/eth-lib+0.2.8.patch
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
diff --git a/node_modules/eth-lib/lib/account.js b/node_modules/eth-lib/lib/account.js
|
||||||
|
index 5d5fc82..bc7b6cd 100644
|
||||||
|
--- a/node_modules/eth-lib/lib/account.js
|
||||||
|
+++ b/node_modules/eth-lib/lib/account.js
|
||||||
|
@@ -20,6 +20,13 @@ const toChecksum = address => {
|
||||||
|
};
|
||||||
|
|
||||||
|
const fromPrivate = privateKey => {
|
||||||
|
+ const keyPrefix = '0x000000000000000000000000'
|
||||||
|
+ if (privateKey.startsWith(keyPrefix)) {
|
||||||
|
+ return {
|
||||||
|
+ address: privateKey.replace(keyPrefix, '0x'),
|
||||||
|
+ privateKey: privateKey
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
const buffer = new Buffer(privateKey.slice(2), "hex");
|
||||||
|
const ecKey = secp256k1.keyFromPrivate(buffer);
|
||||||
|
const publicKey = "0x" + ecKey.getPublic(false, 'hex').slice(2);
|
Loading…
x
Reference in New Issue
Block a user