diff --git a/BTCPayServer/BTCPayServer.csproj b/BTCPayServer/BTCPayServer.csproj index ec733e589..74fd82e5f 100644 --- a/BTCPayServer/BTCPayServer.csproj +++ b/BTCPayServer/BTCPayServer.csproj @@ -136,9 +136,6 @@ $(IncludeRazorContentInPack) - - $(IncludeRazorContentInPack) - $(IncludeRazorContentInPack) @@ -154,7 +151,7 @@ $(IncludeRazorContentInPack) - + $(IncludeRazorContentInPack) diff --git a/BTCPayServer/Controllers/ServerController.cs b/BTCPayServer/Controllers/ServerController.cs index 716c704c7..25c9193ed 100644 --- a/BTCPayServer/Controllers/ServerController.cs +++ b/BTCPayServer/Controllers/ServerController.cs @@ -454,8 +454,8 @@ namespace BTCPayServer.Controllers return View(result); } - [Route("server/services/lnd-grpc/{cryptoCode}/{index}")] - public IActionResult LndGrpcServices(string cryptoCode, int index, uint? nonce) + [Route("server/services/lnd/{cryptoCode}/{index}")] + public IActionResult LndServices(string cryptoCode, int index, uint? nonce) { if (!_dashBoard.IsFullySynched(cryptoCode, out var unusud)) { @@ -466,9 +466,18 @@ namespace BTCPayServer.Controllers if (external == null) return NotFound(); var model = new LndGrpcServicesViewModel(); + if (external.ConnectionType == LightningConnectionType.LndGRPC) + { + model.Host = $"{external.BaseUri.DnsSafeHost}:{external.BaseUri.Port}"; + model.SSL = external.BaseUri.Scheme == "https"; + model.ConnectionType = "GRPC"; + } + else if(external.ConnectionType == LightningConnectionType.LndREST) + { + model.Uri = external.BaseUri.AbsoluteUri; + model.ConnectionType = "REST"; + } - model.Host = $"{external.BaseUri.DnsSafeHost}:{external.BaseUri.Port}"; - model.SSL = external.BaseUri.Scheme == "https"; if (external.CertificateThumbprint != null) { model.CertificateThumbprint = Encoders.Hex.EncodeData(external.CertificateThumbprint); @@ -480,7 +489,7 @@ namespace BTCPayServer.Controllers if (nonce != null) { - var configKey = GetConfigKey("lnd-grpc", cryptoCode, index, nonce.Value); + var configKey = GetConfigKey("lnd", cryptoCode, index, nonce.Value); var lnConfig = _LnConfigProvider.GetConfig(configKey); if (lnConfig != null) { @@ -507,29 +516,42 @@ namespace BTCPayServer.Controllers return Json(conf); } - [Route("server/services/lnd-grpc/{cryptoCode}/{index}")] + [Route("server/services/lnd/{cryptoCode}/{index}")] [HttpPost] - public IActionResult LndGrpcServicesPost(string cryptoCode, int index) + public IActionResult LndServicesPost(string cryptoCode, int index) { var external = GetExternalLndConnectionString(cryptoCode, index); if (external == null) return NotFound(); LightningConfigurations confs = new LightningConfigurations(); - LightningConfiguration conf = new LightningConfiguration(); - conf.Type = "grpc"; - conf.ChainType = _Options.NetworkType.ToString(); - conf.CryptoCode = cryptoCode; - conf.Host = external.BaseUri.DnsSafeHost; - conf.Port = external.BaseUri.Port; - conf.SSL = external.BaseUri.Scheme == "https"; - conf.Macaroon = external.Macaroon == null ? null : Encoders.Hex.EncodeData(external.Macaroon); - conf.CertificateThumbprint = external.CertificateThumbprint == null ? null : Encoders.Hex.EncodeData(external.CertificateThumbprint); - confs.Configurations.Add(conf); - + if (external.ConnectionType == LightningConnectionType.LndGRPC) + { + LightningConfiguration conf = new LightningConfiguration(); + conf.Type = "grpc"; + conf.ChainType = _Options.NetworkType.ToString(); + conf.CryptoCode = cryptoCode; + conf.Host = external.BaseUri.DnsSafeHost; + conf.Port = external.BaseUri.Port; + conf.SSL = external.BaseUri.Scheme == "https"; + conf.Macaroon = external.Macaroon == null ? null : Encoders.Hex.EncodeData(external.Macaroon); + conf.CertificateThumbprint = external.CertificateThumbprint == null ? null : Encoders.Hex.EncodeData(external.CertificateThumbprint); + confs.Configurations.Add(conf); + } + else if (external.ConnectionType == LightningConnectionType.LndREST) + { + var restconf = new LNDRestConfiguration(); + restconf.Type = "lnd-rest"; + restconf.ChainType = _Options.NetworkType.ToString(); + restconf.CryptoCode = cryptoCode; + restconf.Uri = external.BaseUri.AbsoluteUri; + restconf.Macaroon = external.Macaroon == null ? null : Encoders.Hex.EncodeData(external.Macaroon); + restconf.CertificateThumbprint = external.CertificateThumbprint == null ? null : Encoders.Hex.EncodeData(external.CertificateThumbprint); + confs.Configurations.Add(restconf); + } var nonce = RandomUtils.GetUInt32(); - var configKey = GetConfigKey("lnd-grpc", cryptoCode, index, nonce); + var configKey = GetConfigKey("lnd", cryptoCode, index, nonce); _LnConfigProvider.KeepConfig(configKey, confs); - return RedirectToAction(nameof(LndGrpcServices), new { cryptoCode = cryptoCode, nonce = nonce }); + return RedirectToAction(nameof(LndServices), new { cryptoCode = cryptoCode, nonce = nonce }); } private LightningConnectionString GetExternalLndConnectionString(string cryptoCode, int index) @@ -554,28 +576,6 @@ namespace BTCPayServer.Controllers return connectionString; } - [Route("server/services/lnd-rest/{cryptoCode}/{index}")] - public IActionResult LndRestServices(string cryptoCode, int index, uint? nonce) - { - if (!_dashBoard.IsFullySynched(cryptoCode, out var unusud)) - { - StatusMessage = $"Error: {cryptoCode} is not fully synched"; - return RedirectToAction(nameof(Services)); - } - var external = GetExternalLndConnectionString(cryptoCode, index); - if (external == null) - return NotFound(); - var model = new LndRestServicesViewModel(); - - model.BaseApiUrl = external.BaseUri.ToString(); - if (external.CertificateThumbprint != null) - model.CertificateThumbprint = Encoders.Hex.EncodeData(external.CertificateThumbprint); - if (external.Macaroon != null) - model.Macaroon = Encoders.Hex.EncodeData(external.Macaroon); - - return View(model); - } - [Route("server/services/ssh")] public IActionResult SSHService(bool downloadKeyFile = false) { diff --git a/BTCPayServer/Models/ServerViewModels/LndGrpcServicesViewModel.cs b/BTCPayServer/Models/ServerViewModels/LndGrpcServicesViewModel.cs index 1636b94f1..fd527157d 100644 --- a/BTCPayServer/Models/ServerViewModels/LndGrpcServicesViewModel.cs +++ b/BTCPayServer/Models/ServerViewModels/LndGrpcServicesViewModel.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; using System.Linq; using System.Threading.Tasks; @@ -13,5 +14,8 @@ namespace BTCPayServer.Models.ServerViewModels public string CertificateThumbprint { get; set; } public string QRCode { get; set; } public string QRCodeLink { get; set; } + [Display(Name = "REST Uri")] + public string Uri { get; set; } + public string ConnectionType { get; internal set; } } } diff --git a/BTCPayServer/Properties/launchSettings.json b/BTCPayServer/Properties/launchSettings.json index 8f728e890..8caa253aa 100644 --- a/BTCPayServer/Properties/launchSettings.json +++ b/BTCPayServer/Properties/launchSettings.json @@ -28,7 +28,7 @@ "BTCPAY_LTCEXPLORERURL": "http://127.0.0.1:32838/", "BTCPAY_BTCLIGHTNING": "type=charge;server=http://127.0.0.1:54938/;api-token=foiewnccewuify", "BTCPAY_BTCEXTERNALLNDGRPC": "type=lnd-grpc;server=https://lnd:lnd@127.0.0.1:53280/;allowinsecure=true", - "BTCPAY_BTCEXTERNALLNDREST": "type=lnd-rest;server=https://lnd:lnd@127.0.0.1:53280/lnd-rest/btc/;allowinsecure=true;macaroonfilepath=D:\\admin.macaroon", + "BTCPAY_BTCEXTERNALLNDREST": "type=lnd-rest;server=https://lnd:lnd@127.0.0.1:53280/lnd-rest/btc/;allowinsecure=true", "BTCPAY_BTCEXPLORERURL": "http://127.0.0.1:32838/", "ASPNETCORE_ENVIRONMENT": "Development", "BTCPAY_CHAINS": "btc,ltc", diff --git a/BTCPayServer/Services/LightningConfigurationProvider.cs b/BTCPayServer/Services/LightningConfigurationProvider.cs index c2e6f26a5..87bedef1d 100644 --- a/BTCPayServer/Services/LightningConfigurationProvider.cs +++ b/BTCPayServer/Services/LightningConfigurationProvider.cs @@ -39,7 +39,7 @@ namespace BTCPayServer.Services public class LightningConfigurations { - public List Configurations { get; set; } = new List(); + public List Configurations { get; set; } = new List(); } public class LightningConfiguration { @@ -52,4 +52,13 @@ namespace BTCPayServer.Services public string CertificateThumbprint { get; set; } public string Macaroon { get; set; } } + public class LNDRestConfiguration + { + public string ChainType { get; set; } + public string Type { get; set; } + public string CryptoCode { get; set; } + public string Uri { get; set; } + public string Macaroon { get; set; } + public string CertificateThumbprint { get; set; } + } } diff --git a/BTCPayServer/Views/Server/LndRestServices.cshtml b/BTCPayServer/Views/Server/LndRestServices.cshtml deleted file mode 100644 index 0b0b01523..000000000 --- a/BTCPayServer/Views/Server/LndRestServices.cshtml +++ /dev/null @@ -1,41 +0,0 @@ -@model LndRestServicesViewModel -@{ - ViewData.SetActivePageAndTitle(ServerNavPages.Services); -} - - -LND REST - - - - - - - - - - - - BTCPay exposes LND Rest services for outside consumption. See connection information below - - - - Base API Url - - - @if (Model.Macaroon != null) - { - - - - - } - @if (Model.CertificateThumbprint != null) - { - - - - - } - - diff --git a/BTCPayServer/Views/Server/LndGrpcServices.cshtml b/BTCPayServer/Views/Server/LndServices.cshtml similarity index 72% rename from BTCPayServer/Views/Server/LndGrpcServices.cshtml rename to BTCPayServer/Views/Server/LndServices.cshtml index a23b68e5a..86e24fc03 100644 --- a/BTCPayServer/Views/Server/LndGrpcServices.cshtml +++ b/BTCPayServer/Views/Server/LndServices.cshtml @@ -4,7 +4,7 @@ } -LND GRPC +LND @Model.ConnectionType @@ -17,14 +17,14 @@ - BTCPay exposes gRPC services for outside consumption, you will find connection information here. + BTCPay exposes LND's @Model.ConnectionType service for outside consumption, you will find connection information here. QR Code connection - You can use this QR Code to connect your Zap wallet to your LND instance. + You can use this QR Code to connect external software to your LND instance. This QR Code is only valid for 10 minutes @@ -61,22 +61,32 @@ Alternatively, you can see the settings by clicking here - - - - - - - - - @if(Model.Macaroon != null) + @if (Model.Uri == null) + { + + + + + + + + + } + else + { + + + + + } + @if (Model.Macaroon != null) { } - @if(Model.CertificateThumbprint != null) + @if (Model.CertificateThumbprint != null) { diff --git a/BTCPayServer/Views/Server/Services.cshtml b/BTCPayServer/Views/Server/Services.cshtml index 3250c81c0..2eb1b6565 100644 --- a/BTCPayServer/Views/Server/Services.cshtml +++ b/BTCPayServer/Views/Server/Services.cshtml @@ -38,11 +38,11 @@ @if (lnd.Type == BTCPayServer.Configuration.External.LndTypes.gRPC) { - See information + See information } else if (lnd.Type == BTCPayServer.Configuration.External.LndTypes.Rest) { - See information + See information }
BTCPay exposes LND Rest services for outside consumption. See connection information below
- BTCPay exposes gRPC services for outside consumption, you will find connection information here. + BTCPay exposes LND's @Model.ConnectionType service for outside consumption, you will find connection information here.
- You can use this QR Code to connect your Zap wallet to your LND instance. + You can use this QR Code to connect external software to your LND instance. This QR Code is only valid for 10 minutes
Alternatively, you can see the settings by clicking here