cmd/loop: fix channel parsing
@@ -89,16 +89,21 @@ func loopOut(ctx *cli.Context) error {
return err
}
- // Parse outgoing channel set.
- chanStrings := strings.Split(ctx.String("channel"), ",")
+ // Parse outgoing channel set. Don't string split if the flag is empty.
+ // Otherwise strings.Split returns a slice of length one with an empty
+ // element.
var outgoingChanSet []uint64
+ if ctx.IsSet("channel") {
+ chanStrings := strings.Split(ctx.String("channel"), ",")
for _, chanString := range chanStrings {
chanID, err := strconv.ParseUint(chanString, 10, 64)
if err != nil {
- return err
+ return fmt.Errorf("error parsing channel id "+
+ "\"%v\"", chanString)
}
outgoingChanSet = append(outgoingChanSet, chanID)
}
+ }
var destAddr string
switch {
