Parity-ethereum: RPC/Personal: Unlock with time fails

Created on 1 Feb 2017  ·  5Comments  ·  Source: openethereum/parity-ethereum

I am running a node with RPC enabled (for dev).
I am connecting using:
geth attach http://myip:myport

Issuing personal.unlock(myAddress, "mySuperPassword", null)
does work. However, personal.unlock(myAddress, "mySuperPassword", 300) fails.

Z8-wontfix 🙅‍♀️

Most helpful comment

Unlock is expecting quantity, so you need to hex-encode the input (most probably web3 should do that for you). Also note that unlocking for specific time is unsafe and requires --geth flag to work (otherwise the account is unlocked only for one request).

All 5 comments

Unlock is expecting quantity, so you need to hex-encode the input (most probably web3 should do that for you). Also note that unlocking for specific time is unsafe and requires --geth flag to work (otherwise the account is unlocked only for one request).

Hello @tomusdrw, thanks for your answer. By quantity you mean "of time"?
This is why I passed 300 for 5 minutes. The very insecure nature of unlock is clear to me. I am on a test env on a private chain.

I also tried using the --geth flag, it does not change anything.

I am not sure I understand your comment about hex encoding. The duration should be a null or a number such as 300. Neither "300", "0x123", 0x123 are valid for the duration.

So the question remains (despite that it is insecure), how do I unlock (this is for dev...) for 300s ?

By QUANTITY I mean a general rule for encoding numbers for RPC calls, described here:
https://github.com/ethcore/parity/wiki/JSONRPC#types-in-the-jsonrpc

All RPCs are expecting hex-encoded data, so is unlockAccount. web3 should be doing the conversion for you most of the time (for instance when you do web3.eth.sendTransaction({from: a, to: b, value: 10}) it will automatically encode value as 0xa when RPC request), if it's not the case for unlockAccount I would argue web3 should do this.

ok, clear.
Nevertheless, beside null, integers are the only accepted values and all throw an error.
I can unlock accounts when running on geth, but the same command fails on parity.

Could you tell me if such command works for you when running a parity node (--geth or not, your pick) and using geth to attach to the node:
personal.unlock(myAddress, "mySuperPassword", 300)

screen shot 2017-02-01 at 18 23 42

 $ curl --data '{"method":"personal_unlockAccount","params":["0x8f0227d45853a50eefd48dd4fec25d5b3fd2295e","hunter2","0x100"],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST localhost:8545
{"jsonrpc":"2.0","result":false,"id":1}

This RPC request works correctly, as mentioned it might be an issue in web3 not converting integer to QUANTITY (and not accepting hex-encoded number "0x100")

Was this page helpful?
0 / 5 - 0 ratings