From 1eee31e9f1ae4b359e8e8672c4d4630c19d39c69 Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Mon, 4 Jun 2018 12:01:30 +0900 Subject: [PATCH] Fix rate bug: Sometimes coinaverage is sending null bid and ask --- BTCPayServer/Services/Rates/CoinAverageRateProvider.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/BTCPayServer/Services/Rates/CoinAverageRateProvider.cs b/BTCPayServer/Services/Rates/CoinAverageRateProvider.cs index 79562daa1..1b6e83b01 100644 --- a/BTCPayServer/Services/Rates/CoinAverageRateProvider.cs +++ b/BTCPayServer/Services/Rates/CoinAverageRateProvider.cs @@ -85,7 +85,8 @@ namespace BTCPayServer.Services.Rates { JToken bid = p.Value["bid"]; JToken ask = p.Value["ask"]; - if (!decimal.TryParse(bid.Value(), System.Globalization.NumberStyles.AllowExponent | System.Globalization.NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var v1) || + if (bid == null || ask == null || + !decimal.TryParse(bid.Value(), System.Globalization.NumberStyles.AllowExponent | System.Globalization.NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var v1) || !decimal.TryParse(ask.Value(), System.Globalization.NumberStyles.AllowExponent | System.Globalization.NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var v2) || v1 > v2 || v1 <= 0 || v2 <= 0)