aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/api/personal.go
diff options
context:
space:
mode:
Diffstat (limited to 'rpc/api/personal.go')
-rw-r--r--rpc/api/personal.go17
1 files changed, 15 insertions, 2 deletions
diff --git a/rpc/api/personal.go b/rpc/api/personal.go
index 1fb412612..4f347c610 100644
--- a/rpc/api/personal.go
+++ b/rpc/api/personal.go
@@ -98,9 +98,22 @@ func (self *personalApi) NewAccount(req *shared.Request) (interface{}, error) {
if err := self.codec.Decode(req.Params, &args); err != nil {
return nil, shared.NewDecodeParamError(err.Error())
}
-
+ var passwd string
+ if args.Passphrase == nil {
+ fe := self.xeth.Frontend()
+ if fe == nil {
+ return false, fmt.Errorf("unable to create account: unable to interact with user")
+ }
+ var ok bool
+ passwd, ok = fe.AskPassword()
+ if !ok {
+ return false, fmt.Errorf("unable to create account: no password given")
+ }
+ } else {
+ passwd = *args.Passphrase
+ }
am := self.ethereum.AccountManager()
- acc, err := am.NewAccount(args.Passphrase)
+ acc, err := am.NewAccount(passwd)
return acc.Address.Hex(), err
}