jcwallet/patches/eth-lib+0.2.8.patch
2022-11-15 10:22:56 +08:00

19 lines
675 B
Diff

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);