From 22c5f0195066595f6486991984fc0a36e2acd336 Mon Sep 17 00:00:00 2001 From: Thomas Bocek Date: Thu, 2 Jun 2016 17:47:50 +0200 Subject: [PATCH] Negative numbers not properly converted in ABI encoding When converting a negative number e.g., -2, the resulting ABI encoding should look as follows: fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe However, since the check of the type is for an uint instead of an int, it results in the following ABI encoding: 0101010101010101010101010101010101010101010101010101010101010102 --- accounts/abi/numbers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/accounts/abi/numbers.go b/accounts/abi/numbers.go index 5a31cf2b5b..30ecd63cf8 100644 --- a/accounts/abi/numbers.go +++ b/accounts/abi/numbers.go @@ -96,7 +96,7 @@ func packNum(value reflect.Value, to byte) []byte { return S2S256(int64(value.Uint())) } case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - if to == UintTy { + if to == IntTy { return U2U256(uint64(value.Int())) } else { return S2S256(value.Int())