add user agent to coingecko historical rates call
What changed, and why it matters
This commit is a small cleanup that makes the CoinGecko historical exchange-rate request send the same browser-like User-Agent header that other exchange-rate calls already use. Previously, that one CoinGecko call sent no special headers. The change is unlikely to be a security fix on its own; it looks more like a reliability tweak to avoid being blocked by the CoinGecko API, which sometimes rejects requests without a User-Agent.
No immediate action required. Treat as a routine reliability/refactoring change. If reviewing for a security release, confirm whether CoinGecko was actually blocking or rate-limiting requests without a User-Agent, and verify no other API calls need the same header.
Security signals we found
No input validation, authentication, or cryptography changes
No memory-safety, injection, or privilege changes
Change only affects outbound HTTP headers for a third-party price API
Hardcoded User-Agent is already used elsewhere in the same file
Evidence from the diff
The diff extracts a repeated Map of HTTP headers into a constant named HTTP_HEADERS and applies it to the CoinGecko historical-rates request, which previously passed null for headers. The same headers were already used for Coinbase and CoinGecko live-rate requests. There is no cryptographic, authentication, or input-validation change. The only effect is that the historical-rates HTTP request now includes a hardcoded Mozilla/4.0 User-Agent and Accept: /.
Changed components
src/main/java/com/sparrowwallet/sparrow/net/ExchangeSource.javaCoinGecko historical exchange-rate retrievalInspect captured patch +4 / −3
diff --git a/src/main/java/com/sparrowwallet/sparrow/net/ExchangeSource.java b/src/main/java/com/sparrowwallet/sparrow/net/ExchangeSource.java
index 7b01ac3..e025b98 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<Date, Double> 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<Number> 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<String, String> 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;
Why this scored 19/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.