mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
core/types: define yParity errors
This commit is contained in:
parent
736a4ccb2f
commit
f1243b462f
2 changed files with 6 additions and 3 deletions
|
|
@ -37,6 +37,9 @@ var (
|
||||||
ErrTxTypeNotSupported = errors.New("transaction type not supported")
|
ErrTxTypeNotSupported = errors.New("transaction type not supported")
|
||||||
ErrGasFeeCapTooLow = errors.New("fee cap less than base fee")
|
ErrGasFeeCapTooLow = errors.New("fee cap less than base fee")
|
||||||
errShortTypedTx = errors.New("typed transaction too short")
|
errShortTypedTx = errors.New("typed transaction too short")
|
||||||
|
errInvalidYParity = errors.New("'yParity' field must be 0 or 1")
|
||||||
|
errVYParityMismatch = errors.New("'v' and 'yParity' fields do not match")
|
||||||
|
errVYParityMissing = errors.New("missing 'yParity' or 'v' field in transaction")
|
||||||
)
|
)
|
||||||
|
|
||||||
// Transaction types.
|
// Transaction types.
|
||||||
|
|
|
||||||
|
|
@ -57,18 +57,18 @@ func (tx *txJSON) yParityValue() (*big.Int, error) {
|
||||||
if tx.YParity != nil {
|
if tx.YParity != nil {
|
||||||
val := uint64(*tx.YParity)
|
val := uint64(*tx.YParity)
|
||||||
if val != 0 && val != 1 {
|
if val != 0 && val != 1 {
|
||||||
return nil, errors.New("'yParity' field must be 0 or 1")
|
return nil, errInvalidYParity
|
||||||
}
|
}
|
||||||
bigval := new(big.Int).SetUint64(val)
|
bigval := new(big.Int).SetUint64(val)
|
||||||
if tx.V != nil && tx.V.ToInt().Cmp(bigval) != 0 {
|
if tx.V != nil && tx.V.ToInt().Cmp(bigval) != 0 {
|
||||||
return nil, errors.New("'v' and 'yParity' fields do not match")
|
return nil, errVYParityMismatch
|
||||||
}
|
}
|
||||||
return bigval, nil
|
return bigval, nil
|
||||||
}
|
}
|
||||||
if tx.V != nil {
|
if tx.V != nil {
|
||||||
return tx.V.ToInt(), nil
|
return tx.V.ToInt(), nil
|
||||||
}
|
}
|
||||||
return nil, errors.New("missing 'yParity' or 'v' field in transaction")
|
return nil, errVYParityMissing
|
||||||
}
|
}
|
||||||
|
|
||||||
// MarshalJSON marshals as JSON with a hash.
|
// MarshalJSON marshals as JSON with a hash.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue