core/types: fix LatestSignerForChainID panic with chainID 0

This commit is contained in:
allen 2025-09-11 08:45:21 -04:00
parent cbf0b5bc92
commit e392a9bfeb

View file

@ -92,14 +92,14 @@ func LatestSigner(config *params.ChainConfig) Signer {
// LatestSignerForChainID returns the 'most permissive' Signer available. Specifically, // LatestSignerForChainID returns the 'most permissive' Signer available. Specifically,
// this enables support for EIP-155 replay protection and all implemented EIP-2718 // this enables support for EIP-155 replay protection and all implemented EIP-2718
// transaction types if chainID is non-nil. // transaction types if chainID is non-nil and greater than zero.
// //
// Use this in transaction-handling code where the current block number and fork // Use this in transaction-handling code where the current block number and fork
// configuration are unknown. If you have a ChainConfig, use LatestSigner instead. // configuration are unknown. If you have a ChainConfig, use LatestSigner instead.
// If you have a ChainConfig and know the current block number, use MakeSigner instead. // If you have a ChainConfig and know the current block number, use MakeSigner instead.
func LatestSignerForChainID(chainID *big.Int) Signer { func LatestSignerForChainID(chainID *big.Int) Signer {
var signer Signer var signer Signer
if chainID != nil { if chainID != nil && chainID.Sign() > 0 {
signer = NewPragueSigner(chainID) signer = NewPragueSigner(chainID)
} else { } else {
signer = HomesteadSigner{} signer = HomesteadSigner{}