mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 06:24:24 +01:00
Lightning: Link to services directly (#3593)
* Allow to access fake LN services in dev mode * Link directly to Lightning services Closes #3552. * Fix typo
This commit is contained in:
@@ -49,13 +49,15 @@ namespace BTCPayServer.Controllers
|
||||
{
|
||||
var services = _externalServiceOptions.Value.ExternalServices.ToList()
|
||||
.Where(service => _externalServiceTypes.Contains(service.Type))
|
||||
.Select(service => new AdditionalServiceViewModel
|
||||
.Select(async service => new AdditionalServiceViewModel
|
||||
{
|
||||
DisplayName = service.DisplayName,
|
||||
ServiceName = service.ServiceName,
|
||||
CryptoCode = service.CryptoCode,
|
||||
Type = service.Type.ToString()
|
||||
Type = service.Type.ToString(),
|
||||
Link = await GetServiceLink(service)
|
||||
})
|
||||
.Select(t => t.Result)
|
||||
.ToList();
|
||||
|
||||
// other services
|
||||
@@ -78,7 +80,7 @@ namespace BTCPayServer.Controllers
|
||||
|
||||
return View(vm);
|
||||
}
|
||||
|
||||
|
||||
[HttpGet("{storeId}/lightning/{cryptoCode}/setup")]
|
||||
public async Task<IActionResult> SetupLightningNode(string storeId, string cryptoCode)
|
||||
{
|
||||
@@ -376,6 +378,7 @@ namespace BTCPayServer.Controllers
|
||||
.FirstOrDefault(d => d.PaymentId == id);
|
||||
return existing;
|
||||
}
|
||||
|
||||
private LNURLPaySupportedPaymentMethod? GetExistingLNURLSupportedPaymentMethod(string cryptoCode, StoreData store)
|
||||
{
|
||||
var id = new PaymentMethodId(cryptoCode, PaymentTypes.LNURLPay);
|
||||
@@ -384,5 +387,12 @@ namespace BTCPayServer.Controllers
|
||||
.FirstOrDefault(d => d.PaymentId == id);
|
||||
return existing;
|
||||
}
|
||||
|
||||
private async Task<string> GetServiceLink(ExternalService service)
|
||||
{
|
||||
var connectionString = await service.ConnectionString.Expand(Request.GetAbsoluteUriNoPathBase(), service.Type, _BtcpayServerOptions.NetworkType);
|
||||
var tokenParam = service.Type == ExternalServiceTypes.ThunderHub ? "token" : "access-key";
|
||||
return $"{connectionString.Server}?{tokenParam}={connectionString.AccessKey}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user