When I use personal.unlockAccount()
, there is an option to pass a parameter for duration. What is the maximum duration to which i can unlock the account? I have searched through its documentation. It only tells me that the duration is in seconds. And if i pass 0 as a duration parameter, the account unlocks permanently. But I want to know what is the maximum duration i can set.
According to the geth source, there is a max check for the time, which is calculated based of the MaxInt64 value, and ends up as 9223372036 seconds, or roughly 292 years.
// UnlockAccount will unlock the account associated with the given address with
// the given password for duration seconds. If duration is nil it will use a
// default of 300 seconds. It returns an indication if the account was unlocked.
func (s *PrivateAccountAPI) UnlockAccount(addr common.Address, password string, duration *uint64) (bool, error) {
const max = uint64(time.Duration(math.MaxInt64) / time.Second)
var d time.Duration
if duration == nil {
d = 300 * time.Second
} else if *duration > max {
return false, errors.New("unlock duration too large")
} else {
d = time.Duration(*duration) * time.Second
}
err := fetchKeystore(s.am).TimedUnlock(accounts.Account{Address: addr}, password, d)
return err == nil, err
}