From b15e03acd7d6184ad920292a10d9a2bbf2b59f00 Mon Sep 17 00:00:00 2001 From: obscuren Date: Fri, 30 May 2014 16:57:40 +0200 Subject: Fixed issue with casting to smaller byte array --- ethutil/big.go | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'ethutil') diff --git a/ethutil/big.go b/ethutil/big.go index 891d476ad..1c25a4784 100644 --- a/ethutil/big.go +++ b/ethutil/big.go @@ -49,6 +49,10 @@ func BigD(data []byte) *big.Int { func BigToBytes(num *big.Int, base int) []byte { ret := make([]byte, base/8) + if len(num.Bytes()) > base/8 { + return num.Bytes() + } + return append(ret[:len(ret)-len(num.Bytes())], num.Bytes()...) } -- cgit