mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-21 14:04:12 +01:00
Apply some lipstick on the lnd seed backup
This commit is contained in:
parent
3bdcbd8907
commit
c004065eea
6 changed files with 64 additions and 46 deletions
|
@ -624,6 +624,16 @@ namespace BTCPayServer.Controllers
|
|||
if (service.Type == ExternalServiceTypes.LNDSeedBackup)
|
||||
{
|
||||
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);
|
||||
}
|
||||
if (service.Type == ExternalServiceTypes.RPC)
|
||||
|
@ -681,7 +691,7 @@ namespace BTCPayServer.Controllers
|
|||
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";
|
||||
return RedirectToAction(nameof(Services));
|
||||
|
@ -689,6 +699,7 @@ namespace BTCPayServer.Controllers
|
|||
|
||||
if (await model.RemoveSeedAndWrite(service.ConnectionString.CookieFilePath))
|
||||
{
|
||||
TempData[WellKnownTempData.ErrorMessage] = $"Seed successfully removed";
|
||||
return RedirectToAction(nameof(Service), new { serviceName, cryptoCode });
|
||||
}
|
||||
else
|
||||
|
|
|
@ -14,9 +14,9 @@ namespace BTCPayServer.Models.ServerViewModels
|
|||
|
||||
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)
|
||||
{
|
||||
var removedDate = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ssZ", CultureInfo.InvariantCulture);
|
||||
|
@ -53,8 +53,9 @@ namespace BTCPayServer.Models.ServerViewModels
|
|||
return new LndSeedBackupViewModel
|
||||
{
|
||||
WalletPassword = unlockFile.wallet_password,
|
||||
Seed = unlockFile.cipher_seed_mnemonic,
|
||||
Seed = string.Join(' ', unlockFile.cipher_seed_mnemonic),
|
||||
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_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_BTCEXTERNALLNDSEEDBACKUP": "../BTCPayServer.Tests/TestData/LndSeedBackup/walletunlock.json",
|
||||
"BTCPAY_BTCEXTERNALSPARK": "server=/spark/btc/;cookiefile=fake",
|
||||
"BTCPAY_BTCEXTERNALCHARGE": "server=https://127.0.0.1:53280/mycharge/btc/;cookiefilepath=fake",
|
||||
"BTCPAY_BTCEXPLORERURL": "http://127.0.0.1:32838/",
|
||||
|
|
|
@ -3,59 +3,64 @@
|
|||
ViewData.SetActivePageAndTitle(ServerNavPages.Services);
|
||||
}
|
||||
|
||||
|
||||
<h4>LND Seed Backup</h4>
|
||||
<partial name="_StatusMessage" />
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div asp-validation-summary="All" class="text-danger"></div>
|
||||
|
||||
@if (TempData.HasStatusMessage())
|
||||
{
|
||||
<div class="row">
|
||||
<div class="col-md-8 text-center">
|
||||
<partial name="_StatusMessage" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="row">
|
||||
|
||||
<div class="col-md-8">
|
||||
<div class="form-group">
|
||||
@if (Model.IsWalletUnlockPresent)
|
||||
@if (Model.IsWalletUnlockPresent)
|
||||
{
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<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>
|
||||
@if (Model.Seed.Count > 1)
|
||||
{
|
||||
<p>
|
||||
<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 class="form-group collapse">
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<label for="WalletPassword" class="input-group-text"><span class="input-group-addon fa fa-lock"></span><span class="ml-2">Password</span></label>
|
||||
</div>
|
||||
</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<p><b>@Model.Seed.First()</b></p>
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
<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>
|
||||
<input asp-for="WalletPassword" onClick="this.select();" class="form-control" readonly />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group collapse">
|
||||
<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>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
}
|
||||
|
||||
@section Scripts {
|
||||
<script type="text/javascript">
|
||||
function confirmSeedDelete() {
|
||||
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>
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
</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>
|
||||
<ul>
|
||||
<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.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.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;
|
||||
@foreach (var extension in Extensions)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue