Skip to content

Commit 2d1ced8

Browse files
committed
Merge pull request bnb-chain#1739 from bas-vk/empty-password
rpc/api allow empty password
2 parents 6ec13e7 + 39e9560 commit 2d1ced8

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

‎rpc/api/personal.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func (self *personalApi) UnlockAccount(req *shared.Request) (interface{}, error)
110110
return nil, shared.NewDecodeParamError(err.Error())
111111
}
112112

113-
if len(args.Passphrase) == 0 {
113+
if args.Passphrase == nil {
114114
fe := self.xeth.Frontend()
115115
if fe == nil {
116116
return false, fmt.Errorf("No password provided")
@@ -121,6 +121,6 @@ func (self *personalApi) UnlockAccount(req *shared.Request) (interface{}, error)
121121
am := self.ethereum.AccountManager()
122122
addr := common.HexToAddress(args.Address)
123123

124-
err := am.TimedUnlock(addr, args.Passphrase, time.Duration(args.Duration)*time.Second)
124+
err := am.TimedUnlock(addr, *args.Passphrase, time.Duration(args.Duration)*time.Second)
125125
return err == nil, err
126126
}

‎rpc/api/personal_args.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func (args *NewAccountArgs) UnmarshalJSON(b []byte) (err error) {
4646

4747
type UnlockAccountArgs struct {
4848
Address string
49-
Passphrase string
49+
Passphrase *string
5050
Duration int
5151
}
5252

@@ -70,7 +70,7 @@ func (args *UnlockAccountArgs) UnmarshalJSON(b []byte) (err error) {
7070

7171
if len(obj) >= 2 && obj[1] != nil {
7272
if passphrasestr, ok := obj[1].(string); ok {
73-
args.Passphrase = passphrasestr
73+
args.Passphrase = &passphrasestr
7474
} else {
7575
return shared.NewInvalidTypeError("passphrase", "not a string")
7676
}

0 commit comments

Comments
 (0)