accounts/abi: Index output for slices and arrays correctly

This commit is contained in:
Jakob Borg 2016-11-18 11:13:09 +01:00
parent f3228592f5
commit 1c0116ae6c

View file

@ -274,12 +274,19 @@ func (abi ABI) Unpack(v interface{}, name string, output []byte) error {
// struct will match named return values to the struct's field
// names
case reflect.Struct:
idx := 0
for i := 0; i < len(method.Outputs); i++ {
marshalledValue, err := toGoType(i, method.Outputs[i], output)
marshalledValue, err := toGoType(idx, method.Outputs[i], output)
if err != nil {
return err
}
reflectValue := reflect.ValueOf(marshalledValue)
switch reflectValue.Type().Kind() {
case reflect.Slice, reflect.Array:
idx += reflectValue.Len()
default:
idx++
}
for j := 0; j < typ.NumField(); j++ {
field := typ.Field(j)