Correctly parse account name for getnewaddress

This commit is contained in:
Josh Rickmar 2013-10-08 19:25:33 -04:00
parent 9cc6600db2
commit 8163227225

View file

@ -310,16 +310,20 @@ func GetBalance(reply chan []byte, msg *btcjson.Message) {
// the requested wallet does not exist, a JSON error will be returned to // the requested wallet does not exist, a JSON error will be returned to
// the client. // the client.
func GetNewAddress(reply chan []byte, msg *btcjson.Message) { func GetNewAddress(reply chan []byte, msg *btcjson.Message) {
e := InvalidParams
params, ok := msg.Params.([]interface{}) params, ok := msg.Params.([]interface{})
if !ok { if !ok {
log.Error("GetNewAddress: Cannot parse parameters.") ReplyError(reply, msg.Id, &e)
return return
} }
var wname string var wname string
if len(params) == 0 || params[0].(string) == "" { if len(params) > 0 {
wname = "" var ok bool
} else { if wname, ok = params[0].(string); !ok {
wname = "params[0].(string)" e.Message = "account is not a string"
ReplyError(reply, msg.Id, &e)
return
}
} }
wallets.RLock() wallets.RLock()