question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Wallet.isEncryptedWallet

See original GitHub issue

Hi, excuse me that i am asking here, however i cannot fix the issue for days. I try to make unlock wallet with keystore file, however devtool warn me

Uncaught TypeError: Wallet.isEncryptedWallet is not a function at UnlockWalletKeystore (ana.js:349) at HTMLButtonElement.onclick (index.html:200)

how can i fix this? probably my code is old and i should migrate to new version but i dont know how to do it. Excuse me again

function UnlockWalletKeystore() {
    var password = $("#keystorewalletpass").val();
    var buffer = fs.readFileSync(keyFile);
    var walletData = buffer.toString();
    $("#keystorebtn").html("Decrypting...");
    $("#keystorebtn").prop("disabled", true);

    if (password!='' && keyFile!='' && Wallet.isEncryptedWallet(walletData)){

        Wallet.fromEncryptedWallet(walletData, password).then(function(wallet) {
                console.log("Opened Address: " + wallet.address);
                wallet.provider = new ethers.providers.getDefaultProvider(false);
                myWallet = wallet;
                SuccessAccess();
                updateBalance();
                // UpdatePortfolio();
                $("#keystorebtn").html("Decrypting...");
        });
      } else {
        $("#keystorejsonerror").html('<i class="fas fa-exclamation-circle"></i> Invalid Keystore JSON File or Password')
        $("#keystorejsonerror").show();
        $("#keystorebtn").prop("disabled", false);
        $("#keystorebtn").html("Open");
      }
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:24 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
ricmoocommented, Jan 10, 2021

You are changing the contract address after you have already instantiated the Contract. Strings are immutable and passed by value, not by reference. So changing the string after passing it into somewhere else will have no effect.

You would need to make the Contract object re-assignable. This may lead to issues in other places though. I highly Recommend architecting the application to support changing networks, which would mean you have a function that setups up the world for a given network, on change: 1) tear down the old world and 2) rebuild the new one.

Otherwise you will always have lingering un-garbage-collects nuggets within your app resolving and possibly updating the UI after switching networks.

This is why I warn people of the absolute pain it is to support changing networks and to only do so if they absolutely need to. It is not simple… 😒

Does that help at all, though? 😃

1reaction
zemsecommented, Dec 16, 2020

@PlusBitPos Your myWallet doesn’t have a provider object attached to it, so after signing the transaction it doesn’t know which eth node backend it should send it to. So you need to connect it.

const provider = ethers.getDefaultProvider(); // for ethereum mainnet
myWallet = myWallet.connect(provider); // note that you are reasigning the myWallet js variable

You can also refer docs for wallet and providers.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Wallet encryption - Bitcoin Wiki
Wallet encryption uses AES-256-CBC to encrypt only the private keys that are held in a wallet. The keys are encrypted with a master...
Read more >
Securing your wallet - Bitcoin.org
Encrypting your wallet or your smartphone allows you to set a password for anyone trying to withdraw any funds. This helps protect against...
Read more >
What Is a Crypto Wallet and How to Keep Your Wallet Secure?
Software wallets are very secure when you enable their two-factor authentication login settings; however, since they connect to the internet, ...
Read more >
What Is Crypto Wallet, Encryption And Private-Public Keys
As I explained in the previous article, Crypto Wallet is a piece of software which can hold account like your physical wallet hold...
Read more >
14 Cryptocurrency Wallets to Store Your Crypto Securely
Let's look at some of the best crypto currency wallets. ... It's a cryptocurrency wallet that stores users' private keys in a secure...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found