This question is related to this one and this one. It also has a partial answer here and here.
In the third link the account is being unlocked for a period of time using web3.js:
web3.personal.unlockAccount("0x..", "<passs>", 1000);
The unlock period parameter is optional.
How is it possible to check if accounts are locked (prior to making transactions)?
Are there any functionality consequences of unlocking an already unlocked account?
Best Answer
There currently isn't a method for checking whether an account is locked or not in the web3 JS API.
However, from the code, if an account is already unlocked, then there's no problem calling unlock again.
Why are we only looking at
TimedUnlock()
, which presumably only gets invoked if we pass the third parameter?As you noted, the unlock period parameter is optional. If it isn't provided, then we call
Unlock()
, which is a wrapper aroundTimedUnlock()
, but which passes0
as the time period. Hence we only need consider theTimedUnlock()
function in the explanation.