diff options
Diffstat (limited to 'core/types/transaction.go')
-rw-r--r-- | core/types/transaction.go | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/core/types/transaction.go b/core/types/transaction.go index 9c6e77be9..7b53cac2c 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -153,16 +153,21 @@ func (tx *Transaction) UnmarshalJSON(input []byte) error { if err := dec.UnmarshalJSON(input); err != nil { return err } - var V byte - if isProtectedV(dec.V) { - chainID := deriveChainId(dec.V).Uint64() - V = byte(dec.V.Uint64() - 35 - 2*chainID) - } else { - V = byte(dec.V.Uint64() - 27) - } - if !crypto.ValidateSignatureValues(V, dec.R, dec.S, false) { - return ErrInvalidSig + + withSignature := dec.V.Sign() != 0 || dec.R.Sign() != 0 || dec.S.Sign() != 0 + if withSignature { + var V byte + if isProtectedV(dec.V) { + chainID := deriveChainId(dec.V).Uint64() + V = byte(dec.V.Uint64() - 35 - 2*chainID) + } else { + V = byte(dec.V.Uint64() - 27) + } + if !crypto.ValidateSignatureValues(V, dec.R, dec.S, false) { + return ErrInvalidSig + } } + *tx = Transaction{data: dec} return nil } |