aboutsummaryrefslogtreecommitdiffstats
path: root/core/types/gen_tx_json.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2017-02-24 00:58:15 +0800
committerFelix Lange <fjl@twurst.com>2017-03-07 19:45:12 +0800
commit8cf08e4b25c4cd0e0955598342394f34feecca0c (patch)
treedcd215bd6a31dcf78aebcb8132b0cb522890a8b9 /core/types/gen_tx_json.go
parenteee96a5bb7439ccee583d23e53be018fe7c35cfb (diff)
downloadgo-tangerine-8cf08e4b25c4cd0e0955598342394f34feecca0c.tar
go-tangerine-8cf08e4b25c4cd0e0955598342394f34feecca0c.tar.gz
go-tangerine-8cf08e4b25c4cd0e0955598342394f34feecca0c.tar.bz2
go-tangerine-8cf08e4b25c4cd0e0955598342394f34feecca0c.tar.lz
go-tangerine-8cf08e4b25c4cd0e0955598342394f34feecca0c.tar.xz
go-tangerine-8cf08e4b25c4cd0e0955598342394f34feecca0c.tar.zst
go-tangerine-8cf08e4b25c4cd0e0955598342394f34feecca0c.zip
core/types: use gencodec for JSON marshaling code
Diffstat (limited to 'core/types/gen_tx_json.go')
-rw-r--r--core/types/gen_tx_json.go99
1 files changed, 99 insertions, 0 deletions
diff --git a/core/types/gen_tx_json.go b/core/types/gen_tx_json.go
new file mode 100644
index 000000000..8bbe629d7
--- /dev/null
+++ b/core/types/gen_tx_json.go
@@ -0,0 +1,99 @@
+// generated by github.com/fjl/gencodec, do not edit.
+
+package types
+
+import (
+ "encoding/json"
+ "errors"
+ "math/big"
+
+ "github.com/ethereum/go-ethereum/common"
+ "github.com/ethereum/go-ethereum/common/hexutil"
+)
+
+func (t *txdata) MarshalJSON() ([]byte, error) {
+ type txdataJSON struct {
+ AccountNonce *hexutil.Uint64 `json:"nonce"`
+ Price *hexutil.Big `json:"gasPrice"`
+ GasLimit *hexutil.Big `json:"gasLimit"`
+ Recipient *common.Address `json:"to" optional:"yes" rlp:"nil"`
+ Amount *hexutil.Big `json:"value"`
+ Payload hexutil.Bytes `json:"input"`
+ V *hexutil.Big `json:"v"`
+ R *hexutil.Big `json:"r"`
+ S *hexutil.Big `json:"s"`
+ Hash *common.Hash `json:"hash" optional:"yes" rlp:"-"`
+ }
+ var enc txdataJSON
+ enc.AccountNonce = (*hexutil.Uint64)(&t.AccountNonce)
+ enc.Price = (*hexutil.Big)(t.Price)
+ enc.GasLimit = (*hexutil.Big)(t.GasLimit)
+ enc.Recipient = t.Recipient
+ enc.Amount = (*hexutil.Big)(t.Amount)
+ enc.Payload = t.Payload
+ enc.V = (*hexutil.Big)(t.V)
+ enc.R = (*hexutil.Big)(t.R)
+ enc.S = (*hexutil.Big)(t.S)
+ enc.Hash = t.Hash
+ return json.Marshal(&enc)
+}
+
+func (t *txdata) UnmarshalJSON(input []byte) error {
+ type txdataJSON struct {
+ AccountNonce *hexutil.Uint64 `json:"nonce"`
+ Price *hexutil.Big `json:"gasPrice"`
+ GasLimit *hexutil.Big `json:"gasLimit"`
+ Recipient *common.Address `json:"to" optional:"yes" rlp:"nil"`
+ Amount *hexutil.Big `json:"value"`
+ Payload hexutil.Bytes `json:"input"`
+ V *hexutil.Big `json:"v"`
+ R *hexutil.Big `json:"r"`
+ S *hexutil.Big `json:"s"`
+ Hash *common.Hash `json:"hash" optional:"yes" rlp:"-"`
+ }
+ var dec txdataJSON
+ if err := json.Unmarshal(input, &dec); err != nil {
+ return err
+ }
+ var x txdata
+ if dec.AccountNonce == nil {
+ return errors.New("missing required field 'nonce' for txdata")
+ }
+ x.AccountNonce = uint64(*dec.AccountNonce)
+ if dec.Price == nil {
+ return errors.New("missing required field 'gasPrice' for txdata")
+ }
+ x.Price = (*big.Int)(dec.Price)
+ if dec.GasLimit == nil {
+ return errors.New("missing required field 'gasLimit' for txdata")
+ }
+ x.GasLimit = (*big.Int)(dec.GasLimit)
+ if dec.Recipient != nil {
+ x.Recipient = dec.Recipient
+ }
+ if dec.Amount == nil {
+ return errors.New("missing required field 'value' for txdata")
+ }
+ x.Amount = (*big.Int)(dec.Amount)
+ if dec.Payload == nil {
+ return errors.New("missing required field 'input' for txdata")
+ }
+ x.Payload = dec.Payload
+ if dec.V == nil {
+ return errors.New("missing required field 'v' for txdata")
+ }
+ x.V = (*big.Int)(dec.V)
+ if dec.R == nil {
+ return errors.New("missing required field 'r' for txdata")
+ }
+ x.R = (*big.Int)(dec.R)
+ if dec.S == nil {
+ return errors.New("missing required field 's' for txdata")
+ }
+ x.S = (*big.Int)(dec.S)
+ if dec.Hash != nil {
+ x.Hash = dec.Hash
+ }
+ *t = x
+ return nil
+}