Histograms: Add Lightning data and API endpoints (#6217)

* Histograms: Add Lightning data and API endpoints

Ported over from the mobile-working-branch.

Adds histogram data for Lightning and exposes the wallet/lightning histogram data via the API. It also add a dashboard graph for the Lightning balance.

Caveat: The Lightning histogram is calculated by using the current channel balance and going backwards through as much invoices and transactions as we have. The "start" of the LN graph data might not be accurate though. That's because we don't track (and not even have) the LN onchain data. It is calculated by using the current channel balance and going backwards through as much invoices and transactions as we have. So the historic graph data for LN is basically a best effort of trying to reconstruct it with what we have: The LN channel transactions.

* More timeframes

* Refactoring: Remove redundant WalletHistogram types

* Remove store property from dashboard tile view models

* JS error fixes
This commit is contained in:
d11n
2024-11-05 13:40:37 +01:00
committed by GitHub
parent b3945d758a
commit 641bdcff31
30 changed files with 790 additions and 198 deletions

View File

@@ -1,5 +1,4 @@
#nullable enable
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using BTCPayServer.Abstractions.Constants;
@@ -64,7 +63,9 @@ public partial class UIStoresController : Controller
SettingsRepository settingsRepository,
CurrencyNameTable currencyNameTable,
IStringLocalizer stringLocalizer,
EventAggregator eventAggregator)
EventAggregator eventAggregator,
LightningHistogramService lnHistogramService,
LightningClientFactoryService lightningClientFactory)
{
_rateFactory = rateFactory;
_storeRepo = storeRepo;
@@ -95,6 +96,8 @@ public partial class UIStoresController : Controller
_dataProtector = dataProtector.CreateProtector("ConfigProtector");
_webhookNotificationManager = webhookNotificationManager;
_lightningNetworkOptions = lightningNetworkOptions.Value;
_lnHistogramService = lnHistogramService;
_lightningClientFactory = lightningClientFactory;
StringLocalizer = stringLocalizer;
}
@@ -127,6 +130,8 @@ public partial class UIStoresController : Controller
private readonly WebhookSender _webhookNotificationManager;
private readonly LightningNetworkOptions _lightningNetworkOptions;
private readonly IDataProtector _dataProtector;
private readonly LightningHistogramService _lnHistogramService;
private readonly LightningClientFactoryService _lightningClientFactory;
public string? GeneratedPairingCode { get; set; }
public IStringLocalizer StringLocalizer { get; }