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:
d11n
2022-04-11 10:49:28 +02:00
committed by GitHub
parent 8feb60c30d
commit e5174b4a29
4 changed files with 42 additions and 19 deletions

View File

@@ -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}";
}
}
}