From 8e7b0555253e2164f80ad8dcd55f6146ee0cdcda 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 070927484cc7c..8e3db617703a5 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)