From a82495fc1d4a8369c10606dd051ca8fbc0ca0afc Mon Sep 17 00:00:00 2001 From: cebgcontract <99630598+cebgcontract@users.noreply.github.com> Date: Tue, 15 Nov 2022 10:22:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0eth-lib=E5=AF=B9=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0account=E7=9A=84=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- patches/eth-lib+0.2.8.patch | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 patches/eth-lib+0.2.8.patch diff --git a/patches/eth-lib+0.2.8.patch b/patches/eth-lib+0.2.8.patch new file mode 100644 index 0000000..c7e2246 --- /dev/null +++ b/patches/eth-lib+0.2.8.patch @@ -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);