func (pool *TxPool) ValidateTransaction(tx *types.Transaction) error { // Validate sender var ( from common.Address err error ) if from, err = tx.From(); err != nil { return ErrInvalidSender } // Validate curve param v, _, _ := tx.Curve() if v > 28 || v < 27 { return fmt.Errorf("tx.v != (28 || 27) => %v", v) } if !pool.currentState().HasAccount(from) { return ErrNonExistentAccount } if pool.gasLimit().Cmp(tx.GasLimit) < 0 { return ErrGasLimit } total := new(big.Int).Mul(tx.Price, tx.GasLimit) total.Add(total, tx.Value()) if pool.currentState().GetBalance(from).Cmp(total) < 0 { return ErrInsufficientFunds } if tx.GasLimit.Cmp(IntrinsicGas(tx)) < 0 { return ErrIntrinsicGas } if pool.currentState().GetNonce(from) > tx.Nonce() { return ErrNonce } return nil }