From 8bbaf882a61e38caadd3857cfb218df7a0a75c7b Mon Sep 17 00:00:00 2001 From: Freeman Jiang Date: Tue, 13 Jun 2023 08:46:45 -0400 Subject: [PATCH] core/types: add "chainID" field to legacy tx JSON encoding (#27452) Co-authored-by: lightclient <14004106+lightclient@users.noreply.github.com> --- core/types/transaction_marshalling.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/types/transaction_marshalling.go b/core/types/transaction_marshalling.go index 070927484..8e3db6177 100644 --- a/core/types/transaction_marshalling.go +++ b/core/types/transaction_marshalling.go @@ -69,6 +69,9 @@ func (tx *Transaction) MarshalJSON() ([]byte, error) { enc.V = (*hexutil.Big)(itx.V) enc.R = (*hexutil.Big)(itx.R) enc.S = (*hexutil.Big)(itx.S) + if tx.Protected() { + enc.ChainID = (*hexutil.Big)(tx.ChainId()) + } case *AccessListTx: enc.ChainID = (*hexutil.Big)(itx.ChainID)