aboutsummaryrefslogtreecommitdiff
path: root/core/types
diff options
context:
space:
mode:
authorDeterminant <tederminant@gmail.com>2020-06-30 17:05:50 -0400
committerDeterminant <tederminant@gmail.com>2020-06-30 17:05:50 -0400
commit7feec02902d52a3abf722613eb9e218e015b723c (patch)
tree3ca683e866cdaba9c06480f825682677826557f3 /core/types
parent3a872747058e9fd32810d0864e19a197529b7d79 (diff)
make mc tx work
Diffstat (limited to 'core/types')
-rw-r--r--core/types/gen_tx_json.go12
-rw-r--r--core/types/transaction.go22
2 files changed, 23 insertions, 11 deletions
diff --git a/core/types/gen_tx_json.go b/core/types/gen_tx_json.go
index 0410632..dd0d069 100644
--- a/core/types/gen_tx_json.go
+++ b/core/types/gen_tx_json.go
@@ -21,6 +21,8 @@ func (t txdata) MarshalJSON() ([]byte, error) {
GasLimit hexutil.Uint64 `json:"gas" gencodec:"required"`
Recipient *common.Address `json:"to" rlp:"nil"`
Amount *hexutil.Big `json:"value" gencodec:"required"`
+ CoinID *common.Hash `json:"coinid" rlp:"nil"`
+ Amount2 *hexutil.Big `json:"value2" rlp:"nil"`
Payload hexutil.Bytes `json:"input" gencodec:"required"`
V *hexutil.Big `json:"v" gencodec:"required"`
R *hexutil.Big `json:"r" gencodec:"required"`
@@ -33,6 +35,8 @@ func (t txdata) MarshalJSON() ([]byte, error) {
enc.GasLimit = hexutil.Uint64(t.GasLimit)
enc.Recipient = t.Recipient
enc.Amount = (*hexutil.Big)(t.Amount)
+ enc.CoinID = t.CoinID
+ enc.Amount2 = (*hexutil.Big)(t.Amount2)
enc.Payload = t.Payload
enc.V = (*hexutil.Big)(t.V)
enc.R = (*hexutil.Big)(t.R)
@@ -49,6 +53,8 @@ func (t *txdata) UnmarshalJSON(input []byte) error {
GasLimit *hexutil.Uint64 `json:"gas" gencodec:"required"`
Recipient *common.Address `json:"to" rlp:"nil"`
Amount *hexutil.Big `json:"value" gencodec:"required"`
+ CoinID *common.Hash `json:"coinid" rlp:"nil"`
+ Amount2 *hexutil.Big `json:"value2" rlp:"nil"`
Payload *hexutil.Bytes `json:"input" gencodec:"required"`
V *hexutil.Big `json:"v" gencodec:"required"`
R *hexutil.Big `json:"r" gencodec:"required"`
@@ -78,6 +84,12 @@ func (t *txdata) UnmarshalJSON(input []byte) error {
return errors.New("missing required field 'value' for txdata")
}
t.Amount = (*big.Int)(dec.Amount)
+ if dec.CoinID != nil {
+ t.CoinID = dec.CoinID
+ }
+ if dec.Amount2 != nil {
+ t.Amount2 = (*big.Int)(dec.Amount2)
+ }
if dec.Payload == nil {
return errors.New("missing required field 'input' for txdata")
}
diff --git a/core/types/transaction.go b/core/types/transaction.go
index cf9e61a..858b443 100644
--- a/core/types/transaction.go
+++ b/core/types/transaction.go
@@ -49,8 +49,8 @@ type txdata struct {
GasLimit uint64 `json:"gas" gencodec:"required"`
Recipient *common.Address `json:"to" rlp:"nil"` // nil means contract creation
Amount *big.Int `json:"value" gencodec:"required"`
- CoinID *common.Hash `json:"coinid" rlp:"-"`
- Amount2 *big.Int `json:"value2"`
+ CoinID *common.Hash `json:"coinid" rlp:"nil"`
+ Amount2 *big.Int `json:"value2" rlp:"nil"`
Payload []byte `json:"input" gencodec:"required"`
// Signature values
@@ -67,7 +67,7 @@ type txdataMarshaling struct {
Price *hexutil.Big
GasLimit hexutil.Uint64
Amount *hexutil.Big
- CoinID *hexutil.Bytes
+ CoinID *common.Hash
Amount2 *hexutil.Big
Payload hexutil.Bytes
V *hexutil.Big
@@ -183,14 +183,14 @@ func (tx *Transaction) UnmarshalJSON(input []byte) error {
return nil
}
-func (tx *Transaction) Data() []byte { return common.CopyBytes(tx.data.Payload) }
-func (tx *Transaction) Gas() uint64 { return tx.data.GasLimit }
-func (tx *Transaction) GasPrice() *big.Int { return new(big.Int).Set(tx.data.Price) }
-func (tx *Transaction) Value() *big.Int { return new(big.Int).Set(tx.data.Amount) }
-func (tx *Transaction) CoinID() *big.Int { return big.NewInt(0) }
-func (tx *Transaction) Value2() *big.Int { return big.NewInt(0) }
-func (tx *Transaction) Nonce() uint64 { return tx.data.AccountNonce }
-func (tx *Transaction) CheckNonce() bool { return true }
+func (tx *Transaction) Data() []byte { return common.CopyBytes(tx.data.Payload) }
+func (tx *Transaction) Gas() uint64 { return tx.data.GasLimit }
+func (tx *Transaction) GasPrice() *big.Int { return new(big.Int).Set(tx.data.Price) }
+func (tx *Transaction) Value() *big.Int { return new(big.Int).Set(tx.data.Amount) }
+func (tx *Transaction) CoinID() *common.Hash { return tx.data.CoinID }
+func (tx *Transaction) Value2() *big.Int { return new(big.Int).Set(tx.data.Amount2) }
+func (tx *Transaction) Nonce() uint64 { return tx.data.AccountNonce }
+func (tx *Transaction) CheckNonce() bool { return true }
// To returns the recipient address of the transaction.
// It returns nil if the transaction is a contract creation.