From 20459a2f462b20d7b7d5507ce52325e04f78a7d5 Mon Sep 17 00:00:00 2001 From: Martin Date: Tue, 7 Jan 2020 23:09:18 +0100 Subject: [PATCH] Fix groupBy parameter parsing --- server/public.go | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/server/public.go b/server/public.go index 07c9bd4e..57a3c4b8 100644 --- a/server/public.go +++ b/server/public.go @@ -1058,20 +1058,17 @@ func (s *PublicServer) apiBalanceHistory(r *http.Request, apiVersion int) (inter // time.RFC3339 toTime, _ = time.Parse("2006-01-02", t) } - var groupBy uint32 - i, err := strconv.ParseUint(r.URL.Query().Get("groupBy"), 10, 32) - if err != nil || i <= 0 { + var groupBy uint64 + groupBy, err = strconv.ParseUint(r.URL.Query().Get("groupBy"), 10, 32) + if err != nil || groupBy == 0 { groupBy = 3600 - } else { - groupBy = uint32(i) } fiat := r.URL.Query().Get("fiatcurrency") - - history, err = s.api.GetXpubBalanceHistory(r.URL.Path[i+1:], fromTime, toTime, fiat, gap, groupBy) + history, err = s.api.GetXpubBalanceHistory(r.URL.Path[i+1:], fromTime, toTime, fiat, gap, uint32(groupBy)) if err == nil { s.metrics.ExplorerViews.With(common.Labels{"action": "api-xpub-balancehistory"}).Inc() } else { - history, err = s.api.GetBalanceHistory(r.URL.Path[i+1:], fromTime, toTime, fiat, groupBy) + history, err = s.api.GetBalanceHistory(r.URL.Path[i+1:], fromTime, toTime, fiat, uint32(groupBy)) s.metrics.ExplorerViews.With(common.Labels{"action": "api-address-balancehistory"}).Inc() } }