mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-22 06:21:44 +01:00
27 lines
1 KiB
C#
27 lines
1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using BTCPayServer.Payments.Lightning.Charge;
|
|
using BTCPayServer.Payments.Lightning.CLightning;
|
|
|
|
namespace BTCPayServer.Payments.Lightning
|
|
{
|
|
public class LightningClientFactory
|
|
{
|
|
public ILightningInvoiceClient CreateClient(LightningSupportedPaymentMethod supportedPaymentMethod, BTCPayNetwork network)
|
|
{
|
|
var uri = supportedPaymentMethod.GetLightningUrl();
|
|
if (uri.ConnectionType == LightningConnectionType.Charge)
|
|
{
|
|
return new ChargeClient(uri.ToUri(true), network.NBitcoinNetwork);
|
|
}
|
|
else if (uri.ConnectionType == LightningConnectionType.CLightning)
|
|
{
|
|
return new CLightningRPCClient(uri.ToUri(false), network.NBitcoinNetwork);
|
|
}
|
|
else
|
|
throw new NotSupportedException($"Unsupported connection string for lightning server ({uri.ConnectionType})");
|
|
}
|
|
}
|
|
}
|