From efe1686c05b6ce95d475d7495f6cc2b954e20200 Mon Sep 17 00:00:00 2001 From: Umar Bolatov Date: Wed, 6 Jul 2022 18:38:51 -0700 Subject: [PATCH] Don't show "Set up a Lightning node" when LN is not supported (#3935) See discussion here: https://github.com/btcpayserver/btcpayserver/discussions/3868 --- .../UIStoresController.Dashboard.cs | 4 ++- .../StoreDashboardViewModel.cs | 1 + .../LNURL/LightningAddressOption.cshtml | 5 +++ BTCPayServer/Views/UIStores/Dashboard.cshtml | 36 ++++++++++--------- 4 files changed, 28 insertions(+), 18 deletions(-) diff --git a/BTCPayServer/Controllers/UIStoresController.Dashboard.cs b/BTCPayServer/Controllers/UIStoresController.Dashboard.cs index 5e80e0ddd..3a78ac538 100644 --- a/BTCPayServer/Controllers/UIStoresController.Dashboard.cs +++ b/BTCPayServer/Controllers/UIStoresController.Dashboard.cs @@ -24,13 +24,15 @@ namespace BTCPayServer.Controllers var walletEnabled = derivationSchemes.Any(scheme => !string.IsNullOrEmpty(scheme.Value) && scheme.Enabled); var lightningEnabled = lightningNodes.Any(ln => !string.IsNullOrEmpty(ln.Address) && ln.Enabled); + var cryptoCode = _NetworkProvider.DefaultNetwork.CryptoCode; var vm = new StoreDashboardViewModel { WalletEnabled = walletEnabled, LightningEnabled = lightningEnabled, + LightningSupported = _NetworkProvider.GetNetwork(cryptoCode).SupportLightning, StoreId = CurrentStore.Id, StoreName = CurrentStore.StoreName, - CryptoCode = _NetworkProvider.DefaultNetwork.CryptoCode, + CryptoCode = cryptoCode, IsSetUp = walletEnabled || lightningEnabled }; diff --git a/BTCPayServer/Models/StoreViewModels/StoreDashboardViewModel.cs b/BTCPayServer/Models/StoreViewModels/StoreDashboardViewModel.cs index 4df990c60..a7bf1b86f 100644 --- a/BTCPayServer/Models/StoreViewModels/StoreDashboardViewModel.cs +++ b/BTCPayServer/Models/StoreViewModels/StoreDashboardViewModel.cs @@ -10,6 +10,7 @@ public class StoreDashboardViewModel public string StoreName { get; set; } public bool WalletEnabled { get; set; } public bool LightningEnabled { get; set; } + public bool LightningSupported { get; set; } public bool IsSetUp { get; set; } public List Apps { get; set; } = new(); } diff --git a/BTCPayServer/Views/Shared/LNURL/LightningAddressOption.cshtml b/BTCPayServer/Views/Shared/LNURL/LightningAddressOption.cshtml index 0ed2a7f78..3218afee1 100644 --- a/BTCPayServer/Views/Shared/LNURL/LightningAddressOption.cshtml +++ b/BTCPayServer/Views/Shared/LNURL/LightningAddressOption.cshtml @@ -9,7 +9,10 @@ isLightningEnabled && isLNUrlEnabled && store.GetSupportedPaymentMethods(BTCPayNetworkProvider).OfType().Any(type => type.CryptoCode == cryptoCode); + var network = BTCPayNetworkProvider.GetNetwork(cryptoCode); } + +@if (network.SupportLightning) {
  • @@ -48,3 +51,5 @@
  • +} + diff --git a/BTCPayServer/Views/UIStores/Dashboard.cshtml b/BTCPayServer/Views/UIStores/Dashboard.cshtml index 65c6ea516..bcfb9b956 100644 --- a/BTCPayServer/Views/UIStores/Dashboard.cshtml +++ b/BTCPayServer/Views/UIStores/Dashboard.cshtml @@ -162,24 +162,26 @@ else } - @if (!Model.LightningEnabled) - { - - -
    -
    Set up a Lightning node
    + @if (Model.LightningSupported) { + if (!Model.LightningEnabled) + { +
    + +
    +
    Set up a Lightning node
    +
    + +
    + } + else + { +
    + +
    +
    Set up a Lightning node
    +
    - - - } - else - { -
    - -
    -
    Set up a Lightning node
    -
    -
    + } }
    }