From 910f8fb071256098f3f5e8abcf9dec7f8f1da83e Mon Sep 17 00:00:00 2001 From: Ian Norden Date: Wed, 6 Nov 2019 16:25:13 -0600 Subject: [PATCH] tx Enode/DecodeRLP methods --- core/types/transaction.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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()