3

I know the purpose of personal.unlockAccount() function is to unlock account i.e. when I want to send ETH or tokens.

After reading the documentation, I'm still not sure what is actually happening under the hood when we unlock our account.

  1. Does it mean someone else with my public key can move my ETH/token when I unlock my account?

  2. Does it mean someone else can deploy a contract using my account when I unlock my account?

  3. Can I unlock an account in node A and deploy a contract from machine B via node A RPC without having to download/copy down my private key from node A into machine B?

Really appreciate all the assistance and pointers.

2

what is happening when you unlockAccount() is that the account JSON file in keystore directory is decrypted and its private key (64byte long) is stored in memory for some time. During this time, all the transactions you send are signed with this private key.

1) No. To sign transactions you need the private key.

2) Deploying a contract is done by sending a transaction, so - yes. If you unlock the account and have eth module exposed over RPC then anyone can send transaction using your account. If you have personal module exposed over RPC then anyone can list all accounts registered on your node, so discovering which account may be in an unlocked status is much easier.

3) You don't need to unlock account on node A, you need to unlock account on the node B, because without private key you can't sign the transaction. If A's node has RPC enabled, it usually means the node is giving free service to community so anyone can use it, like MyEtherWalett for example.

  • Thank you. Sorry about not being clear. The private is in node A. Because I created the account in node A (running Geth). Machine B here is my development machine which has no private key and not running Geth. Can you revise your answer? Appreciate it. – Zulhilmi Zainudin Sep 10 '18 at 20:09
1

None of those things.

It doesn't reveal the signing key to anyone and it doesn't mean anyone can do anything without the signing key. It means the node won't just return an error immediately when someone/something askes it to sign a transaction.

The node has no knowledge of the signing key except password-encrypted key files. Unlocking supplies the password to make it possible for the node to sign a transaction.

On the command line, when developing on a private network, a favorite one-liner

web3.personal.unlockAccount(web3.personal.listAccounts[0],"<password>", 15000);

Where 15,000 means unlock it for 15,000 seconds (so I can work without needing to unlock every time).

It's not safe in a production setting with real ETH because it's like Safety set of OFF.

Hope it helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.