diff --git a/types/rlp_marshal.go b/types/rlp_marshal.go index 801f9ce9e2..cb19d88420 100644 --- a/types/rlp_marshal.go +++ b/types/rlp_marshal.go @@ -198,6 +198,10 @@ func (t *Transactions) MarshalRLPWith(a *fastrlp.Arena) *fastrlp.Value { vv := a.NewArray() for _, tt := range *t { + if tt.Type() != LegacyTxType { + vv.Set(a.NewCopyBytes([]byte{byte(tt.Type())})) + } + vv.Set(tt.MarshalRLPWith(a)) } diff --git a/types/rlp_unmarshal.go b/types/rlp_unmarshal.go index cc7f72c77e..cc33b2a1e1 100644 --- a/types/rlp_unmarshal.go +++ b/types/rlp_unmarshal.go @@ -229,24 +229,6 @@ func (h *Header) unmarshalRLPFrom(_ *fastrlp.Parser, v *fastrlp.Value) error { return err } -func (t *Transactions) UnmarshalRLP(input []byte) error { - return UnmarshalRlp(t.unmarshalRLPFrom, input) -} - -func (t *Transactions) unmarshalRLPFrom(p *fastrlp.Parser, v *fastrlp.Value) error { - return unmarshalRLPFrom(p, v, func(_ TxType, p *fastrlp.Parser, v *fastrlp.Value) error { - obj := &Transaction{} - - if err := obj.UnmarshalRLPFrom(p, v); err != nil { - return err - } - - *t = append(*t, obj) - - return nil - }) -} - func (r *Receipts) UnmarshalRLP(input []byte) error { return UnmarshalRlp(r.unmarshalRLPFrom, input) } @@ -376,6 +358,24 @@ func (l *Log) unmarshalRLPFrom(_ *fastrlp.Parser, v *fastrlp.Value) error { return nil } +func (t *Transactions) UnmarshalRLP(input []byte) error { + return UnmarshalRlp(t.unmarshalRLPFrom, input) +} + +func (t *Transactions) unmarshalRLPFrom(p *fastrlp.Parser, v *fastrlp.Value) error { + return unmarshalRLPFrom(p, v, func(txType TxType, p *fastrlp.Parser, v *fastrlp.Value) error { + obj := NewTxWithType(txType) + + if err := obj.UnmarshalRLPFrom(p, v); err != nil { + return err + } + + *t = append(*t, obj) + + return nil + }) +} + // UnmarshalRLP unmarshals transaction from byte slice // Caution: Hash calculation should be done from the outside! func (t *Transaction) UnmarshalRLP(input []byte) error {