diff --git a/core/types/gen_return_data.go b/core/types/gen_return_data.go new file mode 100644 index 0000000000..541328c6d8 --- /dev/null +++ b/core/types/gen_return_data.go @@ -0,0 +1,52 @@ +// Code generated by github.com/fjl/gencodec. DO NOT EDIT. + +package types + +import ( + "encoding/json" + "errors" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" +) + +var _ = (*returnDataMarshaling)(nil) + +// MarshalJSON marshals as JSON. +func (r ReturnData) MarshalJSON() ([]byte, error) { + type ReturnData struct { + TxHash common.Hash `json:"transactionHash" gencodec:"required"` + Data hexutil.Bytes `json:"returndata" gencodec:"required"` + Removed bool `json:"removed"` + } + var enc ReturnData + enc.TxHash = r.TxHash + enc.Data = r.Data + enc.Removed = r.Removed + return json.Marshal(&enc) +} + +// UnmarshalJSON unmarshals from JSON. +func (r *ReturnData) UnmarshalJSON(input []byte) error { + type ReturnData struct { + TxHash *common.Hash `json:"transactionHash" gencodec:"required"` + Data *hexutil.Bytes `json:"returndata" gencodec:"required"` + Removed *bool `json:"removed"` + } + var dec ReturnData + if err := json.Unmarshal(input, &dec); err != nil { + return err + } + if dec.TxHash == nil { + return errors.New("missing required field 'transactionHash' for ReturnData") + } + r.TxHash = *dec.TxHash + if dec.Data == nil { + return errors.New("missing required field 'returndata' for ReturnData") + } + r.Data = *dec.Data + if dec.Removed != nil { + r.Removed = *dec.Removed + } + return nil +} diff --git a/core/types/transaction.go b/core/types/transaction.go index 9fd8899319..ace9104141 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -30,6 +30,7 @@ import ( ) //go:generate gencodec -type txdata -field-override txdataMarshaling -out gen_tx_json.go +//go:generate gencodec -type ReturnData -field-override returnDataMarshaling -out gen_return_data.go var ( ErrInvalidSig = errors.New("invalid transaction v, r, s values") @@ -92,6 +93,10 @@ type ReturnData struct { Removed bool `json:"removed"` } +type returnDataMarshaling struct { + Data hexutil.Bytes +} + func NewTransaction(nonce uint64, to common.Address, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte) *Transaction { return newTransaction(nonce, &to, amount, gasLimit, gasPrice, data) }