From 6459c7bfad975ecb054bd36d5c52956481a11a2b Mon Sep 17 00:00:00 2001 From: Kukks Date: Mon, 15 Aug 2022 20:21:20 +0200 Subject: [PATCH] fix altcoin only dashboard crash closes #4038 --- .../Components/MainNav/Default.cshtml | 2 +- .../UIStoresController.Dashboard.cs | 2 +- .../Altcoins/Monero/MoneroLikeExtensions.cs | 1 + BTCPayServer/Services/Cheater.cs | 4 ++-- .../StoreWalletsNavMoneroExtension.cshtml | 20 +++++++++++++++++++ 5 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 BTCPayServer/Views/Shared/Monero/StoreWalletsNavMoneroExtension.cshtml diff --git a/BTCPayServer/Components/MainNav/Default.cshtml b/BTCPayServer/Components/MainNav/Default.cshtml index 5ada7ec9d..0b46bb5b9 100644 --- a/BTCPayServer/Components/MainNav/Default.cshtml +++ b/BTCPayServer/Components/MainNav/Default.cshtml @@ -93,7 +93,7 @@ } - + @if (PoliciesSettings.Experimental) { @foreach (var custodianAccount in Model.CustodianAccounts) diff --git a/BTCPayServer/Controllers/UIStoresController.Dashboard.cs b/BTCPayServer/Controllers/UIStoresController.Dashboard.cs index 3a78ac538..49cccaa08 100644 --- a/BTCPayServer/Controllers/UIStoresController.Dashboard.cs +++ b/BTCPayServer/Controllers/UIStoresController.Dashboard.cs @@ -29,7 +29,7 @@ namespace BTCPayServer.Controllers { WalletEnabled = walletEnabled, LightningEnabled = lightningEnabled, - LightningSupported = _NetworkProvider.GetNetwork(cryptoCode).SupportLightning, + LightningSupported = _NetworkProvider.GetNetwork(cryptoCode)?.SupportLightning is true, StoreId = CurrentStore.Id, StoreName = CurrentStore.StoreName, CryptoCode = cryptoCode, diff --git a/BTCPayServer/Services/Altcoins/Monero/MoneroLikeExtensions.cs b/BTCPayServer/Services/Altcoins/Monero/MoneroLikeExtensions.cs index 81755d430..7a6d136d9 100644 --- a/BTCPayServer/Services/Altcoins/Monero/MoneroLikeExtensions.cs +++ b/BTCPayServer/Services/Altcoins/Monero/MoneroLikeExtensions.cs @@ -25,6 +25,7 @@ namespace BTCPayServer.Services.Altcoins.Monero serviceCollection.AddSingleton(); serviceCollection.AddSingleton(provider => provider.GetService()); serviceCollection.AddSingleton(new UIExtension("Monero/StoreNavMoneroExtension", "store-nav")); + serviceCollection.AddSingleton(new UIExtension("Monero/StoreWalletsNavMoneroExtension", "store-wallets-nav")); serviceCollection.AddSingleton(); return serviceCollection; diff --git a/BTCPayServer/Services/Cheater.cs b/BTCPayServer/Services/Cheater.cs index 6fe76cc75..3f48ff2ea 100644 --- a/BTCPayServer/Services/Cheater.cs +++ b/BTCPayServer/Services/Cheater.cs @@ -17,7 +17,7 @@ namespace BTCPayServer.Services public Cheater(BTCPayServerOptions opts, ExplorerClientProvider prov, ApplicationDbContextFactory applicationDbContextFactory) { - CashCow = prov.GetExplorerClient("BTC").RPCClient; + CashCow = prov.GetExplorerClient("BTC")?.RPCClient; _applicationDbContextFactory = applicationDbContextFactory; } public RPCClient CashCow @@ -38,7 +38,7 @@ namespace BTCPayServer.Services Task IHostedService.StartAsync(CancellationToken cancellationToken) { - _ = CashCow.ScanRPCCapabilitiesAsync(); + _ = CashCow?.ScanRPCCapabilitiesAsync(); return Task.CompletedTask; } diff --git a/BTCPayServer/Views/Shared/Monero/StoreWalletsNavMoneroExtension.cshtml b/BTCPayServer/Views/Shared/Monero/StoreWalletsNavMoneroExtension.cshtml new file mode 100644 index 000000000..38ffd4c42 --- /dev/null +++ b/BTCPayServer/Views/Shared/Monero/StoreWalletsNavMoneroExtension.cshtml @@ -0,0 +1,20 @@ +@using BTCPayServer.Services.Altcoins.Monero.Configuration +@using BTCPayServer.Services.Altcoins.Monero.UI +@using Microsoft.AspNetCore.Mvc.TagHelpers +@using BTCPayServer.Client +@using BTCPayServer.Abstractions.TagHelpers +@inject MoneroLikeConfiguration MoneroLikeConfiguration; +@{ + var controller = ViewContext.RouteData.Values["Controller"].ToString(); + var isMonero = nameof(UIMoneroLikeStoreController).StartsWith(controller, StringComparison.InvariantCultureIgnoreCase); +} +@if (MoneroLikeConfiguration.MoneroLikeConfigurationItems.Any()) +{ + +}