mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2026-02-23 15:14:49 +01:00
@@ -1,6 +1,8 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using BTCPayServer.Client.Models;
|
||||
using BTCPayServer.Configuration;
|
||||
@@ -20,16 +22,19 @@ namespace BTCPayServer.Payments.Lightning
|
||||
private readonly BTCPayNetworkProvider _networkProvider;
|
||||
private readonly DisplayFormatter _displayFormatter;
|
||||
private readonly LightningLikePaymentHandler _lightningLikePaymentHandler;
|
||||
private readonly LightningClientFactoryService _lightningClientFactoryService;
|
||||
|
||||
public LNURLPayPaymentHandler(
|
||||
BTCPayNetworkProvider networkProvider,
|
||||
DisplayFormatter displayFormatter,
|
||||
IOptions<LightningNetworkOptions> options,
|
||||
LightningLikePaymentHandler lightningLikePaymentHandler)
|
||||
LightningLikePaymentHandler lightningLikePaymentHandler,
|
||||
LightningClientFactoryService lightningClientFactoryService)
|
||||
{
|
||||
_networkProvider = networkProvider;
|
||||
_displayFormatter = displayFormatter;
|
||||
_lightningLikePaymentHandler = lightningLikePaymentHandler;
|
||||
_lightningClientFactoryService = lightningClientFactoryService;
|
||||
Options = options;
|
||||
}
|
||||
|
||||
@@ -62,6 +67,16 @@ namespace BTCPayServer.Payments.Lightning
|
||||
{
|
||||
throw new PaymentMethodUnavailableException("LNURL requires a lightning node to be configured for the store.");
|
||||
}
|
||||
using var cts = new CancellationTokenSource(5000);
|
||||
try
|
||||
{
|
||||
var client = lnSupported.CreateLightningClient(network, Options.Value, _lightningClientFactoryService);
|
||||
await client.GetInfo(cts.Token);
|
||||
}
|
||||
catch (OperationCanceledException) when (cts.IsCancellationRequested)
|
||||
{
|
||||
throw new PaymentMethodUnavailableException("The lightning node did not reply in a timely manner");
|
||||
}
|
||||
|
||||
return new LNURLPayPaymentMethodDetails()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user