From 5d8993b8c01668589713e30d4431f404339cacf4 Mon Sep 17 00:00:00 2001 From: johnliu-dexon <42129254+johnliu-dexon@users.noreply.github.com> Date: Thu, 17 Jan 2019 16:37:15 +0800 Subject: common: fix big scan from bytes (#157) We store string of number, not bytes value into database 10 is stored as 0x3130, not 0x0a Use UnmarshalText instead of SetBytes --- common/big.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'common/big.go') diff --git a/common/big.go b/common/big.go index ea3d4aba6..96a83661e 100644 --- a/common/big.go +++ b/common/big.go @@ -45,7 +45,11 @@ func (b *Big) Scan(src interface{}) error { case uint64: *b = Big(*newB.SetUint64(t)) case []byte: - *b = Big(*newB.SetBytes(t)) + err := newB.UnmarshalText(t) + if err != nil { + return err + } + *b = Big(*newB) case string: v, ok := newB.SetString(t, 10) if !ok { -- cgit v1.2.3