geth --unlock and how it's used. I've looked in depth at all of the documentation I can and came across this problem, or failure to understand some of it really. By the way, I'm using this on a Mac.

instance: Geth/v1.8.11-stable/darwin-amd64/go1.10.3

For example. ./geth account list returns the following.

The first one, #0 was created in 2016. The next two, this week.

Account #0: {c9b74488b8e699b54803464a33d57cfff7eb052c} keystore:///Users/robert/Library/Ethereum/keystore/UTC--2016-05-27T11-31-47.551960099Z--c9b74488b8e699b54803464a33d57cfff7eb052c
Account #1: {b8baff0dcc88b9bf7aed45966938a30e2ab23ce4} keystore:///Users/robert/Library/Ethereum/keystore/UTC--2018-06-18T13-40-57.053229334Z--b8baff0dcc88b9bf7aed45966938a30e2ab23ce4
Account #2: {bf7042c963111a96bd4c8d86c179576ddfc07cb8} keystore:///Users/robert/Library/Ethereum/keystore/UTC--2018-06-19T06-11-21.589039961Z--bf7042c963111a96bd4c8d86c179576ddfc07cb8

Now, only account #1 and #2 can be unlocked. It's one I created with geth, using ./geth account new

To unlock this account, I use this

geth --unlock  0xbf7042c963111a96bd4c8d86c179576ddfc07cb8 --datadir=/Users/robert/Library/Ethereum --password password.txt

That works, BUT. accounts #0 and #1 will not unlock - because I have no idea what or if they are even password protected. locked or unlocked? How can I tell?

So, the first address, address #0 is actually a Blockchain.info created address, and is actually Unlocked. I never locked it when created. If indeed I ever could lock it.

Unlock account 0xc9b74488b8e699b54803464a33d57cfff7eb052c
Error: could not decrypt key with given passphrase

The second address, #1, I don't know. I suspect I've accidentally created it. No idea if it's locked or unlocked. So, using ./geth attach I do this.

> personal.unlockAccount('0xb8baff0dcc88b9bf7aed45966938a30e2ab23ce4', null, 1)
Unlock account 0xb8baff0dcc88b9bf7aed45966938a30e2ab23ce4

And as you see, that works. Fortunately when I created that account, again it must have been with ./geth, I used my usual password.

So the question remains, how do I tell if an address is locked or unlocked? How do I add an address to that keystore other than by creating it with ./geth address new? Which didn't happen with the #0 address, because that's a Blockchain.info created address. How did it get into the keystore?

As I think address #0 is unlocked, the error 'could not decrypt key' is actually telling me that it's already unlocked. Interesting stuff.

  • send a transaction, if you get an error that the account is locked, then the account is locked – Nulik Jun 20 '18 at 17:37
  • all your accounts in keystore directory are encrypted with AES 128 bits. You have to know the password, otherwise you lost them. Ethereum doesn't save accounts in plain JSON text file, however, there is a functionality to do so in geth – Nulik Jun 20 '18 at 17:40
  • you have some misunderstandings, the term "locked" means the account wasn't decrypted and it is not ready to send a transaction. the term "unlocked" means you have provided the password, the account was decrypted now, and you can send transactions. If you "unlock" an account it will become locked again after 5 minutes (or so, I don't know the exact time) and you will have to unlock it again if you didn't use it. Locking is the mechanism that geth uses to prevent the user forgets his console with an unlocked account , to avoid security problems. See locking as Desktop screensaver. – Nulik Jun 20 '18 at 17:47
  • Thanks, yes now I understand. This works, because I did password protect that account number. geth --unlock 0xbf7042c963111a96bd4c8d86c179576ddfc07cb8 --datadir=/Users/robert/Library/Ethereum --password password.txt – Harry McGovern Jun 22 '18 at 12:57

Your Answer

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

Browse other questions tagged or ask your own question.