tx Enode/DecodeRLP methods

This commit is contained in:
Ian Norden
2020-07-03 14:26:02 -05:00
parent 54f71abdbc
commit 910f8fb071
+12
View File
@@ -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 gasPremiums 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()