18 lines
359 B
Go
18 lines
359 B
Go
|
package common
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"math/big"
|
||
|
"strconv"
|
||
|
"strings"
|
||
|
)
|
||
|
|
||
|
func StringAsBigInt(data []byte) (*big.Int, error) {
|
||
|
dataString := strings.TrimSpace(string(data))
|
||
|
parseInt, err := strconv.ParseInt(dataString, 16, 64)
|
||
|
if err != nil {
|
||
|
return nil, fmt.Errorf("could not parse %s as big int: %v", dataString, err)
|
||
|
}
|
||
|
return big.NewInt(parseInt), nil
|
||
|
}
|