diff --git a/core/types/transaction.go b/core/types/transaction.go index 598e6f583..982590577 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -111,6 +111,12 @@ func newTransaction(nonce uint64, to *common.Address, amount *big.Int, gasLimit if feeCap != nil { d.FeeCap = feeCap } + if gasPremium != nil { + d.GasPremium = gasPremium + } + if feeCap != nil { + d.FeeCap = feeCap + } return &Transaction{data: d} } @@ -152,6 +158,12 @@ func (tx *Transaction) EncodeRLP(w io.Writer) error { return rlp.Encode(w, &tx.data) } +/* +DecodeRLP should decode the rlp.Stream value into individual fields first, then build the resulting struct. +If decoding the gasPremium’s value returns an EOL error, then this is a legacy transaction. +This allows legacy RLP-encoded transactions to be decoded while properly handling errors +*/ + // DecodeRLP implements rlp.Decoder func (tx *Transaction) DecodeRLP(stream *rlp.Stream) error { size, err := stream.List()