aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/api/personal.go
diff options
context:
space:
mode:
authorBas van Kervel <bas@ethdev.com>2015-08-07 15:56:49 +0800
committerBas van Kervel <bas@ethdev.com>2015-08-12 18:22:16 +0800
commitf9cbd16f27e393d4937354ee31435e0a2f689484 (patch)
tree0b9668443084923b2b264cd0fb1b1b8c604cf1d6 /rpc/api/personal.go
parent2fcf7f1241648dc2c0ed90a122c5945f25b3ce1a (diff)
downloadgo-tangerine-f9cbd16f27e393d4937354ee31435e0a2f689484.tar
go-tangerine-f9cbd16f27e393d4937354ee31435e0a2f689484.tar.gz
go-tangerine-f9cbd16f27e393d4937354ee31435e0a2f689484.tar.bz2
go-tangerine-f9cbd16f27e393d4937354ee31435e0a2f689484.tar.lz
go-tangerine-f9cbd16f27e393d4937354ee31435e0a2f689484.tar.xz
go-tangerine-f9cbd16f27e393d4937354ee31435e0a2f689484.tar.zst
go-tangerine-f9cbd16f27e393d4937354ee31435e0a2f689484.zip
support for user agents
Diffstat (limited to 'rpc/api/personal.go')
-rw-r--r--rpc/api/personal.go22
1 files changed, 11 insertions, 11 deletions
diff --git a/rpc/api/personal.go b/rpc/api/personal.go
index e9942c1e5..6c73ac83d 100644
--- a/rpc/api/personal.go
+++ b/rpc/api/personal.go
@@ -17,6 +17,7 @@
package api
import (
+ "fmt"
"time"
"github.com/ethereum/go-ethereum/common"
@@ -125,18 +126,17 @@ func (self *personalApi) UnlockAccount(req *shared.Request) (interface{}, error)
return nil, shared.NewDecodeParamError(err.Error())
}
- var err error
+ if len(args.Passphrase) == 0 {
+ fe := self.xeth.Frontend()
+ if fe == nil {
+ return false, fmt.Errorf("No password provided")
+ }
+ return fe.UnlockAccount(common.HexToAddress(args.Address).Bytes()), nil
+ }
+
am := self.ethereum.AccountManager()
addr := common.HexToAddress(args.Address)
- if args.Duration == -1 {
- err = am.Unlock(addr, args.Passphrase)
- } else {
- err = am.TimedUnlock(addr, args.Passphrase, time.Duration(args.Duration)*time.Second)
- }
-
- if err == nil {
- return true, nil
- }
- return false, err
+ err := am.TimedUnlock(addr, args.Passphrase, time.Duration(args.Duration)*time.Second)
+ return err == nil, err
}