From d4b76823a2e49fc79930e4bda984889e9c636069 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Schj=C3=B8nhaug?= Date: Thu, 12 Dec 2024 01:59:10 +0100 Subject: [PATCH] =?UTF-8?q?Using=20Bare=20Bitcoin=E2=80=99s=20new=20public?= =?UTF-8?q?=20API=20endpoint=20for=20rates=20(#6473)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Providers/BareBitcoinRateProvider.cs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/BTCPayServer.Rating/Providers/BareBitcoinRateProvider.cs b/BTCPayServer.Rating/Providers/BareBitcoinRateProvider.cs index 6ca0d5239..cea3aa926 100644 --- a/BTCPayServer.Rating/Providers/BareBitcoinRateProvider.cs +++ b/BTCPayServer.Rating/Providers/BareBitcoinRateProvider.cs @@ -10,7 +10,7 @@ namespace BTCPayServer.Services.Rates { private readonly HttpClient _httpClient; - public RateSourceInfo RateSourceInfo => new("barebitcoin", "Bare Bitcoin", "https://api.bb.no/price"); + public RateSourceInfo RateSourceInfo => new("barebitcoin", "Bare Bitcoin", "https://api.bb.no/v1/price/nok"); public BareBitcoinRateProvider(HttpClient httpClient) { @@ -24,16 +24,15 @@ namespace BTCPayServer.Services.Rates var jobj = await response.Content.ReadAsAsync(cancellationToken); - // Extract market and otc prices - var market = jobj["market"].Value(); - var buy = jobj["buy"].Value(); - var sell = jobj["sell"].Value(); + // Extract bid/ask prices from JSON response + var bid = (decimal)jobj["bid"]; + var ask = (decimal)jobj["ask"]; // Create currency pair for BTC/NOK var pair = new CurrencyPair("BTC", "NOK"); - // Return single pair rate with sell/buy as bid/ask - return new[] { new PairRate(pair, new BidAsk(sell, buy)) }; + // Return single pair rate with bid/ask + return new[] { new PairRate(pair, new BidAsk(bid, ask)) }; } } } \ No newline at end of file