Skip to content

Commit

Permalink
Minor change
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan-Ethernal committed Feb 26, 2024
1 parent a7e736b commit b0faeff
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions crypto/txsigner.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,23 @@ type TxSigner interface {

// NewSigner creates a new signer based on currently supported forks
func NewSigner(forks chain.ForksInTime, chainID uint64) TxSigner {
var signer TxSigner

if forks.London {
signer = NewLondonSigner(chainID)
} else if forks.Berlin {
signer = NewBerlinSigner(chainID)
} else if forks.EIP155 {
signer = NewEIP155Signer(chainID)
} else if forks.Homestead {
signer = NewHomesteadSigner()
} else {
signer = NewFrontierSigner()
return NewLondonSigner(chainID)
}

if forks.Berlin {
return NewBerlinSigner(chainID)
}

if forks.EIP155 {
return NewEIP155Signer(chainID)
}

if forks.Homestead {
return NewHomesteadSigner()
}

return signer
return NewFrontierSigner()
}

// encodeSignature generates a signature based on the R, S and parity values
Expand All @@ -61,7 +63,7 @@ func NewSigner(forks chain.ForksInTime, chainID uint64) TxSigner {
// the encodeSignature function expects parity of Y coordinate as third input and that is what will be encoded
func encodeSignature(r, s, parity *big.Int, isHomestead bool) ([]byte, error) {
if !ValidateSignatureValues(parity, r, s, isHomestead) {
return nil, errors.New("signature encoding failed: Invalid transaction signature")
return nil, errors.New("signature encoding failed, because transaction signature is invalid")
}

signature := make([]byte, 65)
Expand Down

0 comments on commit b0faeff

Please sign in to comment.