mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2024-11-19 18:11:36 +01:00
4063a5aaee
* Quality of life improvements to payout processors * Allows more fleixble intervals for payout processing from 10-60 mins to 1min-24hours(requested by users) * Cancel ln payotus that expired (bolt11) * Allow cancelling of ln payotus that have failed to be paid after x attempts * Allow conifguring a threshold for when to process on-chain payouts (reduces fees) # Conflicts: # BTCPayServer.Tests/SeleniumTests.cs * Simplify the code * switch to concurrent dictionary * Allow ProcessNewPayoutsInstantly * refactor plugin hook service to have events available and change processor hooks to actions with better args * add procesor extended tests * Update BTCPayServer.Tests/GreenfieldAPITests.cs * fix concurrency issue * Update BTCPayServer/PayoutProcessors/BaseAutomatedPayoutProcessor.cs --------- Co-authored-by: nicolas.dorier <nicolas.dorier@gmail.com>
60 lines
2.2 KiB
C#
60 lines
2.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using BTCPayServer.Data;
|
|
using BTCPayServer.Payments;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Routing;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
namespace BTCPayServer.PayoutProcessors.Lightning;
|
|
|
|
public class LightningAutomatedPayoutSenderFactory : IPayoutProcessorFactory
|
|
{
|
|
private readonly BTCPayNetworkProvider _btcPayNetworkProvider;
|
|
private readonly IServiceProvider _serviceProvider;
|
|
private readonly LinkGenerator _linkGenerator;
|
|
|
|
|
|
public LightningAutomatedPayoutSenderFactory(BTCPayNetworkProvider btcPayNetworkProvider, IServiceProvider serviceProvider, LinkGenerator linkGenerator)
|
|
{
|
|
_btcPayNetworkProvider = btcPayNetworkProvider;
|
|
_serviceProvider = serviceProvider;
|
|
_linkGenerator = linkGenerator;
|
|
}
|
|
|
|
public string FriendlyName { get; } = "Automated Lightning Sender";
|
|
|
|
public string ConfigureLink(string storeId, PaymentMethodId paymentMethodId, HttpRequest request)
|
|
{
|
|
return _linkGenerator.GetUriByAction("Configure",
|
|
"UILightningAutomatedPayoutProcessors", new
|
|
{
|
|
storeId,
|
|
cryptoCode = paymentMethodId.CryptoCode
|
|
}, request.Scheme, request.Host, request.PathBase);
|
|
}
|
|
public string Processor => ProcessorName;
|
|
public static string ProcessorName => nameof(LightningAutomatedPayoutSenderFactory);
|
|
public IEnumerable<PaymentMethodId> GetSupportedPaymentMethods()
|
|
{
|
|
return _btcPayNetworkProvider.GetAll().OfType<BTCPayNetwork>()
|
|
.Where(network => network.SupportLightning)
|
|
.Select(network =>
|
|
new PaymentMethodId(network.CryptoCode, LightningPaymentType.Instance));
|
|
}
|
|
|
|
public Task<IHostedService> ConstructProcessor(PayoutProcessorData settings)
|
|
{
|
|
if (settings.Processor != Processor)
|
|
{
|
|
throw new NotSupportedException("This processor cannot handle the provided requirements");
|
|
}
|
|
|
|
return Task.FromResult<IHostedService>(ActivatorUtilities.CreateInstance<LightningAutomatedPayoutProcessor>(_serviceProvider, settings));
|
|
|
|
}
|
|
}
|