4

When trying to send a transaction through json-rpc interface on a geth node (version 1.4.10-stable-5f55d95a, running on testnet) using eth_sendTransaction I got this error message:

-32000 [message] => account is locked

I have tried to unlock the account using the following command:

geth --testnet --exec "personal.unlockAccount(eth.accounts[0], password, 3600)" attach true http://localhost:8545

But I get another error:

Fatal: Unable to attach to remote geth: invalid endpoint

Trying to unlock as explained in how to unlock the account with geth?

geth --testnet --unlock 0x3b877e80b... --password password

throws this error too:

Fatal: Could not open database: resource temporarily unavailable

Another option to unlock account according to previous URL is using the Geth interactive Javascript console. But how do I launch such console?

I've seen someone is having same problem on code -32000 message: account is locked but any command of the kind

geth --unlock

is not working on my geth node.

Is it possible to unlock accounts directly through json-rpc interface anyhow?

Why geth is not allowing me to unlock my ethereum account? Why "invalid endpoint"?

2

1 Answer 1

5
  1. The command with attach should be like:
$ geth --testnet --exec "personal.unlockAccount(eth.accounts[0], \"password\", 3600)" attach http://localhost:8545

Make sure that you have included personal in your --rpcapi "eth,web3,personal" in the first Geth you launched.

  1. The command with unlock should be used as part of the first Geth launch:

    • Have a password.txt file that contains as many lines as there are accounts to unlock. Each line with password without the ".
    • Then add --unlock "0x3b877e80b..." --password password.txt to your Geth command line.
  2. Beside that, to launch Geth with a console, just add console at the end. So, when you are in the Geth console, you can type:

> personal.unlockAccount(eth.accounts[0])
// Or
> personal.unlockAccount(eth.accounts[0], "password")
// Or
> personal.unlockAccount(eth.accounts[0], "password", 3600)

Edit:

At your own risk, because the call carries the password in clear, the direct call to unlock via RPC is:

$ curl -X POST --data '{"jsonrpc":"2.0","method":"personal_unlockAccount","params":["0x7642b...", "password", 3600],"id":67}' http://localhost:8545
{"jsonrpc":"2.0","id":67,"result":true}
7
  • 1
    Given that exporting personal over rpc opens up a node to exploits shouldn't they be attaching through ipc instead, e.g. geth --testnet --exec "personal.unlockAccount(eth.accounts[0], \"password\", 3600)" attach ~/<datadir>/geth.ipc?
    – o0ragman0o
    Commented Sep 2, 2016 at 21:51
  • I agree 100%. I just asked if both Geth are on the same computer. Commented Sep 2, 2016 at 22:05
  • Thanks a lot. Using command line call to geth as you described worked like a charm. Nevertheless, I wonder if this unlock action could be also possible through json-rpc protocol, avoinding admin intervention on command line. Commented Sep 3, 2016 at 16:53
  • 1
    I added it in the answer, but be careful, the password is travelling in the clear. Commented Sep 3, 2016 at 20:40
  • is there way for unlock account using private key not using password @XavierLeprêtreB9lab Commented Nov 4, 2017 at 13:45

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