mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-17 22:14:26 +01:00
Apply some lipstick on the lnd seed backup
This commit is contained in:
@@ -624,6 +624,16 @@ namespace BTCPayServer.Controllers
|
|||||||
if (service.Type == ExternalServiceTypes.LNDSeedBackup)
|
if (service.Type == ExternalServiceTypes.LNDSeedBackup)
|
||||||
{
|
{
|
||||||
var model = LndSeedBackupViewModel.Parse(service.ConnectionString.CookieFilePath);
|
var model = LndSeedBackupViewModel.Parse(service.ConnectionString.CookieFilePath);
|
||||||
|
if (!model.IsWalletUnlockPresent)
|
||||||
|
{
|
||||||
|
TempData.SetStatusMessageModel(new StatusMessageModel()
|
||||||
|
{
|
||||||
|
Severity = StatusMessageModel.StatusSeverity.Warning,
|
||||||
|
Html = "Your LND does not seem to allow seed backup.<br />" +
|
||||||
|
"It's recommended, but not required, that you migrate as instructed by <a href=\"https://blog.btcpayserver.org/btcpay-lnd-migration\">our migration blog post</a>.<br />" +
|
||||||
|
"You will need to close all of your channels, and migrate your funds as <a href=\"https://blog.btcpayserver.org/btcpay-lnd-migration\">we documented</a>."
|
||||||
|
});
|
||||||
|
}
|
||||||
return View("LndSeedBackup", model);
|
return View("LndSeedBackup", model);
|
||||||
}
|
}
|
||||||
if (service.Type == ExternalServiceTypes.RPC)
|
if (service.Type == ExternalServiceTypes.RPC)
|
||||||
@@ -681,7 +691,7 @@ namespace BTCPayServer.Controllers
|
|||||||
return RedirectToAction(nameof(Services));
|
return RedirectToAction(nameof(Services));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (model.Seed == null || model.Seed.Count <= 1)
|
if (string.IsNullOrEmpty(model.Seed))
|
||||||
{
|
{
|
||||||
TempData[WellKnownTempData.ErrorMessage] = $"Seed information was already removed";
|
TempData[WellKnownTempData.ErrorMessage] = $"Seed information was already removed";
|
||||||
return RedirectToAction(nameof(Services));
|
return RedirectToAction(nameof(Services));
|
||||||
@@ -689,6 +699,7 @@ namespace BTCPayServer.Controllers
|
|||||||
|
|
||||||
if (await model.RemoveSeedAndWrite(service.ConnectionString.CookieFilePath))
|
if (await model.RemoveSeedAndWrite(service.ConnectionString.CookieFilePath))
|
||||||
{
|
{
|
||||||
|
TempData[WellKnownTempData.ErrorMessage] = $"Seed successfully removed";
|
||||||
return RedirectToAction(nameof(Service), new { serviceName, cryptoCode });
|
return RedirectToAction(nameof(Service), new { serviceName, cryptoCode });
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ namespace BTCPayServer.Models.ServerViewModels
|
|||||||
|
|
||||||
public string WalletPassword { get; set; }
|
public string WalletPassword { get; set; }
|
||||||
|
|
||||||
public List<string> Seed { get; set; }
|
public string Seed { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
public bool Removed { get; set; }
|
||||||
public async Task<bool> RemoveSeedAndWrite(string lndSeedFilePath)
|
public async Task<bool> RemoveSeedAndWrite(string lndSeedFilePath)
|
||||||
{
|
{
|
||||||
var removedDate = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ssZ", CultureInfo.InvariantCulture);
|
var removedDate = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ssZ", CultureInfo.InvariantCulture);
|
||||||
@@ -53,8 +53,9 @@ namespace BTCPayServer.Models.ServerViewModels
|
|||||||
return new LndSeedBackupViewModel
|
return new LndSeedBackupViewModel
|
||||||
{
|
{
|
||||||
WalletPassword = unlockFile.wallet_password,
|
WalletPassword = unlockFile.wallet_password,
|
||||||
Seed = unlockFile.cipher_seed_mnemonic,
|
Seed = string.Join(' ', unlockFile.cipher_seed_mnemonic),
|
||||||
IsWalletUnlockPresent = true,
|
IsWalletUnlockPresent = true,
|
||||||
|
Removed = unlockFile.cipher_seed_mnemonic.Count == 1
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
"BTCPAY_BTCLIGHTNING": "type=charge;server=http://127.0.0.1:54938/;api-token=foiewnccewuify",
|
"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_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",
|
"BTCPAY_BTCEXTERNALLNDREST": "type=lnd-rest;server=https://lnd:lnd@127.0.0.1:53280/lnd-rest/btc/;allowinsecure=true",
|
||||||
|
"BTCPAY_BTCEXTERNALLNDSEEDBACKUP": "../BTCPayServer.Tests/TestData/LndSeedBackup/walletunlock.json",
|
||||||
"BTCPAY_BTCEXTERNALSPARK": "server=/spark/btc/;cookiefile=fake",
|
"BTCPAY_BTCEXTERNALSPARK": "server=/spark/btc/;cookiefile=fake",
|
||||||
"BTCPAY_BTCEXTERNALCHARGE": "server=https://127.0.0.1:53280/mycharge/btc/;cookiefilepath=fake",
|
"BTCPAY_BTCEXTERNALCHARGE": "server=https://127.0.0.1:53280/mycharge/btc/;cookiefilepath=fake",
|
||||||
"BTCPAY_BTCEXPLORERURL": "http://127.0.0.1:32838/",
|
"BTCPAY_BTCEXPLORERURL": "http://127.0.0.1:32838/",
|
||||||
|
|||||||
@@ -3,59 +3,64 @@
|
|||||||
ViewData.SetActivePageAndTitle(ServerNavPages.Services);
|
ViewData.SetActivePageAndTitle(ServerNavPages.Services);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
<h4>LND Seed Backup</h4>
|
<h4>LND Seed Backup</h4>
|
||||||
<partial name="_StatusMessage" />
|
|
||||||
<div class="row">
|
@if (TempData.HasStatusMessage())
|
||||||
<div class="col-md-6">
|
{
|
||||||
<div asp-validation-summary="All" class="text-danger"></div>
|
<div class="row">
|
||||||
|
<div class="col-md-8 text-center">
|
||||||
|
<partial name="_StatusMessage" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
}
|
||||||
|
|
||||||
<div class="row">
|
@if (Model.IsWalletUnlockPresent)
|
||||||
|
{
|
||||||
<div class="col-md-8">
|
<div class="row">
|
||||||
<div class="form-group">
|
<div class="col-md-8">
|
||||||
@if (Model.IsWalletUnlockPresent)
|
<div class="form-group">
|
||||||
|
<p>The LND seed backup is useful to recover funds of your LND wallet in case of a corruption of your server.</p>
|
||||||
|
<p>The recovering process is documented by LND on <a href="https://github.com/lightningnetwork/lnd/blob/master/docs/recovery.md">this page</a>.</p>
|
||||||
|
</div>
|
||||||
|
<a class="btn btn-primary @(Model.Removed ? "collapse" : "")" id="details" href="#">See confidential seed information</a>
|
||||||
|
<div class="form-group @(Model.Removed ? "" : "collapse")">
|
||||||
|
<div class="input-group">
|
||||||
|
<div class="input-group-prepend">
|
||||||
|
<label for="Seed" class="input-group-text"><span class="input-group-addon fa fa-eye"></span><span class="ml-2">Seed</span></label>
|
||||||
|
</div>
|
||||||
|
<textarea asp-for="Seed" onClick="this.select();" class="form-control" readonly rows="@(Model.Removed ? "1" : "3")"></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@if (!Model.Removed)
|
||||||
{
|
{
|
||||||
<p>Wallet Password: <b>@Model.WalletPassword</b></p>
|
<div class="form-group collapse">
|
||||||
@if (Model.Seed.Count > 1)
|
<div class="input-group">
|
||||||
{
|
<div class="input-group-prepend">
|
||||||
<p>
|
<label for="WalletPassword" class="input-group-text"><span class="input-group-addon fa fa-lock"></span><span class="ml-2">Password</span></label>
|
||||||
<div><a href="#details" data-toggle="collapse">Reveal Seed Information</a></div>
|
|
||||||
<div id="details" class="collapse">
|
|
||||||
@foreach (var item in Model.Seed)
|
|
||||||
{
|
|
||||||
<span>@item</span>
|
|
||||||
}
|
|
||||||
<br /><br />
|
|
||||||
<form method="post" action="@Context.Request.Path/removelndseed">
|
|
||||||
<button class="btn btn-primary" type="submit" onclick="return confirmSeedDelete();">Remove Seed from server</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
</div>
|
||||||
</p>
|
<input asp-for="WalletPassword" onClick="this.select();" class="form-control" readonly />
|
||||||
}
|
</div>
|
||||||
else
|
</div>
|
||||||
{
|
<div class="form-group collapse">
|
||||||
<p><b>@Model.Seed.First()</b></p>
|
<form method="post" asp-action="RemoveLndSeed" asp-route-serviceName="@this.Context.GetRouteValue("serviceName")" asp-route-cryptoCode="@this.Context.GetRouteValue("cryptoCode")">
|
||||||
}
|
<button class="btn btn-primary" type="submit" onclick="return confirmSeedDelete();">Remove Seed from server</button>
|
||||||
}
|
</form>
|
||||||
else
|
</div>
|
||||||
{
|
|
||||||
<p class="text-danger">Unlock file is NOT present</p>
|
|
||||||
<p>You have old version of LND deployment that was auto-initialized using `noseedbackup=1`.</p>
|
|
||||||
<p>Please migrate to new version of LND deployment that is auto-initialized through script which creates seed backup file as part of the startup process.</p>
|
|
||||||
<p><a href="https://github.com/btcpayserver/lnd/pull/4" target="_blank">Visit this link for more information</a></p>
|
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
</div>
|
|
||||||
|
|
||||||
@section Scripts {
|
@section Scripts {
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function confirmSeedDelete() {
|
function confirmSeedDelete() {
|
||||||
return confirm('This operation is not undoable. Are you sure you want to proceed with deleting seed from LND container?');
|
return confirm('This operation is not undoable. Are you sure you want to proceed with deleting seed from LND container?');
|
||||||
}
|
}
|
||||||
|
$(function () {
|
||||||
|
$("#details").click(function () {
|
||||||
|
$(".collapse").removeClass("collapse");
|
||||||
|
$(this).addClass("collapse");
|
||||||
|
});
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
<span>Before you proceed, please understand that Lightning Network is still in the experimental stage. Do not put the money you can't afford to lose. There is a high risk of you losing the money.</span>
|
<span>Before you proceed, please understand that Lightning Network is still in the experimental stage. Do not put the money you can't afford to lose. There is a high risk of you losing the money.</span>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
Take time to familiarize yourself with the risk. There's no backup for LND or c-lightning keys in BTCPay. Your keys are in a hot-wallet. This means :
|
Take time to familiarize yourself with the risk. There's no backup lightning keys automatically done by BTCPayServer. Your keys are in a hot-wallet. This means :
|
||||||
</p>
|
</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>Most of BTCPay Server deployments run on a pruned node, which, while working, is not officially supported by lightning network implementations.</li>
|
<li>Most of BTCPay Server deployments run on a pruned node, which, while working, is not officially supported by lightning network implementations.</li>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<a id="@(nameof(StoreNavPages.Checkout))"class="nav-link @ViewData.IsActivePage(StoreNavPages.Checkout)" asp-controller="Stores" asp-action="CheckoutExperience" asp-route-storeId="@this.Context.GetRouteValue("storeId")">Checkout experience</a>
|
<a id="@(nameof(StoreNavPages.Checkout))"class="nav-link @ViewData.IsActivePage(StoreNavPages.Checkout)" asp-controller="Stores" asp-action="CheckoutExperience" asp-route-storeId="@this.Context.GetRouteValue("storeId")">Checkout experience</a>
|
||||||
<a id="@(nameof(StoreNavPages.Tokens))"class="nav-link @ViewData.IsActivePage(StoreNavPages.Tokens)" asp-controller="Stores" asp-action="ListTokens" asp-route-storeId="@this.Context.GetRouteValue("storeId")">Access Tokens</a>
|
<a id="@(nameof(StoreNavPages.Tokens))"class="nav-link @ViewData.IsActivePage(StoreNavPages.Tokens)" asp-controller="Stores" asp-action="ListTokens" asp-route-storeId="@this.Context.GetRouteValue("storeId")">Access Tokens</a>
|
||||||
<a id="@(nameof(StoreNavPages.Users))"class="nav-link @ViewData.IsActivePage(StoreNavPages.Users)" asp-controller="Stores" asp-action="StoreUsers" asp-route-storeId="@this.Context.GetRouteValue("storeId")">Users</a>
|
<a id="@(nameof(StoreNavPages.Users))"class="nav-link @ViewData.IsActivePage(StoreNavPages.Users)" asp-controller="Stores" asp-action="StoreUsers" asp-route-storeId="@this.Context.GetRouteValue("storeId")">Users</a>
|
||||||
<a id="@(nameof(StoreNavPages.PayButton))"class="nav-link @ViewData.IsActivePage(StoreNavPages.PayButton)"asp-controller="Stores" asp-action="PayButton" asp-route-storeId="@this.Context.GetRouteValue("storeId")">Pay Button</a>
|
<a id="@(nameof(StoreNavPages.PayButton))"class="nav-link @ViewData.IsActivePage(StoreNavPages.PayButton)" asp-controller="Stores" asp-action="PayButton" asp-route-storeId="@this.Context.GetRouteValue("storeId")">Pay Button</a>
|
||||||
@inject IEnumerable<BTCPayServer.Contracts.IStoreNavExtension> Extensions;
|
@inject IEnumerable<BTCPayServer.Contracts.IStoreNavExtension> Extensions;
|
||||||
@foreach (var extension in Extensions)
|
@foreach (var extension in Extensions)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user