mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-01-18 21:32:27 +01:00
Support LN connection string with onion http client (#3845)
I'm not sure if onion based ln conenction strings ever worked in btcpay? closes #1648
This commit is contained in:
parent
9a24e4ade1
commit
4a0f10ea99
@ -107,6 +107,8 @@ namespace BTCPayServer.Hosting
|
||||
services.AddSingleton<ISwaggerProvider, DefaultSwaggerProvider>();
|
||||
services.TryAddSingleton<SocketFactory>();
|
||||
services.TryAddSingleton<LightningClientFactoryService>();
|
||||
services.AddHttpClient(LightningClientFactoryService.OnionNamedClient)
|
||||
.ConfigurePrimaryHttpMessageHandler<Socks5HttpClientHandler>();
|
||||
services.TryAddSingleton<InvoicePaymentNotification>();
|
||||
services.TryAddSingleton<BTCPayServerOptions>(o =>
|
||||
o.GetRequiredService<IOptions<BTCPayServerOptions>>().Value);
|
||||
|
@ -13,13 +13,18 @@ namespace BTCPayServer.Services
|
||||
_httpClientFactory = httpClientFactory;
|
||||
}
|
||||
|
||||
public static string OnionNamedClient { get; set; } = "lightning.onion";
|
||||
|
||||
public ILightningClient Create(LightningConnectionString lightningConnectionString, BTCPayNetwork network)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(lightningConnectionString);
|
||||
ArgumentNullException.ThrowIfNull(network);
|
||||
return new Lightning.LightningClientFactory(network.NBitcoinNetwork)
|
||||
|
||||
return new LightningClientFactory(network.NBitcoinNetwork)
|
||||
{
|
||||
HttpClient = _httpClientFactory.CreateClient($"{network.CryptoCode}: Lightning client")
|
||||
HttpClient = _httpClientFactory.CreateClient(lightningConnectionString.BaseUri.IsOnion()
|
||||
? OnionNamedClient
|
||||
: $"{network.CryptoCode}: Lightning client")
|
||||
}.Create(lightningConnectionString);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user