From dd0ffffec1ecd069b5727231cfe43e74f01072b2 Mon Sep 17 00:00:00 2001 From: BokkyPooBah Date: Tue, 16 Apr 2024 16:15:10 +1000 Subject: [PATCH] compressed public key --- docs/offline.html | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/docs/offline.html b/docs/offline.html index 65e3893..27df1a6 100644 --- a/docs/offline.html +++ b/docs/offline.html @@ -247,7 +247,7 @@ - + @@ -503,13 +503,13 @@
Troubleshooting
// --- DATA --- data: { wallet: { - type: 'mnemonics', // 'privatekey', 'keystorefile' + type: 'privatekey', // 'mnemonics', // 'privatekey', 'keystorefile' mnemonics: null, keystore: null, privateKey: null, publicKey: null, - // compressedPublicKey: null, // TODO: ethers.js returns a error + compressedPublicKey: null, address: null, }, @@ -954,15 +954,14 @@
Troubleshooting
async recomputeWallet() { console.log(moment().format("HH:mm:ss") + " recomputeWallet: " + JSON.stringify(this.wallet)); if (this.wallet.type == 'privatekey') { + console.log(moment().format("HH:mm:ss") + " recomputeWallet - privatekey: " + JSON.stringify(this.wallet)); try { const wallet = new ethers.Wallet(this.wallet.privateKey); this.wallet.address = wallet.address; this.wallet.publicKey = wallet.publicKey; - // TODO: ethers.js returns an error - // this.wallet.compressedPublicKey = wallet.compressedPublicKey || 'ethers.js returning an error'; - console.table(wallet); + this.wallet.compressedPublicKey = ethers.utils.computePublicKey(wallet.publicKey, true); } catch (e) { - console.log(moment().format("HH:mm:ss") + " recomputeWallet ERROR: " + e.message); + console.log(moment().format("HH:mm:ss") + " recomputeWallet - privatekey ERROR: " + e.message); } } else if (this.wallet.type == 'mnemonics') { console.log(moment().format("HH:mm:ss") + " recomputeWallet - mnemonics: " + JSON.stringify(this.wallet)); @@ -970,11 +969,9 @@
Troubleshooting
const wallet = new ethers.Wallet.fromMnemonic(this.wallet.mnemonics); this.wallet.address = wallet.address; this.wallet.publicKey = wallet.publicKey; - // TODO: ethers.js returns an error - // this.wallet.compressedPublicKey = wallet.compressedPublicKey || 'ethers.js returning an error'; - console.table(wallet); + this.wallet.compressedPublicKey = ethers.utils.computePublicKey(wallet.publicKey, true); } catch (e) { - console.log(moment().format("HH:mm:ss") + " recomputeWallet ERROR: " + e.message); + console.log(moment().format("HH:mm:ss") + " recomputeWallet - mnemonics ERROR: " + e.message); } } else if (this.wallet.type == 'keystorefile'){ console.log(moment().format("HH:mm:ss") + " recomputeWallet - keystorefile: " + JSON.stringify(this.wallet));