mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 14:34:23 +01:00
Show Bitcoin RPC service
This commit is contained in:
@@ -158,6 +158,9 @@
|
||||
<Content Update="Views\Server\LightningWalletServices.cshtml">
|
||||
<Pack>$(IncludeRazorContentInPack)</Pack>
|
||||
</Content>
|
||||
<Content Update="Views\Server\RPCService.cshtml">
|
||||
<Pack>$(IncludeRazorContentInPack)</Pack>
|
||||
</Content>
|
||||
<Content Update="Views\Server\P2PService.cshtml">
|
||||
<Pack>$(IncludeRazorContentInPack)</Pack>
|
||||
</Content>
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -76,6 +76,7 @@ namespace BTCPayServer.Configuration
|
||||
Spark,
|
||||
RTL,
|
||||
Charge,
|
||||
P2P
|
||||
P2P,
|
||||
RPC
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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<Task>();
|
||||
return new Task[] { CreateLoopTask(RefreshTorServices) };
|
||||
}
|
||||
|
||||
|
||||
@@ -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<BTCPayNetworkBase>(splitted[0]);
|
||||
return network != null;
|
||||
}
|
||||
@@ -104,6 +115,7 @@ namespace BTCPayServer.Services
|
||||
{
|
||||
BTCPayServer,
|
||||
P2P,
|
||||
RPC,
|
||||
Other
|
||||
}
|
||||
}
|
||||
|
||||
105
BTCPayServer/Views/Server/RPCService.cshtml
Normal file
105
BTCPayServer/Views/Server/RPCService.cshtml
Normal file
@@ -0,0 +1,105 @@
|
||||
@model LightningWalletServices
|
||||
@{
|
||||
ViewData.SetActivePageAndTitle(ServerNavPages.Services);
|
||||
}
|
||||
|
||||
|
||||
<h4>@Model.WalletName</h4>
|
||||
<partial name="_StatusMessage" />
|
||||
|
||||
@if (Model.ShowQR)
|
||||
{
|
||||
<div class="alert alert-warning alert-dismissible" role="alert">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<div>
|
||||
<span><b>CONFIDENTIAL:</b> This QR Code is confidential, close this window as soon as you don't need it anymore.<br /></span>
|
||||
<span>A malicious actor with access to this QR Code can affect the performances of your server.</span>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div asp-validation-summary="All" class="text-danger"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<div class="form-group">
|
||||
<h5>Full node connection</h5>
|
||||
<p>
|
||||
<span>This page exposes information to connect remotely to your full node via the RPC protocol.</span>
|
||||
</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<h5>Compatible wallets</h5>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-lg-3 ml-auto text-center">
|
||||
<a href="https://apps.apple.com/us/app/fully-noded/id1436425586" target="_blank">
|
||||
<img src="~/img/fullynoded.png" height="100" />
|
||||
</a>
|
||||
<p><a href="https://apps.apple.com/us/app/fully-noded/id1436425586" target="_blank">Fully Noded</a></p>
|
||||
</div>
|
||||
<div class="col-lg-3 mr-auto text-center">
|
||||
|
||||
</div>
|
||||
<div class="col-lg-3 mr-auto text-center">
|
||||
|
||||
</div>
|
||||
<div class="col-lg-3 mr-auto text-center">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<h5>QR Code connection</h5>
|
||||
<p>
|
||||
<span>You can use QR Code to connect to @Model.WalletName with compatible wallets.<br /></span>
|
||||
</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
@if (!Model.ShowQR)
|
||||
{
|
||||
<div class="form-group">
|
||||
<form method="get">
|
||||
<input type="hidden" asp-for="ShowQR" value="true" />
|
||||
<button type="submit" class="btn btn-primary">Show Confidential QR Code</button>
|
||||
</form>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="form-group">
|
||||
<div id="qrCode"></div>
|
||||
<div id="qrCodeData" data-url="@Model.ServiceLink"></div>
|
||||
</div>
|
||||
<p>See QR Code information by clicking <a href="#detailsQR" data-toggle="collapse">here</a></p>
|
||||
<div id="detailsQR" class="collapse">
|
||||
<div class="form-group">
|
||||
<label>QR Code data</label>
|
||||
<input asp-for="ServiceLink" readonly class="form-control" />
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
@await Html.PartialAsync("_ValidationScriptsPartial")
|
||||
|
||||
@if (Model.ShowQR)
|
||||
{
|
||||
<script type="text/javascript" src="~/js/qrcode.js"></script>
|
||||
<script type="text/javascript">
|
||||
new QRCode(document.getElementById("qrCode"),
|
||||
{
|
||||
text: @Safe.Json(Model.ServiceLink),
|
||||
width: 200,
|
||||
height: 200,
|
||||
useSVG: true
|
||||
});
|
||||
</script>
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,15 @@
|
||||
{
|
||||
<tr>
|
||||
<td>@s.CryptoCode</td>
|
||||
<td>@s.DisplayName</td>
|
||||
<td>
|
||||
<span>@s.DisplayName</span>
|
||||
@if ((s.ConnectionString.IsOnion() is true) ||
|
||||
(s.ConnectionString.IsOnion() is false &&
|
||||
this.Context.Request.IsOnion()))
|
||||
{
|
||||
<span><img style="display:inline; margin-top:-8px;" src="~/img/icons/Onion_Color.svg" height="20" /></span>
|
||||
}
|
||||
</td>
|
||||
<td style="text-align: right">
|
||||
<a asp-action="Service" asp-route-serviceName="@s.ServiceName" asp-route-cryptoCode="@s.CryptoCode">See information</a>
|
||||
</td>
|
||||
|
||||
BIN
BTCPayServer/wwwroot/img/fullynoded.png
Normal file
BIN
BTCPayServer/wwwroot/img/fullynoded.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.3 KiB |
Reference in New Issue
Block a user