diff --git a/BTCPayServer.Rating/Providers/HitBTCRateProvider.cs b/BTCPayServer.Rating/Providers/HitBTCRateProvider.cs index deaa90a0c..1a98e96b5 100644 --- a/BTCPayServer.Rating/Providers/HitBTCRateProvider.cs +++ b/BTCPayServer.Rating/Providers/HitBTCRateProvider.cs @@ -24,13 +24,21 @@ namespace BTCPayServer.Rating var jarray = await response.Content.ReadAsAsync(cancellationToken); return jarray .Children() - .Where(p => CurrencyPair.TryParse(p["symbol"].Value(), out _)) - .Select(p => new PairRate(CurrencyPair.Parse(p["symbol"].Value()), CreateBidAsk(p))) + .Select(p => + { + CurrencyPair.TryParse(p["symbol"].Value(), out var currency); + var bidask = CreateBidAsk(p); + return (currency, bidask); + }) + .Where(p => p.currency != null && p.bidask != null) + .Select(p => new PairRate(p.currency, p.bidask)) .ToArray(); } private BidAsk CreateBidAsk(JObject p) { + if (p["bid"].Type != JTokenType.String || p["ask"].Type != JTokenType.String) + return null; var bid = p["bid"].Value(); var ask = p["ask"].Value(); return new BidAsk(bid, ask);