diff --git a/core/types/transaction_signing.go b/core/types/transaction_signing.go index c428c4626e..ca3d046455 100644 --- a/core/types/transaction_signing.go +++ b/core/types/transaction_signing.go @@ -53,6 +53,28 @@ func MakeSigner(config *params.ChainConfig, blockNumber *big.Int, blockTime uint return signer } +// LatestSigner returns the 'most permissive' Signer available for the given chain +// configuration. Specifically, this enables support of all types of transactions +// when their respective forks are scheduled to occur at any block number (or time) +// in the chain config. +// +// Use this in transaction-handling code where the current block number is unknown. If you +// have the current block number available, use MakeSigner instead. +func LatestSigner(config *params.ChainConfig) Signer { + var signer Signer + if config.ChainID != nil { + switch { + case config.EIP155Block != nil: + signer = NewEIP155Signer(config.ChainID) + default: + signer = HomesteadSigner{} + } + } else { + signer = HomesteadSigner{} + } + return signer +} + // LatestSignerForChainID returns the 'most permissive' Signer available. Specifically, // this enables support for EIP-155 replay protection and all implemented EIP-2718 // transaction types if chainID is non-nil. diff --git a/ctxc/handler.go b/ctxc/handler.go index a29a75b569..1366ad0912 100644 --- a/ctxc/handler.go +++ b/ctxc/handler.go @@ -1093,7 +1093,7 @@ func (pm *ProtocolManager) BroadcastTransactions(txs types.Transactions) { total := new(big.Int).Exp(direct, big.NewInt(2), nil) // Stabilise total peer count a bit based on sqrt peers var ( - signer = types.LatestSignerForChainID(pm.blockchain.Config().ChainID) // Don't care about chain status, we just need *a* sender + signer = types.LatestSigner(pm.blockchain.Config()) // Don't care about chain status, we just need *a* sender hasher = crypto.NewKeccakState() hash = make([]byte, 32) )