@@ -164,14 +164,15 @@ func (am *Manager) Lock(addr common.Address) error {
164
164
return nil
165
165
}
166
166
167
- // TimedUnlock unlocks the given account with. The account
167
+ // TimedUnlock unlocks the given account with the passphrase . The account
168
168
// stays unlocked for the duration of timeout. A timeout of 0 unlocks the account
169
- // until the program exits. The account must match a unique key.
169
+ // until the program exits. The account must match a unique key file .
170
170
//
171
- // If the accout is already unlocked, TimedUnlock extends or shortens
172
- // the active unlock timeout.
173
- func (am * Manager ) TimedUnlock (a Account , keyAuth string , timeout time.Duration ) error {
174
- _ , key , err := am .getDecryptedKey (a , keyAuth )
171
+ // If the account address is already unlocked for a duration, TimedUnlock extends or
172
+ // shortens the active unlock timeout. If the address was previously unlocked
173
+ // indefinitely the timeout is not altered.
174
+ func (am * Manager ) TimedUnlock (a Account , passphrase string , timeout time.Duration ) error {
175
+ a , key , err := am .getDecryptedKey (a , passphrase )
175
176
if err != nil {
176
177
return err
177
178
}
@@ -180,8 +181,13 @@ func (am *Manager) TimedUnlock(a Account, keyAuth string, timeout time.Duration)
180
181
defer am .mu .Unlock ()
181
182
u , found := am .unlocked [a .Address ]
182
183
if found {
183
- // terminate dropLater for this key to avoid unexpected drops.
184
- if u .abort != nil {
184
+ if u .abort == nil {
185
+ // The address was unlocked indefinitely, so unlocking
186
+ // it with a timeout would be confusing.
187
+ zeroKey (key .PrivateKey )
188
+ return nil
189
+ } else {
190
+ // Terminate the expire goroutine and replace it below.
185
191
close (u .abort )
186
192
}
187
193
}
0 commit comments