github.com/Aodurkeen/go-ubiq@v2.3.0+incompatible/core/types/gen_tx_json.go (about)

     1  // Code generated by github.com/fjl/gencodec. DO NOT EDIT.
     2  
     3  package types
     4  
     5  import (
     6  	"encoding/json"
     7  	"errors"
     8  	"math/big"
     9  
    10  	"github.com/ubiq/go-ubiq/common"
    11  	"github.com/ubiq/go-ubiq/common/hexutil"
    12  )
    13  
    14  var _ = (*txdataMarshaling)(nil)
    15  
    16  func (t txdata) MarshalJSON() ([]byte, error) {
    17  	type txdata struct {
    18  		AccountNonce hexutil.Uint64  `json:"nonce"    gencodec:"required"`
    19  		Price        *hexutil.Big    `json:"gasPrice" gencodec:"required"`
    20  		GasLimit     hexutil.Uint64  `json:"gas"      gencodec:"required"`
    21  		Recipient    *common.Address `json:"to"       rlp:"nil"`
    22  		Amount       *hexutil.Big    `json:"value"    gencodec:"required"`
    23  		Payload      hexutil.Bytes   `json:"input"    gencodec:"required"`
    24  		V            *hexutil.Big    `json:"v" gencodec:"required"`
    25  		R            *hexutil.Big    `json:"r" gencodec:"required"`
    26  		S            *hexutil.Big    `json:"s" gencodec:"required"`
    27  		Hash         *common.Hash    `json:"hash" rlp:"-"`
    28  	}
    29  	var enc txdata
    30  	enc.AccountNonce = hexutil.Uint64(t.AccountNonce)
    31  	enc.Price = (*hexutil.Big)(t.Price)
    32  	enc.GasLimit = hexutil.Uint64(t.GasLimit)
    33  	enc.Recipient = t.Recipient
    34  	enc.Amount = (*hexutil.Big)(t.Amount)
    35  	enc.Payload = t.Payload
    36  	enc.V = (*hexutil.Big)(t.V)
    37  	enc.R = (*hexutil.Big)(t.R)
    38  	enc.S = (*hexutil.Big)(t.S)
    39  	enc.Hash = t.Hash
    40  	return json.Marshal(&enc)
    41  }
    42  
    43  func (t *txdata) UnmarshalJSON(input []byte) error {
    44  	type txdata struct {
    45  		AccountNonce *hexutil.Uint64 `json:"nonce"    gencodec:"required"`
    46  		Price        *hexutil.Big    `json:"gasPrice" gencodec:"required"`
    47  		GasLimit     *hexutil.Uint64 `json:"gas"      gencodec:"required"`
    48  		Recipient    *common.Address `json:"to"       rlp:"nil"`
    49  		Amount       *hexutil.Big    `json:"value"    gencodec:"required"`
    50  		Payload      *hexutil.Bytes  `json:"input"    gencodec:"required"`
    51  		V            *hexutil.Big    `json:"v" gencodec:"required"`
    52  		R            *hexutil.Big    `json:"r" gencodec:"required"`
    53  		S            *hexutil.Big    `json:"s" gencodec:"required"`
    54  		Hash         *common.Hash    `json:"hash" rlp:"-"`
    55  	}
    56  	var dec txdata
    57  	if err := json.Unmarshal(input, &dec); err != nil {
    58  		return err
    59  	}
    60  	if dec.AccountNonce == nil {
    61  		return errors.New("missing required field 'nonce' for txdata")
    62  	}
    63  	t.AccountNonce = uint64(*dec.AccountNonce)
    64  	if dec.Price == nil {
    65  		return errors.New("missing required field 'gasPrice' for txdata")
    66  	}
    67  	t.Price = (*big.Int)(dec.Price)
    68  	if dec.GasLimit == nil {
    69  		return errors.New("missing required field 'gas' for txdata")
    70  	}
    71  	t.GasLimit = uint64(*dec.GasLimit)
    72  	if dec.Recipient != nil {
    73  		t.Recipient = dec.Recipient
    74  	}
    75  	if dec.Amount == nil {
    76  		return errors.New("missing required field 'value' for txdata")
    77  	}
    78  	t.Amount = (*big.Int)(dec.Amount)
    79  	if dec.Payload == nil {
    80  		return errors.New("missing required field 'input' for txdata")
    81  	}
    82  	t.Payload = *dec.Payload
    83  	if dec.V == nil {
    84  		return errors.New("missing required field 'v' for txdata")
    85  	}
    86  	t.V = (*big.Int)(dec.V)
    87  	if dec.R == nil {
    88  		return errors.New("missing required field 'r' for txdata")
    89  	}
    90  	t.R = (*big.Int)(dec.R)
    91  	if dec.S == nil {
    92  		return errors.New("missing required field 's' for txdata")
    93  	}
    94  	t.S = (*big.Int)(dec.S)
    95  	if dec.Hash != nil {
    96  		t.Hash = dec.Hash
    97  	}
    98  	return nil
    99  }