Reply with errors when parameters are not a []interface{}.

This commit is contained in:
Josh Rickmar 2013-10-04 18:34:53 -04:00
parent 911e9fa5ae
commit e081508c9d

View file

@ -332,14 +332,15 @@ func GetNewAddress(reply chan []byte, msg *btcjson.Message) {
// not sent to the payment address or a fee for the miner are sent // not sent to the payment address or a fee for the miner are sent
// back to a new address in the wallet. // back to a new address in the wallet.
func SendFrom(reply chan []byte, msg *btcjson.Message) { func SendFrom(reply chan []byte, msg *btcjson.Message) {
e := InvalidParams
params, ok := msg.Params.([]interface{}) params, ok := msg.Params.([]interface{})
if !ok { if !ok {
log.Error("SendFrom: Cannot parse parameters.") e.Message = "Cannot parse parameters."
ReplyError(reply, msg.Id, &e)
return return
} }
var fromaccount, toaddr58, comment, commentto string var fromaccount, toaddr58, comment, commentto string
var famt, minconf float64 var famt, minconf float64
e := InvalidParams
if len(params) < 3 { if len(params) < 3 {
e.Message = "Too few parameters." e.Message = "Too few parameters."
ReplyError(reply, msg.Id, &e) ReplyError(reply, msg.Id, &e)
@ -449,15 +450,16 @@ func SendFrom(reply chan []byte, msg *btcjson.Message) {
// inputs not sent to the payment address or a fee for the miner are // inputs not sent to the payment address or a fee for the miner are
// sent back to a new address in the wallet. // sent back to a new address in the wallet.
func SendMany(reply chan []byte, msg *btcjson.Message) { func SendMany(reply chan []byte, msg *btcjson.Message) {
e := InvalidParams
params, ok := msg.Params.([]interface{}) params, ok := msg.Params.([]interface{})
if !ok { if !ok {
log.Error("SendFrom: Cannot parse parameters.") e.Message = "Cannot parse parameters."
ReplyError(reply, msg.Id, &e)
return return
} }
var fromaccount, comment string var fromaccount, comment string
var minconf float64 var minconf float64
var jsonPairs map[string]interface{} var jsonPairs map[string]interface{}
e := InvalidParams
if len(params) < 2 { if len(params) < 2 {
e.Message = "Too few parameters." e.Message = "Too few parameters."
ReplyError(reply, msg.Id, &e) ReplyError(reply, msg.Id, &e)