Do not register services of altcoins if not used

This commit is contained in:
nicolas.dorier 2022-02-10 12:35:21 +09:00
parent 3fa694c65f
commit 9e2f7fb048
No known key found for this signature in database
GPG Key ID: 6618763EF09186FE
2 changed files with 10 additions and 1 deletions

View File

@ -492,6 +492,14 @@ namespace BTCPayServer
ctx.Items["BTCPAY.APPDATA"] = appData;
}
public static bool SupportChain(this IConfiguration conf, string cryptoCode)
{
var supportedChains = conf.GetOrDefault<string>("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

View File

@ -88,7 +88,8 @@ namespace BTCPayServer.Hosting
services.AddPayJoinServices();
#if ALTCOINS
services.AddMoneroLike();
if (configuration.SupportChain("xmr"))
services.AddMoneroLike();
#endif
services.TryAddSingleton<SettingsRepository>();
services.TryAddSingleton<ISettingsRepository>(provider => provider.GetService<SettingsRepository>());