btcpayserver/BTCPayServer/Payments/PayJoin/PayJoinExtensions.cs

28 lines
1.3 KiB
C#
Raw Normal View History

2020-03-30 00:28:22 +09:00
using BTCPayServer.HostedServices;
using BTCPayServer.Payments.PayJoin.Sender;
2020-03-30 00:28:22 +09:00
using BTCPayServer.Services;
2020-01-06 13:57:32 +01:00
using Microsoft.Extensions.DependencyInjection;
2020-03-30 00:28:22 +09:00
using Microsoft.Extensions.Hosting;
using BTCPayServer.BIP78.Sender;
2020-01-06 13:57:32 +01:00
namespace BTCPayServer.Payments.PayJoin
{
public static class PayJoinExtensions
{
2020-03-30 00:28:22 +09:00
public static void AddPayJoinServices(this IServiceCollection services)
2020-01-06 13:57:32 +01:00
{
2020-03-30 00:28:22 +09:00
services.AddSingleton<DelayedTransactionBroadcaster>();
services.AddSingleton<IHostedService, HostedServices.DelayedTransactionBroadcasterHostedService>();
services.AddSingleton<HostedServices.Socks5HttpProxyServer>();
services.AddSingleton<IHostedService, HostedServices.Socks5HttpProxyServer>(s => s.GetRequiredService<Socks5HttpProxyServer>());
2020-03-30 00:28:22 +09:00
services.AddSingleton<PayJoinRepository>();
services.AddSingleton<IPayjoinServerCommunicator, PayjoinServerCommunicator>();
2020-03-30 00:28:22 +09:00
services.AddSingleton<PayjoinClient>();
services.AddTransient<Socks5HttpClientHandler>();
services.AddHttpClient(PayjoinServerCommunicator.PayjoinOnionNamedClient)
2020-11-13 14:01:51 +09:00
.ConfigureHttpClient(h => h.DefaultRequestHeaders.ConnectionClose = true)
.ConfigurePrimaryHttpMessageHandler<Socks5HttpClientHandler>();
2020-01-06 13:57:32 +01:00
}
}
}