From 1c0116ae6caefde112e40348f61cc12f992cd671 Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Fri, 18 Nov 2016 11:13:09 +0100 Subject: [PATCH] accounts/abi: Index output for slices and arrays correctly --- accounts/abi/abi.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/accounts/abi/abi.go b/accounts/abi/abi.go index 2efac1307d..8d2532b063 100644 --- a/accounts/abi/abi.go +++ b/accounts/abi/abi.go @@ -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)