Skip to content

Commit

Permalink
webserver: Ensure sub forms are not nil.
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeGruffins committed Oct 4, 2024
1 parent 8db3d84 commit cceac4d
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions client/webserver/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,10 @@ func (s *WebServer) apiTrade(w http.ResponseWriter, r *http.Request) {
return
}
defer zero(pass)
if form.Order == nil {
s.writeAPIError(w, errors.New("order missing"))
return
}
ord, err := s.core.Trade(pass, form.Order)
if err != nil {
s.writeAPIError(w, fmt.Errorf("error placing order: %w", err))
Expand Down Expand Up @@ -748,6 +752,10 @@ func (s *WebServer) apiAccountImport(w http.ResponseWriter, r *http.Request) {
return
}
defer zero(pass)
if form.Account == nil {
s.writeAPIError(w, errors.New("account missing"))
return
}
err = s.core.AccountImport(pass, form.Account, form.Bonds)
if err != nil {
s.writeAPIError(w, fmt.Errorf("error importing account: %w", err))
Expand Down Expand Up @@ -1668,6 +1676,11 @@ func (s *WebServer) apiRunLogs(w http.ResponseWriter, r *http.Request) {
return
}

if req.Market == nil {
s.writeAPIError(w, errors.New("market missing"))
return
}

logs, updatedLogs, overview, err := s.mm.RunLogs(req.StartTime, req.Market, req.N, req.RefID, req.Filters)
if err != nil {
s.writeAPIError(w, fmt.Errorf("error getting run logs: %w", err))
Expand Down Expand Up @@ -1888,6 +1901,11 @@ func (s *WebServer) apiStartMarketMakingBot(w http.ResponseWriter, r *http.Reque
s.writeAPIError(w, fmt.Errorf("password error: %w", err))
return
}
defer zero(appPW)
if form.Config == nil {
s.writeAPIError(w, errors.New("config missing"))
return
}
if err = s.mm.StartBot(form.Config, nil, appPW); err != nil {
s.writeAPIError(w, fmt.Errorf("error starting market making: %v", err))
return
Expand All @@ -1904,6 +1922,10 @@ func (s *WebServer) apiStopMarketMakingBot(w http.ResponseWriter, r *http.Reques
s.writeAPIError(w, fmt.Errorf("failed to read form"))
return
}
if form.Market == nil {
s.writeAPIError(w, errors.New("market missing"))
return
}
if err := s.mm.StopBot(form.Market); err != nil {
s.writeAPIError(w, fmt.Errorf("error stopping mm bot %q: %v", form.Market, err))
return
Expand Down

0 comments on commit cceac4d

Please sign in to comment.