Send error replies for walletpassphrase

This commit is contained in:
Josh Rickmar 2013-08-21 12:07:57 -04:00
parent af4df4a3d5
commit 1aa324684d

View file

@ -138,8 +138,6 @@ var (
}{ }{
m: make(map[uint64]chan []byte), m: make(map[uint64]chan []byte),
} }
incorrectParameters = errors.New("Incorrect parameters.")
) )
// ProcessFrontendMsg checks the message sent from a frontend. If the // ProcessFrontendMsg checks the message sent from a frontend. If the
@ -262,25 +260,23 @@ func WalletPassphrase(reply chan []byte, msg []byte) {
json.Unmarshal(msg, &v) json.Unmarshal(msg, &v)
params := v["params"].([]interface{}) params := v["params"].([]interface{})
if len(params) != 2 { if len(params) != 2 {
log.Error(incorrectParameters) ReplyError(reply, v["id"], &InvalidParams)
return return
} }
passphrase, ok := params[0].(string) passphrase, ok1 := params[0].(string)
if !ok { timeout, ok2 := params[1].(float64)
log.Error(incorrectParameters) if !ok1 || !ok2 {
return ReplyError(reply, v["id"], &InvalidParams)
}
timeout, ok := params[1].(float64)
if !ok {
log.Error(incorrectParameters)
return return
} }
if w := wallets[""]; w != nil { if w := wallets[""]; w != nil {
w.Unlock([]byte(passphrase)) if err := w.Unlock([]byte(passphrase)); err != nil {
ReplyError(reply, v["id"], &WalletPassphraseIncorrect)
return
}
go func() { go func() {
time.Sleep(time.Second * time.Duration(int64(timeout))) time.Sleep(time.Second * time.Duration(int64(timeout)))
fmt.Println("finally locking")
w.Lock() w.Lock()
}() }()
} }