btcpayserver/BTCPayServer/Services/Altcoins/Ethereum/EthereumLikeExtensions.cs
XPayServer de755ac0bb Add Ethereum & ERC20 Support
Add Tests
Add Index, XPub to payment data
Add Note on local ETH node
Fix Sync Summary and Race Condition
2020-09-09 08:19:10 +02:00

41 lines
1.8 KiB
C#

#if ALTCOINS
using System.Net;
using System.Net.Http;
using BTCPayServer.Contracts;
using BTCPayServer.HostedServices;
using BTCPayServer.Payments;
using BTCPayServer.Services.Altcoins.Ethereum.Payments;
using BTCPayServer.Services.Altcoins.Ethereum.Services;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace BTCPayServer.Services.Altcoins.Ethereum
{
public static class EthereumLikeExtensions
{
public const string EthereumInvoiceCheckHttpClient = "EthereumCheck";
public const string EthereumInvoiceCreateHttpClient = "EthereumCreate";
public static IServiceCollection AddEthereumLike(this IServiceCollection serviceCollection)
{
serviceCollection.AddSingleton<EthereumService>();
serviceCollection.AddSingleton<IHostedService, EthereumService>(provider => provider.GetService<EthereumService>());
serviceCollection.AddSingleton<EthereumLikePaymentMethodHandler>();
serviceCollection.AddSingleton<IPaymentMethodHandler>(provider => provider.GetService<EthereumLikePaymentMethodHandler>());
serviceCollection.AddSingleton<IStoreNavExtension, EthereumStoreNavExtension>();
serviceCollection.AddTransient<NoRedirectHttpClientHandler>();
serviceCollection.AddSingleton<ISyncSummaryProvider, EthereumSyncSummaryProvider>();
serviceCollection.AddHttpClient(EthereumInvoiceCreateHttpClient)
.ConfigurePrimaryHttpMessageHandler<NoRedirectHttpClientHandler>();
return serviceCollection;
}
}
public class NoRedirectHttpClientHandler : HttpClientHandler
{
public NoRedirectHttpClientHandler()
{
this.AllowAutoRedirect = false;
}
}
}
#endif