Here are the definitions of these two types:
// big.Int
type Int struct {
neg bool // sign
abs nat // absolute value of the integer
}
// hexutil.Big
type Big big.Int
This is my test code:
package main
import (
"fmt"
"math/big"
"reflect"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/rlp"
)
type TransactionData struct {
Value *hexutil.Big
Vaule2 *big.Int
}
func main() {
OneBig := (*hexutil.Big)(big.NewInt(1))
data := TransactionData{
Value: OneBig,
Vaule2: big.NewInt(2),
}
encodedData, err := rlp.EncodeToBytes(data)
if err != nil {
fmt.Println("Failed to encode data:", err)
return
}
decodedData := TransactionData{}
err = rlp.DecodeBytes(encodedData, &decodedData)
if err != nil {
fmt.Println("Failed to decode data:", err)
return
}
fmt.Println("equal:", reflect.DeepEqual(data, decodedData))
fmt.Printf("expected: %+v\n", data)
fmt.Printf("decoded: %+v\n", decodedData)
}
This is the output after executing the code:
equal: false
expected: {Value:0x1 Vaule2:+2}
decoded: {Value:0x0 Vaule2:+2}