aboutsummaryrefslogtreecommitdiffstats
path: root/common/hexutil/hexutil.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2017-01-16 17:20:20 +0800
committerFelix Lange <fjl@twurst.com>2017-01-16 17:32:40 +0800
commit51f6b6d33f5b50e16f0b04bcccd03ad370f36636 (patch)
tree871c3a0915a6b75f73619e8626c61fafd701921b /common/hexutil/hexutil.go
parent01f6f2d741e717f669b7ba1d6b88991f28e30c72 (diff)
downloaddexon-51f6b6d33f5b50e16f0b04bcccd03ad370f36636.tar
dexon-51f6b6d33f5b50e16f0b04bcccd03ad370f36636.tar.gz
dexon-51f6b6d33f5b50e16f0b04bcccd03ad370f36636.tar.bz2
dexon-51f6b6d33f5b50e16f0b04bcccd03ad370f36636.tar.lz
dexon-51f6b6d33f5b50e16f0b04bcccd03ad370f36636.tar.xz
dexon-51f6b6d33f5b50e16f0b04bcccd03ad370f36636.tar.zst
dexon-51f6b6d33f5b50e16f0b04bcccd03ad370f36636.zip
common/hexutil: fix EncodeBig, Big.MarshalJSON
The code was too clever and failed to include zeros on a big.Word boundary.
Diffstat (limited to 'common/hexutil/hexutil.go')
-rw-r--r--common/hexutil/hexutil.go7
1 files changed, 1 insertions, 6 deletions
diff --git a/common/hexutil/hexutil.go b/common/hexutil/hexutil.go
index 29e6de333..4ec0ee8e6 100644
--- a/common/hexutil/hexutil.go
+++ b/common/hexutil/hexutil.go
@@ -169,12 +169,7 @@ func EncodeBig(bigint *big.Int) string {
if nbits == 0 {
return "0x0"
}
- enc := make([]byte, 2, (nbits/8)*2+2)
- copy(enc, "0x")
- for i := len(bigint.Bits()) - 1; i >= 0; i-- {
- enc = strconv.AppendUint(enc, uint64(bigint.Bits()[i]), 16)
- }
- return string(enc)
+ return fmt.Sprintf("0x%x", bigint)
}
func has0xPrefix(input string) bool {