diff --git a/BTCPayServer/BTCPayServer.csproj b/BTCPayServer/BTCPayServer.csproj index 23a513275..ff1993e89 100644 --- a/BTCPayServer/BTCPayServer.csproj +++ b/BTCPayServer/BTCPayServer.csproj @@ -158,6 +158,9 @@ $(IncludeRazorContentInPack) + + $(IncludeRazorContentInPack) + $(IncludeRazorContentInPack) diff --git a/BTCPayServer/Configuration/ExternalConnectionString.cs b/BTCPayServer/Configuration/ExternalConnectionString.cs index e99b9ceed..e5c66fc34 100644 --- a/BTCPayServer/Configuration/ExternalConnectionString.cs +++ b/BTCPayServer/Configuration/ExternalConnectionString.cs @@ -142,6 +142,12 @@ namespace BTCPayServer.Configuration Macaroons = Macaroons?.Clone() }; } + public bool? IsOnion() + { + if (!this.Server.IsAbsoluteUri) + return null; + return this.Server.DnsSafeHost.EndsWith(".onion", StringComparison.OrdinalIgnoreCase); + } public static bool TryParse(string str, out ExternalConnectionString result, out string error) { if (str == null) diff --git a/BTCPayServer/Configuration/ExternalService.cs b/BTCPayServer/Configuration/ExternalService.cs index 0e56af98d..d03258790 100644 --- a/BTCPayServer/Configuration/ExternalService.cs +++ b/BTCPayServer/Configuration/ExternalService.cs @@ -76,6 +76,7 @@ namespace BTCPayServer.Configuration Spark, RTL, Charge, - P2P + P2P, + RPC } } diff --git a/BTCPayServer/Controllers/ServerController.cs b/BTCPayServer/Controllers/ServerController.cs index ef92b8966..7ace366a5 100644 --- a/BTCPayServer/Controllers/ServerController.cs +++ b/BTCPayServer/Controllers/ServerController.cs @@ -570,6 +570,17 @@ namespace BTCPayServer.Controllers ServiceName = torService.Name, }; } + if (torService.ServiceType == TorServiceType.RPC) + { + externalService = new ExternalService() + { + CryptoCode = torService.Network.CryptoCode, + DisplayName = "Full node RPC", + Type = ExternalServiceTypes.RPC, + ConnectionString = new ExternalConnectionString(new Uri($"btcrpc://btcrpc:btcpayserver4ever@{torService.OnionHost}:{torService.VirtualPort}", UriKind.Absolute)), + ServiceName = torService.Name + }; + } return externalService != null; } @@ -605,6 +616,15 @@ namespace BTCPayServer.Controllers ServiceLink = service.ConnectionString.Server.AbsoluteUri.WithoutEndingSlash() }); } + if (service.Type == ExternalServiceTypes.RPC) + { + return View("RPCService", new LightningWalletServices() + { + ShowQR = showQR, + WalletName = service.ServiceName, + ServiceLink = service.ConnectionString.Server.AbsoluteUri.WithoutEndingSlash() + }); + } var connectionString = await service.ConnectionString.Expand(this.Request.GetAbsoluteUriNoPathBase(), service.Type, _Options.NetworkType); switch (service.Type) { diff --git a/BTCPayServer/HostedServices/TorServicesHostedService.cs b/BTCPayServer/HostedServices/TorServicesHostedService.cs index 1f08fda2d..4acade425 100644 --- a/BTCPayServer/HostedServices/TorServicesHostedService.cs +++ b/BTCPayServer/HostedServices/TorServicesHostedService.cs @@ -21,9 +21,6 @@ namespace BTCPayServer.HostedServices internal override Task[] InitializeTasks() { - // TODO: We should report auto configured services (like bitcoind, lnd or clightning) - if (string.IsNullOrEmpty(_options.TorrcFile)) - return Array.Empty(); return new Task[] { CreateLoopTask(RefreshTorServices) }; } diff --git a/BTCPayServer/Services/TorServices.cs b/BTCPayServer/Services/TorServices.cs index abaec7fef..6796c197e 100644 --- a/BTCPayServer/Services/TorServices.cs +++ b/BTCPayServer/Services/TorServices.cs @@ -60,9 +60,9 @@ namespace BTCPayServer.Services }; if (service.ServiceName.Equals("BTCPayServer", StringComparison.OrdinalIgnoreCase)) torService.ServiceType = TorServiceType.BTCPayServer; - else if (TryParseP2PService(service.ServiceName, out var network)) + else if (TryParseP2PService(service.ServiceName, out var network, out var serviceType)) { - torService.ServiceType = TorServiceType.P2P; + torService.ServiceType = serviceType; torService.Network = network; } result.Add(torService); @@ -80,12 +80,23 @@ namespace BTCPayServer.Services Services = result.ToArray(); } - private bool TryParseP2PService(string name, out BTCPayNetworkBase network) + private bool TryParseP2PService(string name, out BTCPayNetworkBase network, out TorServiceType serviceType) { network = null; + serviceType = TorServiceType.Other; var splitted = name.Trim().Split('-'); - if (splitted.Length != 2 || splitted[1] != "P2P") + if (splitted.Length == 2 && splitted[1] != "P2P") + { + serviceType = TorServiceType.P2P; + } + else if (splitted.Length == 2 && splitted[1] != "RPC") + { + serviceType = TorServiceType.RPC; + } + else + { return false; + } network = _networks.GetNetwork(splitted[0]); return network != null; } @@ -104,6 +115,7 @@ namespace BTCPayServer.Services { BTCPayServer, P2P, + RPC, Other } } diff --git a/BTCPayServer/Views/Server/RPCService.cshtml b/BTCPayServer/Views/Server/RPCService.cshtml new file mode 100644 index 000000000..1096738ee --- /dev/null +++ b/BTCPayServer/Views/Server/RPCService.cshtml @@ -0,0 +1,105 @@ +@model LightningWalletServices +@{ + ViewData.SetActivePageAndTitle(ServerNavPages.Services); +} + + +

@Model.WalletName

+ + +@if (Model.ShowQR) +{ + +} + +
+
+
+
+
+ +
+
+
+
Full node connection
+

+ This page exposes information to connect remotely to your full node via the RPC protocol. +

+
+
+
Compatible wallets
+
+
+ +
+ +
+
+ +
+
+ +
+
+
+
QR Code connection
+

+ You can use QR Code to connect to @Model.WalletName with compatible wallets.
+

+
+
+ @if (!Model.ShowQR) + { +
+
+ + +
+
+ } + else + { +
+
+
+
+

See QR Code information by clicking here

+
+
+ + +
+
+ } +
+
+
+ +@section Scripts { + @await Html.PartialAsync("_ValidationScriptsPartial") + + @if (Model.ShowQR) + { + + + } +} diff --git a/BTCPayServer/Views/Server/Services.cshtml b/BTCPayServer/Views/Server/Services.cshtml index d4e13f719..d908f5800 100644 --- a/BTCPayServer/Views/Server/Services.cshtml +++ b/BTCPayServer/Views/Server/Services.cshtml @@ -33,7 +33,15 @@ { @s.CryptoCode - @s.DisplayName + + @s.DisplayName + @if ((s.ConnectionString.IsOnion() is true) || + (s.ConnectionString.IsOnion() is false && + this.Context.Request.IsOnion())) + { + + } + See information diff --git a/BTCPayServer/wwwroot/img/fullynoded.png b/BTCPayServer/wwwroot/img/fullynoded.png new file mode 100644 index 000000000..c52d1dc7b Binary files /dev/null and b/BTCPayServer/wwwroot/img/fullynoded.png differ