From 92ae1109d03986d10491d0bcc74cb95d82ea25bf Mon Sep 17 00:00:00 2001 From: XPayServer Date: Tue, 28 Jul 2020 22:48:51 +0200 Subject: [PATCH 1/9] Add Bitcoin Only Build --- .circleci/config.yml | 13 ++++ .../BTCPayServer.Client.csproj | 2 + .../Altcoins/BTCPayNetworkProvider.cs | 2 + .../Liquid/BTCPayNetworkProvider.Liquid.cs | 2 + .../BTCPayNetworkProvider.LiquidAssets.cs | 2 + .../Liquid/ElementsLikeBtcPayNetwork.cs | 2 + .../Altcoins/Liquid/LiquidExtensions.cs | 18 +++++ .../BTCPayServer.Common.csproj | 4 ++ BTCPayServer.Data/BTCPayServer.Data.csproj | 4 ++ .../BTCPayServer.Rating.csproj | 4 ++ BTCPayServer.Tests/BTCPayServer.Tests.csproj | 2 + BTCPayServer/BTCPayServer.csproj | 24 +++++++ .../Configuration/BTCPayServerOptions.cs | 8 +-- .../Contracts/ISyncSummaryProvider.cs | 10 +++ BTCPayServer/Controllers/StoresController.cs | 2 + BTCPayServer/Extensions/MoneyExtensions.cs | 2 + BTCPayServer/Hosting/BTCPayServerServices.cs | 9 ++- BTCPayServer/Payments/PaymentTypes.cs | 4 ++ .../Configuration/MoneroLikeConfiguration.cs | 2 + .../Altcoins/Monero/MoneroLikeExtensions.cs | 3 + .../Monero/MoneroStoreNavExtension.cs | 2 + .../MoneroLikeOnChainPaymentMethodDetails.cs | 2 + .../Monero/Payments/MoneroLikePaymentData.cs | 2 + .../MoneroLikePaymentMethodHandler.cs | 2 + .../Monero/Payments/MoneroPaymentType.cs | 2 + .../Payments/MoneroSupportedPaymentMethod.cs | 2 + .../RPC/MoneroDaemonCallbackController.cs | 2 + .../Altcoins/Monero/RPC/MoneroEvent.cs | 2 + .../MoneroLikeSummaryUpdaterHostedService.cs | 2 + .../Monero/Services/MoneroListener.cs | 2 + .../Monero/Services/MoneroRPCProvider.cs | 2 + .../Services/MoneroSyncSummaryProvider.cs | 24 +++++++ .../Monero/UI/MoneroLikeStoreController.cs | 2 + .../Monero/UI/MoneroPaymentViewModel.cs | 2 + .../Services/NBXSyncSummaryProvider.cs | 22 ++++++ .../Shared/LayoutPartials/SyncModal.cshtml | 70 ++----------------- .../Views/Shared/NBXSyncSummary.cshtml | 60 ++++++++++++++++ amd64.Dockerfile | 3 +- arm32v7.Dockerfile | 3 +- arm64v8.Dockerfile | 4 +- btcpayserver.sln | 13 ++++ 41 files changed, 270 insertions(+), 74 deletions(-) create mode 100644 BTCPayServer.Common/Altcoins/Liquid/LiquidExtensions.cs create mode 100644 BTCPayServer/Contracts/ISyncSummaryProvider.cs create mode 100644 BTCPayServer/Services/Altcoins/Monero/Services/MoneroSyncSummaryProvider.cs create mode 100644 BTCPayServer/Services/NBXSyncSummaryProvider.cs create mode 100644 BTCPayServer/Views/Shared/NBXSyncSummary.cshtml diff --git a/.circleci/config.yml b/.circleci/config.yml index 19669605e..6d8f06492 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -49,8 +49,10 @@ jobs: LATEST_TAG=${CIRCLE_TAG:1} #trim v from tag # sudo docker build --pull -t $DOCKERHUB_REPO:$LATEST_TAG-amd64 -f amd64.Dockerfile . + sudo docker build --pull --build-arg CONFIGURATION_NAME=Altcoins-Release -t $DOCKERHUB_REPO:$LATEST_TAG-altcoins-amd64 -f amd64.Dockerfile . sudo docker login --username=$DOCKERHUB_USER --password=$DOCKERHUB_PASS sudo docker push $DOCKERHUB_REPO:$LATEST_TAG-amd64 + sudo docker push $DOCKERHUB_REPO:$LATEST_TAG-altcoins-amd64 arm32v7: machine: @@ -63,8 +65,10 @@ jobs: LATEST_TAG=${CIRCLE_TAG:1} #trim v from tag # sudo docker build --pull -t $DOCKERHUB_REPO:$LATEST_TAG-arm32v7 -f arm32v7.Dockerfile . + sudo docker build --pull --build-arg CONFIGURATION_NAME=Altcoins-Release -t $DOCKERHUB_REPO:$LATEST_TAG-altcoins-arm32v7 -f arm32v7.Dockerfile . sudo docker login --username=$DOCKERHUB_USER --password=$DOCKERHUB_PASS sudo docker push $DOCKERHUB_REPO:$LATEST_TAG-arm32v7 + sudo docker push $DOCKERHUB_REPO:$LATEST_TAG-altcoins-arm32v7 arm64v8: machine: @@ -77,8 +81,10 @@ jobs: LATEST_TAG=${CIRCLE_TAG:1} #trim v from tag # sudo docker build --pull -t $DOCKERHUB_REPO:$LATEST_TAG-arm64v8 -f arm64v8.Dockerfile . + sudo docker build --build-arg CONFIGURATION_NAME=Altcoins-Release --pull -t $DOCKERHUB_REPO:$LATEST_TAG-altcoins-arm64v8 -f arm64v8.Dockerfile . sudo docker login --username=$DOCKERHUB_USER --password=$DOCKERHUB_PASS sudo docker push $DOCKERHUB_REPO:$LATEST_TAG-arm64v8 + sudo docker push $DOCKERHUB_REPO:$LATEST_TAG-altcoins-arm64v8 multiarch: machine: @@ -99,6 +105,13 @@ jobs: sudo docker manifest annotate $DOCKERHUB_REPO:$LATEST_TAG $DOCKERHUB_REPO:$LATEST_TAG-arm32v7 --os linux --arch arm --variant v7 sudo docker manifest annotate $DOCKERHUB_REPO:$LATEST_TAG $DOCKERHUB_REPO:$LATEST_TAG-arm64v8 --os linux --arch arm64 --variant v8 sudo docker manifest push $DOCKERHUB_REPO:$LATEST_TAG -p + + + sudo docker manifest create --amend $DOCKERHUB_REPO:$LATEST_TAG-altcoins $DOCKERHUB_REPO:$LATEST_TAG-altcoins-amd64 $DOCKERHUB_REPO:$LATEST_TAG-altcoins-arm32v7 $DOCKERHUB_REPO:$LATEST_TAG-altcoins-arm64v8 + sudo docker manifest annotate $DOCKERHUB_REPO:$LATEST_TAG-altcoins $DOCKERHUB_REPO:$LATEST_TAG-altcoins-amd64 --os linux --arch amd64 + sudo docker manifest annotate $DOCKERHUB_REPO:$LATEST_TAG-altcoins $DOCKERHUB_REPO:$LATEST_TAG-altcoins-arm32v7 --os linux --arch arm --variant v7 + sudo docker manifest annotate $DOCKERHUB_REPO:$LATEST_TAG-altcoins $DOCKERHUB_REPO:$LATEST_TAG-altcoins-arm64v8 --os linux --arch arm64 --variant v8 + sudo docker manifest push $DOCKERHUB_REPO:$LATEST_TAG-altcoins -p workflows: version: 2 diff --git a/BTCPayServer.Client/BTCPayServer.Client.csproj b/BTCPayServer.Client/BTCPayServer.Client.csproj index b3cd8c197..2c029e00b 100644 --- a/BTCPayServer.Client/BTCPayServer.Client.csproj +++ b/BTCPayServer.Client/BTCPayServer.Client.csproj @@ -2,6 +2,8 @@ netstandard2.1 + Debug;Release;Altcoins-Release + AnyCPU diff --git a/BTCPayServer.Common/Altcoins/BTCPayNetworkProvider.cs b/BTCPayServer.Common/Altcoins/BTCPayNetworkProvider.cs index 5b8e7c2a6..5bc01bcd8 100644 --- a/BTCPayServer.Common/Altcoins/BTCPayNetworkProvider.cs +++ b/BTCPayServer.Common/Altcoins/BTCPayNetworkProvider.cs @@ -45,6 +45,7 @@ namespace BTCPayServer _NBXplorerNetworkProvider = new NBXplorerNetworkProvider(networkType); NetworkType = networkType; InitBitcoin(); +#if ALTCOINS_RELEASE || DEBUG InitLiquid(); InitLiquidAssets(); InitLitecoin(); @@ -80,6 +81,7 @@ namespace BTCPayServer // Disabled because of https://twitter.com/Cryptopia_NZ/status/1085084168852291586 //InitBitcoinplus(); //InitUfo(); +#endif } /// diff --git a/BTCPayServer.Common/Altcoins/Liquid/BTCPayNetworkProvider.Liquid.cs b/BTCPayServer.Common/Altcoins/Liquid/BTCPayNetworkProvider.Liquid.cs index bef65cd3f..15e880166 100644 --- a/BTCPayServer.Common/Altcoins/Liquid/BTCPayNetworkProvider.Liquid.cs +++ b/BTCPayServer.Common/Altcoins/Liquid/BTCPayNetworkProvider.Liquid.cs @@ -1,3 +1,4 @@ +#if ALTCOINS_RELEASE || DEBUG using NBitcoin; using NBitcoin.Altcoins; using NBitcoin.Altcoins.Elements; @@ -34,3 +35,4 @@ namespace BTCPayServer } +#endif diff --git a/BTCPayServer.Common/Altcoins/Liquid/BTCPayNetworkProvider.LiquidAssets.cs b/BTCPayServer.Common/Altcoins/Liquid/BTCPayNetworkProvider.LiquidAssets.cs index a14c49c2b..cd340f79e 100644 --- a/BTCPayServer.Common/Altcoins/Liquid/BTCPayNetworkProvider.LiquidAssets.cs +++ b/BTCPayServer.Common/Altcoins/Liquid/BTCPayNetworkProvider.LiquidAssets.cs @@ -1,3 +1,4 @@ +#if ALTCOINS_RELEASE || DEBUG using NBitcoin; namespace BTCPayServer @@ -81,3 +82,4 @@ namespace BTCPayServer } +#endif diff --git a/BTCPayServer.Common/Altcoins/Liquid/ElementsLikeBtcPayNetwork.cs b/BTCPayServer.Common/Altcoins/Liquid/ElementsLikeBtcPayNetwork.cs index 47321e83f..638871a3d 100644 --- a/BTCPayServer.Common/Altcoins/Liquid/ElementsLikeBtcPayNetwork.cs +++ b/BTCPayServer.Common/Altcoins/Liquid/ElementsLikeBtcPayNetwork.cs @@ -1,3 +1,4 @@ +#if ALTCOINS_RELEASE || DEBUG using System.Collections.Generic; using System.Linq; using NBitcoin; @@ -58,3 +59,4 @@ namespace BTCPayServer } } } +#endif diff --git a/BTCPayServer.Common/Altcoins/Liquid/LiquidExtensions.cs b/BTCPayServer.Common/Altcoins/Liquid/LiquidExtensions.cs new file mode 100644 index 000000000..d04a5ab3e --- /dev/null +++ b/BTCPayServer.Common/Altcoins/Liquid/LiquidExtensions.cs @@ -0,0 +1,18 @@ +#if ALTCOINS_RELEASE || DEBUG +using System.Collections.Generic; +using System.Linq; + +namespace BTCPayServer +{ + public static class LiquidExtensions + { + public static IEnumerable GetAllElementsSubChains(this BTCPayNetworkProvider networkProvider) + { + var elementsBased = networkProvider.GetAll().OfType(); + var parentChains = elementsBased.Select(network => network.NetworkCryptoCode.ToUpperInvariant()).Distinct(); + return networkProvider.UnfilteredNetworks.GetAll().OfType() + .Where(network => parentChains.Contains(network.NetworkCryptoCode)).Select(network => network.CryptoCode.ToUpperInvariant()); + } + } +} +#endif diff --git a/BTCPayServer.Common/BTCPayServer.Common.csproj b/BTCPayServer.Common/BTCPayServer.Common.csproj index 6293fed52..ac5dbb4b5 100644 --- a/BTCPayServer.Common/BTCPayServer.Common.csproj +++ b/BTCPayServer.Common/BTCPayServer.Common.csproj @@ -1,4 +1,8 @@  + + Debug;Release;Altcoins-Release + AnyCPU + diff --git a/BTCPayServer.Data/BTCPayServer.Data.csproj b/BTCPayServer.Data/BTCPayServer.Data.csproj index 7436b550d..8efacebc6 100644 --- a/BTCPayServer.Data/BTCPayServer.Data.csproj +++ b/BTCPayServer.Data/BTCPayServer.Data.csproj @@ -1,4 +1,8 @@  + + Debug;Release;Altcoins-Release + AnyCPU + diff --git a/BTCPayServer.Rating/BTCPayServer.Rating.csproj b/BTCPayServer.Rating/BTCPayServer.Rating.csproj index 9ceef4b02..1760d9ed2 100644 --- a/BTCPayServer.Rating/BTCPayServer.Rating.csproj +++ b/BTCPayServer.Rating/BTCPayServer.Rating.csproj @@ -1,4 +1,8 @@  + + Debug;Release;Altcoins-Release + AnyCPU + diff --git a/BTCPayServer.Tests/BTCPayServer.Tests.csproj b/BTCPayServer.Tests/BTCPayServer.Tests.csproj index db839de1b..f7c1345ce 100644 --- a/BTCPayServer.Tests/BTCPayServer.Tests.csproj +++ b/BTCPayServer.Tests/BTCPayServer.Tests.csproj @@ -9,6 +9,8 @@ AB0AC1DD-9D26-485B-9416-56A33F268117 true + Debug;Release;Altcoins-Release + AnyCPU diff --git a/BTCPayServer/BTCPayServer.csproj b/BTCPayServer/BTCPayServer.csproj index 41730078f..46abdb977 100644 --- a/BTCPayServer/BTCPayServer.csproj +++ b/BTCPayServer/BTCPayServer.csproj @@ -5,8 +5,12 @@ false $(DefineConstants);RAZOR_RUNTIME_COMPILE + + Exe + Debug;Release;Altcoins-Release + AnyCPU @@ -21,6 +25,10 @@ + + true + PreserveNewest + @@ -28,6 +36,22 @@ + + + + + + + + + + + + + + + + diff --git a/BTCPayServer/Configuration/BTCPayServerOptions.cs b/BTCPayServer/Configuration/BTCPayServerOptions.cs index b596bb90d..4099a13b8 100644 --- a/BTCPayServer/Configuration/BTCPayServerOptions.cs +++ b/BTCPayServer/Configuration/BTCPayServerOptions.cs @@ -90,11 +90,9 @@ namespace BTCPayServer.Configuration var networkProvider = new BTCPayNetworkProvider(NetworkType); var filtered = networkProvider.Filter(supportedChains.ToArray()); - var elementsBased = filtered.GetAll().OfType(); - var parentChains = elementsBased.Select(network => network.NetworkCryptoCode.ToUpperInvariant()).Distinct(); - var allSubChains = networkProvider.GetAll().OfType() - .Where(network => parentChains.Contains(network.NetworkCryptoCode)).Select(network => network.CryptoCode.ToUpperInvariant()); - supportedChains.AddRange(allSubChains); +#if ALTCOINS_RELEASE || DEBUG + supportedChains.AddRange(filtered.GetAllElementsSubChains()); +#endif NetworkProvider = networkProvider.Filter(supportedChains.ToArray()); foreach (var chain in supportedChains) { diff --git a/BTCPayServer/Contracts/ISyncSummaryProvider.cs b/BTCPayServer/Contracts/ISyncSummaryProvider.cs new file mode 100644 index 000000000..44cdc918c --- /dev/null +++ b/BTCPayServer/Contracts/ISyncSummaryProvider.cs @@ -0,0 +1,10 @@ +namespace BTCPayServer.Contracts +{ + public interface ISyncSummaryProvider + { + bool AllAvailable(); + + string Partial { get; } + } + +} diff --git a/BTCPayServer/Controllers/StoresController.cs b/BTCPayServer/Controllers/StoresController.cs index a55965bb5..a4eec2e6f 100644 --- a/BTCPayServer/Controllers/StoresController.cs +++ b/BTCPayServer/Controllers/StoresController.cs @@ -520,7 +520,9 @@ namespace BTCPayServer.Controllers Value = value, WalletId = new WalletId(store.Id, paymentMethodId.CryptoCode), Enabled = !excludeFilters.Match(paymentMethodId) && strategy != null, +#if ALTCOINS_RELEASE || DEBUG Collapsed = network is ElementsBTCPayNetwork elementsBTCPayNetwork && elementsBTCPayNetwork.NetworkCryptoCode != elementsBTCPayNetwork.CryptoCode && string.IsNullOrEmpty(value) +#endif }); break; case LightningPaymentType _: diff --git a/BTCPayServer/Extensions/MoneyExtensions.cs b/BTCPayServer/Extensions/MoneyExtensions.cs index 736975d12..b8bac5a1c 100644 --- a/BTCPayServer/Extensions/MoneyExtensions.cs +++ b/BTCPayServer/Extensions/MoneyExtensions.cs @@ -16,6 +16,7 @@ namespace BTCPayServer return money.ToDecimal(MoneyUnit.BTC); case MoneyBag mb: return mb.Select(money => money.GetValue(network)).Sum(); +#if ALTCOINS_RELEASE || DEBUG case AssetMoney assetMoney: if (network is ElementsBTCPayNetwork elementsBTCPayNetwork) { @@ -24,6 +25,7 @@ namespace BTCPayServer : 0; } throw new NotSupportedException("IMoney type not supported"); +#endif default: throw new NotSupportedException("IMoney type not supported"); } diff --git a/BTCPayServer/Hosting/BTCPayServerServices.cs b/BTCPayServer/Hosting/BTCPayServerServices.cs index 99bed5819..33a65eec6 100644 --- a/BTCPayServer/Hosting/BTCPayServerServices.cs +++ b/BTCPayServer/Hosting/BTCPayServerServices.cs @@ -2,6 +2,7 @@ using System; using System.IO; using System.Threading; using BTCPayServer.Configuration; +using BTCPayServer.Contracts; using BTCPayServer.Controllers; using BTCPayServer.Data; using BTCPayServer.HostedServices; @@ -16,7 +17,6 @@ using BTCPayServer.Security; using BTCPayServer.Security.Bitpay; using BTCPayServer.Security.GreenField; using BTCPayServer.Services; -using BTCPayServer.Services.Altcoins.Monero; using BTCPayServer.Services.Apps; using BTCPayServer.Services.Fees; using BTCPayServer.Services.Invoices; @@ -47,7 +47,9 @@ using NBXplorer.DerivationStrategy; using Newtonsoft.Json; using NicolasDorier.RateLimits; using Serilog; - +#if ALTCOINS_RELEASE || DEBUG +using BTCPayServer.Services.Altcoins.Monero; +#endif namespace BTCPayServer.Hosting { public static class BTCPayServerServices @@ -75,7 +77,9 @@ namespace BTCPayServer.Hosting services.RegisterJsonConverter(n => new ClaimDestinationJsonConverter(n)); services.AddPayJoinServices(); +#if ALTCOINS_RELEASE || DEBUG services.AddMoneroLike(); +#endif services.TryAddSingleton(); services.TryAddSingleton(); services.TryAddSingleton(); @@ -177,6 +181,7 @@ namespace BTCPayServer.Hosting services.TryAddSingleton(); services.TryAddSingleton(); services.TryAddSingleton(); + services.TryAddSingleton(); services.TryAddSingleton(); services.TryAddSingleton(); services.TryAddSingleton(); diff --git a/BTCPayServer/Payments/PaymentTypes.cs b/BTCPayServer/Payments/PaymentTypes.cs index 352b67dd7..2032bfe19 100644 --- a/BTCPayServer/Payments/PaymentTypes.cs +++ b/BTCPayServer/Payments/PaymentTypes.cs @@ -1,5 +1,7 @@ using System; +#if ALTCOINS_RELEASE || DEBUG using BTCPayServer.Services.Altcoins.Monero.Payments; +#endif using BTCPayServer.Services.Invoices; using Newtonsoft.Json.Linq; @@ -31,9 +33,11 @@ namespace BTCPayServer.Payments case "offchain": type = PaymentTypes.LightningLike; break; +#if ALTCOINS_RELEASE || DEBUG case "monerolike": type = MoneroPaymentType.Instance; break; +#endif default: type = null; return false; diff --git a/BTCPayServer/Services/Altcoins/Monero/Configuration/MoneroLikeConfiguration.cs b/BTCPayServer/Services/Altcoins/Monero/Configuration/MoneroLikeConfiguration.cs index 3d6a60a35..2837b2100 100644 --- a/BTCPayServer/Services/Altcoins/Monero/Configuration/MoneroLikeConfiguration.cs +++ b/BTCPayServer/Services/Altcoins/Monero/Configuration/MoneroLikeConfiguration.cs @@ -1,3 +1,4 @@ +#if ALTCOINS_RELEASE || DEBUG using System; using System.Collections.Generic; @@ -16,3 +17,4 @@ namespace BTCPayServer.Services.Altcoins.Monero.Configuration public string WalletDirectory { get; set; } } } +#endif diff --git a/BTCPayServer/Services/Altcoins/Monero/MoneroLikeExtensions.cs b/BTCPayServer/Services/Altcoins/Monero/MoneroLikeExtensions.cs index b8926a728..952730e00 100644 --- a/BTCPayServer/Services/Altcoins/Monero/MoneroLikeExtensions.cs +++ b/BTCPayServer/Services/Altcoins/Monero/MoneroLikeExtensions.cs @@ -1,3 +1,4 @@ +#if ALTCOINS_RELEASE || DEBUG using System; using System.Linq; using BTCPayServer.Configuration; @@ -23,6 +24,7 @@ namespace BTCPayServer.Services.Altcoins.Monero serviceCollection.AddSingleton(); serviceCollection.AddSingleton(provider => provider.GetService()); serviceCollection.AddSingleton(); + serviceCollection.AddSingleton(); return serviceCollection; } @@ -67,3 +69,4 @@ namespace BTCPayServer.Services.Altcoins.Monero } } } +#endif diff --git a/BTCPayServer/Services/Altcoins/Monero/MoneroStoreNavExtension.cs b/BTCPayServer/Services/Altcoins/Monero/MoneroStoreNavExtension.cs index c0f9ff3c7..9ed33a997 100644 --- a/BTCPayServer/Services/Altcoins/Monero/MoneroStoreNavExtension.cs +++ b/BTCPayServer/Services/Altcoins/Monero/MoneroStoreNavExtension.cs @@ -1,3 +1,4 @@ +#if ALTCOINS_RELEASE || DEBUG using BTCPayServer.Contracts; namespace BTCPayServer.Services.Altcoins.Monero @@ -7,3 +8,4 @@ namespace BTCPayServer.Services.Altcoins.Monero public string Partial { get; } = "Monero/StoreNavMoneroExtension"; } } +#endif diff --git a/BTCPayServer/Services/Altcoins/Monero/Payments/MoneroLikeOnChainPaymentMethodDetails.cs b/BTCPayServer/Services/Altcoins/Monero/Payments/MoneroLikeOnChainPaymentMethodDetails.cs index 5c343a10e..2e311e0f5 100644 --- a/BTCPayServer/Services/Altcoins/Monero/Payments/MoneroLikeOnChainPaymentMethodDetails.cs +++ b/BTCPayServer/Services/Altcoins/Monero/Payments/MoneroLikeOnChainPaymentMethodDetails.cs @@ -1,3 +1,4 @@ +#if ALTCOINS_RELEASE || DEBUG using BTCPayServer.Payments; namespace BTCPayServer.Services.Altcoins.Monero.Payments @@ -34,3 +35,4 @@ namespace BTCPayServer.Services.Altcoins.Monero.Payments public decimal NextNetworkFee { get; set; } } } +#endif diff --git a/BTCPayServer/Services/Altcoins/Monero/Payments/MoneroLikePaymentData.cs b/BTCPayServer/Services/Altcoins/Monero/Payments/MoneroLikePaymentData.cs index d12a88f2a..ebabf5720 100644 --- a/BTCPayServer/Services/Altcoins/Monero/Payments/MoneroLikePaymentData.cs +++ b/BTCPayServer/Services/Altcoins/Monero/Payments/MoneroLikePaymentData.cs @@ -1,3 +1,4 @@ +#if ALTCOINS_RELEASE || DEBUG using BTCPayServer.Client.Models; using BTCPayServer.Payments; using BTCPayServer.Services.Altcoins.Monero.Utils; @@ -65,3 +66,4 @@ namespace BTCPayServer.Services.Altcoins.Monero.Payments } } } +#endif diff --git a/BTCPayServer/Services/Altcoins/Monero/Payments/MoneroLikePaymentMethodHandler.cs b/BTCPayServer/Services/Altcoins/Monero/Payments/MoneroLikePaymentMethodHandler.cs index 5815bfb18..8ef3df9df 100644 --- a/BTCPayServer/Services/Altcoins/Monero/Payments/MoneroLikePaymentMethodHandler.cs +++ b/BTCPayServer/Services/Altcoins/Monero/Payments/MoneroLikePaymentMethodHandler.cs @@ -1,3 +1,4 @@ +#if ALTCOINS_RELEASE || DEBUG using System; using System.Collections.Generic; using System.Globalization; @@ -128,3 +129,4 @@ namespace BTCPayServer.Services.Altcoins.Monero.Payments } } } +#endif diff --git a/BTCPayServer/Services/Altcoins/Monero/Payments/MoneroPaymentType.cs b/BTCPayServer/Services/Altcoins/Monero/Payments/MoneroPaymentType.cs index 06df200f8..dd5581a55 100644 --- a/BTCPayServer/Services/Altcoins/Monero/Payments/MoneroPaymentType.cs +++ b/BTCPayServer/Services/Altcoins/Monero/Payments/MoneroPaymentType.cs @@ -1,3 +1,4 @@ +#if ALTCOINS_RELEASE || DEBUG using System.Globalization; using BTCPayServer.Payments; using BTCPayServer.Services.Invoices; @@ -47,3 +48,4 @@ namespace BTCPayServer.Services.Altcoins.Monero.Payments public override string InvoiceViewPaymentPartialName { get; } = "Monero/ViewMoneroLikePaymentData"; } } +#endif diff --git a/BTCPayServer/Services/Altcoins/Monero/Payments/MoneroSupportedPaymentMethod.cs b/BTCPayServer/Services/Altcoins/Monero/Payments/MoneroSupportedPaymentMethod.cs index 8790ec0d4..1e534b1d3 100644 --- a/BTCPayServer/Services/Altcoins/Monero/Payments/MoneroSupportedPaymentMethod.cs +++ b/BTCPayServer/Services/Altcoins/Monero/Payments/MoneroSupportedPaymentMethod.cs @@ -1,3 +1,4 @@ +#if ALTCOINS_RELEASE || DEBUG using BTCPayServer.Payments; namespace BTCPayServer.Services.Altcoins.Monero.Payments @@ -10,3 +11,4 @@ namespace BTCPayServer.Services.Altcoins.Monero.Payments public PaymentMethodId PaymentId => new PaymentMethodId(CryptoCode, MoneroPaymentType.Instance); } } +#endif diff --git a/BTCPayServer/Services/Altcoins/Monero/RPC/MoneroDaemonCallbackController.cs b/BTCPayServer/Services/Altcoins/Monero/RPC/MoneroDaemonCallbackController.cs index 9db2d24e3..4a4dd940b 100644 --- a/BTCPayServer/Services/Altcoins/Monero/RPC/MoneroDaemonCallbackController.cs +++ b/BTCPayServer/Services/Altcoins/Monero/RPC/MoneroDaemonCallbackController.cs @@ -1,3 +1,4 @@ +#if ALTCOINS_RELEASE || DEBUG using BTCPayServer.Filters; using Microsoft.AspNetCore.Mvc; @@ -36,3 +37,4 @@ namespace BTCPayServer.Services.Altcoins.Monero.RPC } } +#endif diff --git a/BTCPayServer/Services/Altcoins/Monero/RPC/MoneroEvent.cs b/BTCPayServer/Services/Altcoins/Monero/RPC/MoneroEvent.cs index 4821730ec..a56197f28 100644 --- a/BTCPayServer/Services/Altcoins/Monero/RPC/MoneroEvent.cs +++ b/BTCPayServer/Services/Altcoins/Monero/RPC/MoneroEvent.cs @@ -1,3 +1,4 @@ +#if ALTCOINS_RELEASE || DEBUG namespace BTCPayServer.Services.Altcoins.Monero.RPC { public class MoneroEvent @@ -13,3 +14,4 @@ namespace BTCPayServer.Services.Altcoins.Monero.RPC } } } +#endif diff --git a/BTCPayServer/Services/Altcoins/Monero/Services/MoneroLikeSummaryUpdaterHostedService.cs b/BTCPayServer/Services/Altcoins/Monero/Services/MoneroLikeSummaryUpdaterHostedService.cs index 5bdd511a6..5336c3efd 100644 --- a/BTCPayServer/Services/Altcoins/Monero/Services/MoneroLikeSummaryUpdaterHostedService.cs +++ b/BTCPayServer/Services/Altcoins/Monero/Services/MoneroLikeSummaryUpdaterHostedService.cs @@ -1,3 +1,4 @@ +#if ALTCOINS_RELEASE || DEBUG using System; using System.Threading; using System.Threading.Tasks; @@ -64,3 +65,4 @@ namespace BTCPayServer.Services.Altcoins.Monero.Services } } } +#endif diff --git a/BTCPayServer/Services/Altcoins/Monero/Services/MoneroListener.cs b/BTCPayServer/Services/Altcoins/Monero/Services/MoneroListener.cs index 8f3bbca69..cc4a00f76 100644 --- a/BTCPayServer/Services/Altcoins/Monero/Services/MoneroListener.cs +++ b/BTCPayServer/Services/Altcoins/Monero/Services/MoneroListener.cs @@ -1,3 +1,4 @@ +#if ALTCOINS_RELEASE || DEBUG using System; using System.Collections.Concurrent; using System.Collections.Generic; @@ -374,3 +375,4 @@ namespace BTCPayServer.Services.Altcoins.Monero.Services } } } +#endif diff --git a/BTCPayServer/Services/Altcoins/Monero/Services/MoneroRPCProvider.cs b/BTCPayServer/Services/Altcoins/Monero/Services/MoneroRPCProvider.cs index 63552dfef..e25ed5010 100644 --- a/BTCPayServer/Services/Altcoins/Monero/Services/MoneroRPCProvider.cs +++ b/BTCPayServer/Services/Altcoins/Monero/Services/MoneroRPCProvider.cs @@ -1,3 +1,4 @@ +#if ALTCOINS_RELEASE || DEBUG using System; using System.Collections.Concurrent; using System.Collections.Immutable; @@ -117,3 +118,4 @@ namespace BTCPayServer.Services.Altcoins.Monero.Services } } } +#endif diff --git a/BTCPayServer/Services/Altcoins/Monero/Services/MoneroSyncSummaryProvider.cs b/BTCPayServer/Services/Altcoins/Monero/Services/MoneroSyncSummaryProvider.cs new file mode 100644 index 000000000..7118e87b9 --- /dev/null +++ b/BTCPayServer/Services/Altcoins/Monero/Services/MoneroSyncSummaryProvider.cs @@ -0,0 +1,24 @@ +#if ALTCOINS_RELEASE || DEBUG +using System.Linq; +using BTCPayServer.Contracts; + +namespace BTCPayServer.Services.Altcoins.Monero.Services +{ + public class MoneroSyncSummaryProvider : ISyncSummaryProvider + { + private readonly MoneroRPCProvider _moneroRpcProvider; + + public MoneroSyncSummaryProvider(MoneroRPCProvider moneroRpcProvider) + { + _moneroRpcProvider = moneroRpcProvider; + } + + public bool AllAvailable() + { + return _moneroRpcProvider.Summaries.All(pair => pair.Value.WalletAvailable); + } + + public string Partial { get; } = "Monero/MoneroSyncSummary"; + } +} +#endif diff --git a/BTCPayServer/Services/Altcoins/Monero/UI/MoneroLikeStoreController.cs b/BTCPayServer/Services/Altcoins/Monero/UI/MoneroLikeStoreController.cs index 697aaa7fc..70ee0ac97 100644 --- a/BTCPayServer/Services/Altcoins/Monero/UI/MoneroLikeStoreController.cs +++ b/BTCPayServer/Services/Altcoins/Monero/UI/MoneroLikeStoreController.cs @@ -1,3 +1,4 @@ +#if ALTCOINS_RELEASE || DEBUG using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; @@ -302,3 +303,4 @@ namespace BTCPayServer.Services.Altcoins.Monero.UI } } } +#endif diff --git a/BTCPayServer/Services/Altcoins/Monero/UI/MoneroPaymentViewModel.cs b/BTCPayServer/Services/Altcoins/Monero/UI/MoneroPaymentViewModel.cs index 5b1f0ac82..0eda72133 100644 --- a/BTCPayServer/Services/Altcoins/Monero/UI/MoneroPaymentViewModel.cs +++ b/BTCPayServer/Services/Altcoins/Monero/UI/MoneroPaymentViewModel.cs @@ -1,3 +1,4 @@ +#if ALTCOINS_RELEASE || DEBUG using System; namespace BTCPayServer.Services.Altcoins.Monero.UI @@ -13,3 +14,4 @@ namespace BTCPayServer.Services.Altcoins.Monero.UI public string TransactionLink { get; set; } } } +#endif diff --git a/BTCPayServer/Services/NBXSyncSummaryProvider.cs b/BTCPayServer/Services/NBXSyncSummaryProvider.cs new file mode 100644 index 000000000..32d4451af --- /dev/null +++ b/BTCPayServer/Services/NBXSyncSummaryProvider.cs @@ -0,0 +1,22 @@ +using BTCPayServer.Contracts; +using BTCPayServer.HostedServices; + +namespace BTCPayServer.Services +{ + public class NBXSyncSummaryProvider : ISyncSummaryProvider + { + private readonly NBXplorerDashboard _nbXplorerDashboard; + + public NBXSyncSummaryProvider(NBXplorerDashboard nbXplorerDashboard) + { + _nbXplorerDashboard = nbXplorerDashboard; + } + + public bool AllAvailable() + { + return _nbXplorerDashboard.IsFullySynched(); + } + + public string Partial { get; } = "NBXSyncSummary"; + } +} diff --git a/BTCPayServer/Views/Shared/LayoutPartials/SyncModal.cshtml b/BTCPayServer/Views/Shared/LayoutPartials/SyncModal.cshtml index 8315623b7..5c5102200 100644 --- a/BTCPayServer/Views/Shared/LayoutPartials/SyncModal.cshtml +++ b/BTCPayServer/Views/Shared/LayoutPartials/SyncModal.cshtml @@ -1,7 +1,6 @@ -@using BTCPayServer.Services.Altcoins.Monero.Services -@inject BTCPayServer.HostedServices.NBXplorerDashboard dashboard -@inject MoneroRPCProvider MoneroRpcProvider -@if (!dashboard.IsFullySynched() || !MoneroRpcProvider.Summaries.All(pair => pair.Value.WalletAvailable)) +@using BTCPayServer.Contracts +@inject IEnumerable SyncSummaryProviders; +@if(SyncSummaryProviders.Any(provider => !provider.AllAvailable())) { -