|
|
@ -16,13 +16,14 @@ var _ = (*txdataMarshaling)(nil) |
|
|
|
// MarshalJSON marshals as JSON.
|
|
|
|
// MarshalJSON marshals as JSON.
|
|
|
|
func (t txdata) MarshalJSON() ([]byte, error) { |
|
|
|
func (t txdata) MarshalJSON() ([]byte, error) { |
|
|
|
type txdata struct { |
|
|
|
type txdata struct { |
|
|
|
AccountNonce hexutil.Uint64 `json:"nonce" gencodec:"required"` |
|
|
|
AccountNonce hexutil.Uint64 `json:"nonce" gencodec:"required"` |
|
|
|
ShardID uint32 `json:"shardID" gencodec:"required"` |
|
|
|
Price *hexutil.Big `json:"gasPrice" gencodec:"required"` |
|
|
|
Price *hexutil.Big `json:"gasPrice" gencodec:"required"` |
|
|
|
GasLimit hexutil.Uint64 `json:"gas" gencodec:"required"` |
|
|
|
GasLimit hexutil.Uint64 `json:"gas" gencodec:"required"` |
|
|
|
ShardID uint32 `json:"shardID" gencodec:"required"` |
|
|
|
Recipient *common.Address `json:"to" rlp:"nil"` |
|
|
|
ToShardID uint32 `json:"toShardID"` |
|
|
|
Amount *hexutil.Big `json:"value" gencodec:"required"` |
|
|
|
Recipient *common.Address `json:"to" rlp:"nil"` |
|
|
|
Payload hexutil.Bytes `json:"input" gencodec:"required"` |
|
|
|
Amount *hexutil.Big `json:"value" gencodec:"required"` |
|
|
|
|
|
|
|
Payload hexutil.Bytes `json:"input" gencodec:"required"` |
|
|
|
V *hexutil.Big `json:"v" gencodec:"required"` |
|
|
|
V *hexutil.Big `json:"v" gencodec:"required"` |
|
|
|
R *hexutil.Big `json:"r" gencodec:"required"` |
|
|
|
R *hexutil.Big `json:"r" gencodec:"required"` |
|
|
|
S *hexutil.Big `json:"s" gencodec:"required"` |
|
|
|
S *hexutil.Big `json:"s" gencodec:"required"` |
|
|
@ -30,9 +31,10 @@ func (t txdata) MarshalJSON() ([]byte, error) { |
|
|
|
} |
|
|
|
} |
|
|
|
var enc txdata |
|
|
|
var enc txdata |
|
|
|
enc.AccountNonce = hexutil.Uint64(t.AccountNonce) |
|
|
|
enc.AccountNonce = hexutil.Uint64(t.AccountNonce) |
|
|
|
enc.ShardID = t.ShardID |
|
|
|
|
|
|
|
enc.Price = (*hexutil.Big)(t.Price) |
|
|
|
enc.Price = (*hexutil.Big)(t.Price) |
|
|
|
enc.GasLimit = hexutil.Uint64(t.GasLimit) |
|
|
|
enc.GasLimit = hexutil.Uint64(t.GasLimit) |
|
|
|
|
|
|
|
enc.ShardID = t.ShardID |
|
|
|
|
|
|
|
enc.ToShardID = t.ToShardID |
|
|
|
enc.Recipient = t.Recipient |
|
|
|
enc.Recipient = t.Recipient |
|
|
|
enc.Amount = (*hexutil.Big)(t.Amount) |
|
|
|
enc.Amount = (*hexutil.Big)(t.Amount) |
|
|
|
enc.Payload = t.Payload |
|
|
|
enc.Payload = t.Payload |
|
|
@ -46,13 +48,14 @@ func (t txdata) MarshalJSON() ([]byte, error) { |
|
|
|
// UnmarshalJSON unmarshals from JSON.
|
|
|
|
// UnmarshalJSON unmarshals from JSON.
|
|
|
|
func (t *txdata) UnmarshalJSON(input []byte) error { |
|
|
|
func (t *txdata) UnmarshalJSON(input []byte) error { |
|
|
|
type txdata struct { |
|
|
|
type txdata struct { |
|
|
|
AccountNonce *hexutil.Uint64 `json:"nonce" gencodec:"required"` |
|
|
|
AccountNonce *hexutil.Uint64 `json:"nonce" gencodec:"required"` |
|
|
|
ShardID *uint32 `json:"shardID" gencodec:"required"` |
|
|
|
Price *hexutil.Big `json:"gasPrice" gencodec:"required"` |
|
|
|
Price *hexutil.Big `json:"gasPrice" gencodec:"required"` |
|
|
|
GasLimit *hexutil.Uint64 `json:"gas" gencodec:"required"` |
|
|
|
GasLimit *hexutil.Uint64 `json:"gas" gencodec:"required"` |
|
|
|
ShardID *uint32 `json:"shardID" gencodec:"required"` |
|
|
|
Recipient *common.Address `json:"to" rlp:"nil"` |
|
|
|
ToShardID *uint32 `json:"toShardID"` |
|
|
|
Amount *hexutil.Big `json:"value" gencodec:"required"` |
|
|
|
Recipient *common.Address `json:"to" rlp:"nil"` |
|
|
|
Payload *hexutil.Bytes `json:"input" gencodec:"required"` |
|
|
|
Amount *hexutil.Big `json:"value" gencodec:"required"` |
|
|
|
|
|
|
|
Payload *hexutil.Bytes `json:"input" gencodec:"required"` |
|
|
|
V *hexutil.Big `json:"v" gencodec:"required"` |
|
|
|
V *hexutil.Big `json:"v" gencodec:"required"` |
|
|
|
R *hexutil.Big `json:"r" gencodec:"required"` |
|
|
|
R *hexutil.Big `json:"r" gencodec:"required"` |
|
|
|
S *hexutil.Big `json:"s" gencodec:"required"` |
|
|
|
S *hexutil.Big `json:"s" gencodec:"required"` |
|
|
@ -66,10 +69,6 @@ func (t *txdata) UnmarshalJSON(input []byte) error { |
|
|
|
return errors.New("missing required field 'nonce' for txdata") |
|
|
|
return errors.New("missing required field 'nonce' for txdata") |
|
|
|
} |
|
|
|
} |
|
|
|
t.AccountNonce = uint64(*dec.AccountNonce) |
|
|
|
t.AccountNonce = uint64(*dec.AccountNonce) |
|
|
|
if dec.ShardID == nil { |
|
|
|
|
|
|
|
return errors.New("missing required field 'shardID' for txdata") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
t.ShardID = *dec.ShardID |
|
|
|
|
|
|
|
if dec.Price == nil { |
|
|
|
if dec.Price == nil { |
|
|
|
return errors.New("missing required field 'gasPrice' for txdata") |
|
|
|
return errors.New("missing required field 'gasPrice' for txdata") |
|
|
|
} |
|
|
|
} |
|
|
@ -78,6 +77,13 @@ func (t *txdata) UnmarshalJSON(input []byte) error { |
|
|
|
return errors.New("missing required field 'gas' for txdata") |
|
|
|
return errors.New("missing required field 'gas' for txdata") |
|
|
|
} |
|
|
|
} |
|
|
|
t.GasLimit = uint64(*dec.GasLimit) |
|
|
|
t.GasLimit = uint64(*dec.GasLimit) |
|
|
|
|
|
|
|
if dec.ShardID == nil { |
|
|
|
|
|
|
|
return errors.New("missing required field 'shardID' for txdata") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
t.ShardID = *dec.ShardID |
|
|
|
|
|
|
|
if dec.ToShardID != nil { |
|
|
|
|
|
|
|
t.ToShardID = *dec.ToShardID |
|
|
|
|
|
|
|
} |
|
|
|
if dec.Recipient != nil { |
|
|
|
if dec.Recipient != nil { |
|
|
|
t.Recipient = dec.Recipient |
|
|
|
t.Recipient = dec.Recipient |
|
|
|
} |
|
|
|
} |
|
|
|