aboutsummaryrefslogtreecommitdiffstats
path: root/internal/ethapi/api.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@users.noreply.github.com>2017-01-11 20:20:24 +0800
committerGitHub <noreply@github.com>2017-01-11 20:20:24 +0800
commit8820d97039cffa66411062df4b23ff74d659a220 (patch)
tree4db53d913f898a44c0d88cf67a176f57dae49f90 /internal/ethapi/api.go
parentb52fde7cf7ce50725830a9d7ddb61e0e8094c7cd (diff)
downloadgo-tangerine-8820d97039cffa66411062df4b23ff74d659a220.tar
go-tangerine-8820d97039cffa66411062df4b23ff74d659a220.tar.gz
go-tangerine-8820d97039cffa66411062df4b23ff74d659a220.tar.bz2
go-tangerine-8820d97039cffa66411062df4b23ff74d659a220.tar.lz
go-tangerine-8820d97039cffa66411062df4b23ff74d659a220.tar.xz
go-tangerine-8820d97039cffa66411062df4b23ff74d659a220.tar.zst
go-tangerine-8820d97039cffa66411062df4b23ff74d659a220.zip
internal/ethapi: fix duration parameter of personal_unlockAccount (#3542)
Diffstat (limited to 'internal/ethapi/api.go')
-rw-r--r--internal/ethapi/api.go13
1 files changed, 8 insertions, 5 deletions
diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go
index 7ea216029..4359181c8 100644
--- a/internal/ethapi/api.go
+++ b/internal/ethapi/api.go
@@ -19,7 +19,9 @@ package ethapi
import (
"bytes"
"encoding/hex"
+ "errors"
"fmt"
+ "math"
"math/big"
"strings"
"time"
@@ -237,17 +239,18 @@ func (s *PrivateAccountAPI) ImportRawKey(privkey string, password string) (commo
// 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 *hexutil.Uint) (bool, error) {
+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
}
- if err := s.am.TimedUnlock(accounts.Account{Address: addr}, password, d); err != nil {
- return false, err
- }
- return true, nil
+ err := s.am.TimedUnlock(accounts.Account{Address: addr}, password, d)
+ return err == nil, err
}
// LockAccount will lock the account associated with the given address when it's unlocked.