From 85c81adc09b5d9b965add21f19c87d5b3ff93ce7 Mon Sep 17 00:00:00 2001 From: Liz Lightning Date: Wed, 21 Jan 2026 01:36:46 -0800 Subject: [PATCH] add user agent to coingecko historical rates call --- .../java/com/sparrowwallet/sparrow/net/ExchangeSource.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/net/ExchangeSource.java b/src/main/java/com/sparrowwallet/sparrow/net/ExchangeSource.java index 7b01ac32..e025b984 100644 --- a/src/main/java/com/sparrowwallet/sparrow/net/ExchangeSource.java +++ b/src/main/java/com/sparrowwallet/sparrow/net/ExchangeSource.java @@ -104,7 +104,7 @@ public enum ExchangeSource { HttpClientService httpClientService = AppServices.getHttpClientService(); try { - Number[][] coinbaseData = httpClientService.requestJson(url, Number[][].class, Map.of("User-Agent", "Mozilla/4.0 (compatible; MSIE 9.0; Windows NT 6.1)", "Accept", "*/*")); + Number[][] coinbaseData = httpClientService.requestJson(url, Number[][].class, HTTP_HEADERS); for(Number[] price : coinbaseData) { Date date = new Date(price[0].longValue() * 1000); historicalRates.put(DateUtils.truncate(date, Calendar.DAY_OF_MONTH), price[4].doubleValue()); @@ -152,7 +152,7 @@ public enum ExchangeSource { HttpClientService httpClientService = AppServices.getHttpClientService(); try { - return httpClientService.requestJson(url, CoinGeckoRates.class, Map.of("User-Agent", "Mozilla/4.0 (compatible; MSIE 9.0; Windows NT 6.1)", "Accept", "*/*")); + return httpClientService.requestJson(url, CoinGeckoRates.class, HTTP_HEADERS); } catch(Exception e) { if(log.isDebugEnabled()) { log.warn("Error retrieving currency rates", e); @@ -182,7 +182,7 @@ public enum ExchangeSource { Map historicalRates = new TreeMap<>(); HttpClientService httpClientService = AppServices.getHttpClientService(); try { - CoinGeckoHistoricalRates coinGeckoHistoricalRates = httpClientService.requestJson(url, CoinGeckoHistoricalRates.class, null); + CoinGeckoHistoricalRates coinGeckoHistoricalRates = httpClientService.requestJson(url, CoinGeckoHistoricalRates.class, HTTP_HEADERS); for(List historicalRate : coinGeckoHistoricalRates.prices) { Date date = new Date(historicalRate.get(0).longValue()); historicalRates.put(DateUtils.truncate(date, Calendar.DAY_OF_MONTH), historicalRate.get(1).doubleValue()); @@ -269,6 +269,7 @@ public enum ExchangeSource { }; private static final Logger log = LoggerFactory.getLogger(ExchangeSource.class); + private static final Map HTTP_HEADERS = Map.of("User-Agent", "Mozilla/4.0 (compatible; MSIE 9.0; Windows NT 6.1)", "Accept", "*/*"); private final String name; private final String description;