From 9e2f7fb048773bae00672dd60738fe4f034fc444 Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Thu, 10 Feb 2022 12:35:21 +0900 Subject: [PATCH] Do not register services of altcoins if not used --- BTCPayServer/Extensions.cs | 8 ++++++++ BTCPayServer/Hosting/BTCPayServerServices.cs | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/BTCPayServer/Extensions.cs b/BTCPayServer/Extensions.cs index 93a2f0ee5..282eed2f3 100644 --- a/BTCPayServer/Extensions.cs +++ b/BTCPayServer/Extensions.cs @@ -492,6 +492,14 @@ namespace BTCPayServer ctx.Items["BTCPAY.APPDATA"] = appData; } + public static bool SupportChain(this IConfiguration conf, string cryptoCode) + { + var supportedChains = conf.GetOrDefault("chains", "btc") + .Split(',', StringSplitOptions.RemoveEmptyEntries) + .Select(t => t.ToUpperInvariant()).ToHashSet(); + return supportedChains.Contains(cryptoCode.ToUpperInvariant()); + } + public static IActionResult RedirectToRecoverySeedBackup(this Controller controller, RecoverySeedBackupViewModel vm) { var redirectVm = new PostRedirectViewModel diff --git a/BTCPayServer/Hosting/BTCPayServerServices.cs b/BTCPayServer/Hosting/BTCPayServerServices.cs index cbab06e73..51ec9da7f 100644 --- a/BTCPayServer/Hosting/BTCPayServerServices.cs +++ b/BTCPayServer/Hosting/BTCPayServerServices.cs @@ -88,7 +88,8 @@ namespace BTCPayServer.Hosting services.AddPayJoinServices(); #if ALTCOINS - services.AddMoneroLike(); + if (configuration.SupportChain("xmr")) + services.AddMoneroLike(); #endif services.TryAddSingleton(); services.TryAddSingleton(provider => provider.GetService());