2023-01-22 03:08:12 +09:00
@using BTCPayServer.Views.Stores
2022-07-15 05:38:33 +02:00
@using BTCPayServer.Abstractions.Models
2022-01-07 12:32:00 +09:00
@model UILNURLController.EditLightningAddressVM
2021-10-29 11:01:16 +02:00
@{
2021-12-31 08:36:38 +01:00
ViewData.SetActivePage("LightningAddress", nameof(StoreNavPages), "Lightning Address", Context.GetStoreData().Id);
2021-10-29 11:01:16 +02:00
}
@section PageHeadContent {
<style>
.settings-holder span:not(:last-child):after{
content: " / ";
}
</style>
}
@section PageFootContent {
<script>
delegate('click', '.remove', event => {
event.preventDefault()
const { name, value } = event.target
const confirmButton = document.getElementById('ConfirmContinue')
confirmButton.setAttribute('name', name)
confirmButton.setAttribute('value', value)
})
</script>
}
2024-06-19 15:23:10 +02:00
<div class="sticky-header">
<h2>@ViewData["Title"]</h2>
<a data-bs-toggle="collapse" data-bs-target="#AddAddress" class="btn btn-primary" role="button">
Add Address
</a>
</div>
2021-12-31 08:36:38 +01:00
<partial name="_StatusMessage" />
2021-10-29 22:18:33 +09:00
@if (Context.Request.PathBase.ToString() != string.Empty)
{
2021-12-31 08:36:38 +01:00
<div class="alert alert-warning" role="alert">
Your BTCPay Server installation is using the root path <span class="fw-bold">@Context.Request.PathBase</span>.<br /><br />
This is incompatible with wallets attempting to resolve <span class="fw-bold">@Context.Request.GetAbsoluteUriNoPathBase(new Uri("/.well-known/lnurlp/{username}", UriKind.Relative))</span> rather than <span class="fw-bold">@Context.Request.GetAbsoluteUri("/.well-known/lnurlp/{username}")</span>.<br /><br />
If the LN Address doesn't work, ask your integrator to redirect queries from <span class="fw-bold">@Context.Request.GetAbsoluteUriNoPathBase(new Uri("/.well-known/lnurlp/{username}", UriKind.Relative))</span> to <span class="fw-bold">@Context.Request.GetAbsoluteUri("/.well-known/lnurlp/{username}")</span>.
</div>
2021-10-29 22:18:33 +09:00
}
2021-10-29 11:01:16 +02:00
<form asp-action="EditLightningAddress" method="post">
@{
var showAddForm = !ViewContext.ViewData.ModelState.IsValid || !string.IsNullOrEmpty(Model.Add?.Username) || Model.Add?.Max != null || Model.Add?.Min != null || !string.IsNullOrEmpty(Model.Add?.CurrencyCode);
var showAdvancedOptions = !string.IsNullOrEmpty(Model.Add?.CurrencyCode) || Model.Add?.Min != null || Model.Add?.Max != null;
}
2021-12-31 08:36:38 +01:00
<div class="collapse @(showAddForm ? "show": "")" id="AddAddress">
2024-06-19 15:23:10 +02:00
<div class="form-group">
2021-10-29 11:01:16 +02:00
<label asp-for="Add.Username" class="form-label"></label>
<div class="input-group">
<input asp-for="Add.Username" class="form-control"/>
2021-12-31 08:36:38 +01:00
<span class="input-group-text">@@@Context.Request.Host.ToUriComponent()@Context.Request.PathBase</span>
2021-10-29 11:01:16 +02:00
</div>
<span asp-validation-for="Add.Username" class="text-danger"></span>
</div>
2022-09-20 09:50:59 +02:00
<button class="d-inline-flex align-items-center btn btn-link text-primary fw-semibold p-0 mb-3" type="button" id="AdvancedSettingsButton" data-bs-toggle="collapse" data-bs-target="#AdvancedSettings" aria-expanded="false" aria-controls="AdvancedSettings">
<vc:icon symbol="caret-down"/>
<span class="ms-1">Advanced settings</span>
</button>
2021-10-29 11:01:16 +02:00
<div id="AdvancedSettings" class="collapse @(showAdvancedOptions ? "show" : "")">
<div class="row">
<div class="col-12 col-sm-auto">
2023-04-07 10:48:58 +02:00
<div class="form-group" title="The currency to generate the invoice in when generated through this lightning address ">
2021-10-29 11:01:16 +02:00
<label asp-for="Add.CurrencyCode" class="form-label"></label>
2023-02-23 00:35:34 +09:00
<input asp-for="Add.CurrencyCode" class="form-control w-auto" currency-selection style="max-width:16ch;"/>
2021-10-29 11:01:16 +02:00
<span asp-validation-for="Add.CurrencyCode" class="text-danger"></span>
</div>
</div>
<div class="col-12 col-sm-auto">
2023-04-07 10:48:58 +02:00
<div class="form-group" title="Minimum amount of sats to allow to be sent to this ln address">
2021-10-29 11:01:16 +02:00
<label asp-for="Add.Min" class="form-label"></label>
2022-03-30 00:58:50 -07:00
<input asp-for="Add.Min" class="form-control" type="number" inputmode="numeric" min="1" style="max-width:16ch;"/>
2021-10-29 11:01:16 +02:00
<span asp-validation-for="Add.Min" class="text-danger"></span>
</div>
</div>
<div class="col-12 col-sm-auto">
2023-04-07 10:48:58 +02:00
<div class="form-group" title="Maximum amount of sats to allow to be sent to this ln address">
2021-10-29 11:01:16 +02:00
<label asp-for="Add.Max" class="form-label"></label>
2022-03-30 00:58:50 -07:00
<input asp-for="Add.Max" class="form-control" type="number" inputmode="numeric" min="1" max="@int.MaxValue" style="max-width:16ch;"/>
2021-10-29 11:01:16 +02:00
<span asp-validation-for="Add.Max" class="text-danger"></span>
</div>
</div>
2023-04-07 10:48:58 +02:00
<div class="col-12 col-sm-auto">
<div class="form-group" title="Metadata (in JSON) to add to the invoice when created through this lightning address.">
<label asp-for="Add.InvoiceMetadata" class="form-label"></label>
2023-04-12 16:30:34 +09:00
<a href="https://docs.btcpayserver.org/Development/InvoiceMetadata/" target="_blank" rel="noreferrer noopener">
<vc:icon symbol="info" />
</a>
2023-04-07 10:48:58 +02:00
<textarea asp-for="Add.InvoiceMetadata" class="form-control" ></textarea>
<span asp-validation-for="Add.InvoiceMetadata" class="text-danger"></span>
</div>
</div>
2021-10-29 11:01:16 +02:00
</div>
</div>
<div class="form-group">
<button type="submit" name="command" value="add" class="btn btn-primary">Save</button>
</div>
</div>
@if (Model.Items.Any())
{
2024-06-19 15:23:10 +02:00
<table class="table table-hover">
<thead>
<tr>
<th>Address</th>
<th>Settings</th>
<th class="text-end">Actions</th>
</tr>
</thead>
<tbody>
@for (var index = 0; index < Model.Items.Count; index++)
{
<input asp-for="Items[index].CurrencyCode" type="hidden"/>
<input asp-for="Items[index].Min" type="hidden"/>
<input asp-for="Items[index].Max" type="hidden"/>
<input asp-for="Items[index].Username" type="hidden"/>
<input asp-for="Items[index].InvoiceMetadata" type="hidden"/>
var address = $"{Model.Items[index].Username}@{Context.Request.Host.ToUriComponent()}";
<tr>
<td>
<div class="input-group" data-clipboard="@address">
<input type="text" class="form-control copy-cursor lightning-address-value" readonly="readonly" value="@address"/>
<button type="button" class="btn btn-outline-secondary px-3">
<vc:icon symbol="actions-copy" />
</button>
</div>
2021-10-29 11:01:16 +02:00
2024-06-19 15:23:10 +02:00
</td>
<td class="settings-holder align-middle">
@if (Model.Items[index].Min.HasValue)
{
<span>@Model.Items[index].Min min sats</span>
}
@if (Model.Items[index].Max.HasValue)
{
<span>@Model.Items[index].Max max sats</span>
}
@if (!string.IsNullOrEmpty(Model.Items[index].CurrencyCode))
{
<span>tracked in @Model.Items[index].CurrencyCode</span>
}
@if (!string.IsNullOrEmpty(Model.Items[index].InvoiceMetadata))
{
<span>with invoice metadata @Model.Items[index].InvoiceMetadata</span>
}
</td>
<td class="text-end">
<button type="submit" title="Remove" name="command" value="@($"remove:{Model.Items[index].Username}")" class="btn btn-link px-0 remove" data-bs-toggle="modal" data-bs-target="#ConfirmModal" data-description="The Lightning Address <strong>@Html.Encode(address)</strong> will be removed." data-confirm-input="REMOVE">
Remove
</button>
</td>
</tr>
}
</tbody>
</table>
2021-10-29 11:01:16 +02:00
}
else
{
2024-06-19 15:23:10 +02:00
<p class="text-secondary">
2021-10-29 11:01:16 +02:00
There are no Lightning Addresses yet.
</p>
}
</form>
<partial name="_Confirm" model="@(new ConfirmModel("Remove Lightning Address", "This Lightning Address will be removed.", "Remove"))" />