Fix JavaScript errors and browser warnings in payment workflows
What changed, and why it matters
This commit fixes a collection of small UI and JavaScript bugs in BTCPay Server's payment workflows. The changes include correcting how dates are formatted in form fields, fixing a passphrase-confirmation validation bug, changing some HTTP status codes from 404 to 204, adding a missing JSON endpoint for payment-request labels, and cleaning up minor HTML/preload issues. Most fixes are functional or user-experience improvements rather than security vulnerabilities. The most security-relevant item is the passphrase-confirmation fix, which previously could have allowed a form to submit when passphrases did not match because of a JavaScript error, but the practical impact is limited because server-side validation would still apply.
Treat as a routine bug-fix commit. Review the new `PaymentRequestLabelsJson` endpoint to confirm it has appropriate authorization/permissions consistent with the existing `PaymentRequestLabels` action, since the diff does not show an `[Authorize]` attribute. Verify that the passphrase-confirmation fix is sufficient and that server-side validation still enforces passphrase matching. No urgent security response appears warranted based solely on the supplied diff.
Security signals we found
Client-side passphrase confirmation validation was broken due to unquoted localized string and duplicate-ID selector; patch fixes it.
LNURL-auth polling endpoints changed from 404 to 204, and front-end polling now checks for 204 explicitly, reducing accidental redirect/fallback behavior.
New payment-request labels JSON endpoint added without an explicit authorization attribute in the shown diff (the existing `labels` endpoint has one).
Sound preload links changed from invalid `as=audio` to `as=fetch` with `crossorigin=anonymous`.
Evidence from the diff
The commit is a mixed bag of front-end and minor controller fixes. Key technical changes: (1) _GenerateWalletForm.cshtml now uses class-based selectors instead of duplicate IDs and properly JSON-encodes the localized error string, fixing a client-side passphrase confirmation check that could fail silently. (2) UILNURLAuthController returns NoContent() instead of NotFound() for pending LNURL-auth checks, and the corresponding views now look for HTTP 204 instead of any non-200 status. (3) UIPaymentRequestController adds a new labels.json endpoint used by the LabelManager component when linked to a payment request. (4) Date inputs in crowdfund and payment-request forms switch from datetime-local to type='text' with ISO 8601 (‘o’) formatting to avoid browser validation warnings. (5) Preload links for sounds use as='fetch' with crossorigin='anonymous' instead of invalid as='audio'. (6) A duplicate blank line and an unnecessary data-bs-toggle='modal' attribute are removed. No explicit security disclosure or CVE is present in the commit materials.
Changed components
BTCPayServer/Plugins/Wallets/Views/UIStoreOnChainWallets/_GenerateWalletForm.cshtmlBTCPayServer/Controllers/UILNURLAuthController.csBTCPayServer/Views/UIAccount/LoginWithLNURLAuth.cshtmlBTCPayServer/Views/UILNURLAuth/Create.cshtmlBTCPayServer/Controllers/UIPaymentRequestController.csBTCPayServer/Components/LabelManager/Default.cshtmlBTCPayServer/Plugins/Crowdfund/Views/UpdateCrowdfund.cshtmlBTCPayServer/Views/UIPaymentRequest/EditPaymentRequest.cshtmlBTCPayServer/Views/UIInvoice/Checkout.cshtmlBTCPayServer/Views/UIStores/Rates.Source.cshtmlBTCPayServer.Tests/MultisigTests.csBTCPayServer.Tests/RolesTests.csInspect captured patch +40 / −21
### BTCPayServer.Tests/MultisigTests.cs
@@ -837,7 +837,7 @@ await page.Context.AddInitScriptAsync($$"""
const fingerprint = {{System.Text.Json.JsonSerializer.Serialize(fingerprint)}};
window.__vaultRequests = [];
window.fetch = async (input, init) => {
- const url = typeof input === 'string' ? input : input.url;
+ const url = input instanceof Request ? input.url : String(input);
if (!url.startsWith('http://127.0.0.1:65092/hwi-bridge/v1')) {
return originalFetch(input, init);
}
### BTCPayServer.Tests/RolesTests.cs
@@ -898,6 +898,7 @@ public async Task CanUsePredefinedRoles()
await s.AssertPageAccess(true, GetStorePath("invoices/create"));
await s.AssertPageAccess(true, GetStorePath("payment-requests"));
await s.AssertPageAccess(true, GetStorePath("payment-requests/new"));
+ await Expect(s.Page.Locator("input.label-manager.tomselected")).ToHaveCountAsync(1);
await s.AssertPageAccess(true, GetStorePath("pull-payments"));
await s.AssertPageAccess(true, GetStorePath("payouts"));
await s.AssertPageAccess(false, GetStorePath("onchain/BTC"));
### BTCPayServer/Components/LabelManager/Default.cshtml
@@ -22,6 +22,11 @@
excludeTypes = Safe.Json(Model.ExcludeTypes),
linkedType = Model.LinkedType
})
+ : Model.LinkedType == WalletObjectData.Types.PaymentRequest
+ ? Url.Action("PaymentRequestLabelsJson", "UIPaymentRequest", new {
+ storeId = Model.StoreId,
+ excludeTypes = Model.ExcludeTypes
+ })
: Url.Action("StoreLabelsJson", "UIStores", new {
storeId = Model.StoreId,
excludeTypes = Safe.Json(Model.ExcludeTypes),
### BTCPayServer/Controllers/UILNURLAuthController.cs
@@ -97,7 +97,7 @@ public Task<IActionResult> CreateCheck()
return Task.FromResult<IActionResult>(Ok());
}
- return Task.FromResult<IActionResult>(NotFound());
+ return Task.FromResult<IActionResult>(NoContent());
}
[HttpGet("register-callback")]
@@ -135,7 +135,7 @@ public IActionResult CreateComplete()
public async Task<IActionResult> LoginCheck()
{
var user = await _signInManager.GetTwoFactorAuthenticationUserAsync();
- return _lnurlAuthService.LoginStore.ContainsKey(user?.Id ?? "") ? Ok() : NotFound();
+ return _lnurlAuthService.LoginStore.ContainsKey(user?.Id ?? "") ? Ok() : NoContent();
}
[HttpGet("login-callback")]
### BTCPayServer/Controllers/UIPaymentRequestController.cs
@@ -576,6 +576,20 @@ public async Task<IActionResult> TogglePaymentRequestCompleted(string payReqId)
return RedirectToAction("GetPaymentRequests", new { storeId = HttpContext.GetStoreData().Id });
}
+ [HttpGet("/stores/{storeId}/payment-requests/labels.json")]
+ public async Task<IActionResult> PaymentRequestLabelsJson(string storeId, bool excludeTypes = true)
+ {
+ var labels = await _storeLabelRepository.GetStoreLabels(storeId, WalletObjectData.Types.PaymentRequest);
+ return Ok(labels
+ .Where(l => !excludeTypes || !WalletObjectData.Types.AllTypes.Contains(l.Label))
+ .Select(l => new WalletLabelModel
+ {
+ Label = l.Label,
+ Color = l.Color,
+ TextColor = ColorPalette.Default.TextColor(l.Color)
+ }));
+ }
+
[HttpGet("/stores/{storeId}/payment-requests/labels")]
[Authorize(Policy = Policies.CanViewPaymentRequests, AuthenticationSchemes = AuthenticationSchemes.Cookie)]
public async Task<IActionResult> PaymentRequestLabels(string storeId)
### BTCPayServer/Plugins/Crowdfund/Views/UpdateCrowdfund.cshtml
@@ -139,8 +139,8 @@
<div class="form-group mb-0 w-250px">
<label asp-for="StartDate" class="form-label"></label>
<div class="input-group flex-nowrap">
- <input type="datetime-local" asp-for="StartDate"
- value="@(Model.StartDate?.ToString("u", CultureInfo.InvariantCulture))"
+ <input type="text" asp-for="StartDate"
+ value="@(Model.StartDate?.ToString("o", CultureInfo.InvariantCulture))"
class="form-control flatdtpicker"
placeholder="@StringLocalizer["No start date has been set"]" />
<button class="btn btn-secondary input-group-clear px-3" type="button" title="Clear">
@@ -151,8 +151,8 @@
<div class="form-group mb-0 w-250px">
<label asp-for="EndDate" class="form-label"></label>
<div class="input-group flex-nowrap">
- <input type="datetime-local" asp-for="EndDate"
- value="@(Model.EndDate?.ToString("u", CultureInfo.InvariantCulture))"
+ <input type="text" asp-for="EndDate"
+ value="@(Model.EndDate?.ToString("o", CultureInfo.InvariantCulture))"
class="form-control flatdtpicker"
placeholder="@StringLocalizer["No end date has been set"]" />
<button class="btn btn-secondary input-group-clear px-3" type="button" title="Clear" id="clear_end">
### BTCPayServer/Plugins/Wallets/Views/UIStoreOnChainWallets/_GenerateWalletForm.cshtml
@@ -18,7 +18,7 @@
</div>
}
-<form id="generate-wallet-form" method="post" asp-controller="UIStoreOnChainWallets" asp-action="GenerateWallet" asp-route-storeId="@Context.GetRouteValue("storeId")" asp-route-cryptoCode="@Context.GetRouteValue("cryptoCode")" asp-route-method="@method">
+<form id="generate-wallet-form" class="wallet-generation" method="post" asp-controller="UIStoreOnChainWallets" asp-action="GenerateWallet" asp-route-storeId="@Context.GetRouteValue("storeId")" asp-route-cryptoCode="@Context.GetRouteValue("cryptoCode")" asp-route-method="@method">
@if (isImport)
{
<div class="form-group">
@@ -110,7 +110,7 @@
<div class="form-group">
<label for="passphrase_conf" class="form-label" text-translate="true">Confirm passphrase</label>
<input type="text" name="passphrase_conf" id="passphrase_conf" class="form-control"/>
- <span class="text-danger field-validation-valid" id="passphrase_conf_validation"></span>
+ <span class="text-danger field-validation-valid wallet-generation__passphrase-error" id="passphrase_conf_validation"></span>
</div>
</div>
</div>
@@ -126,13 +126,13 @@
</form>
<script>
- document.getElementById("generate-wallet-form").addEventListener("submit", event => {
+ document.querySelector(".wallet-generation").addEventListener("submit", event => {
const $form = event.currentTarget;
if ($form.elements["passphrase_conf"].value !== $form.elements["Passphrase"].value) {
- const $validation = document.getElementById("passphrase_conf_validation");
+ const $validation = $form.querySelector(".wallet-generation__passphrase-error");
$validation.classList.remove("field-validation-valid");
- $validation.innerText = @StringLocalizer["Invalid passphrase confirmation"];
+ $validation.innerText = @Safe.Json(StringLocalizer["Invalid passphrase confirmation"].Value);
event.preventDefault();
}
});
### BTCPayServer/Views/UIAccount/LoginWithLNURLAuth.cshtml
@@ -48,7 +48,7 @@
request.onload = function() {
if (request.readyState === 4 && request.status === 200) {
setTimeout(check, 1000);
- } else if (request.readyState === 4 ){
+ } else if (request.readyState === 4 && request.status === 204) {
document.getElementById("authform").submit();
}
}
### BTCPayServer/Views/UIInvoice/Checkout.cshtml
@@ -23,15 +23,15 @@
<link href="~/checkout/checkout.css" asp-append-version="true" rel="stylesheet" />
@if (!string.IsNullOrEmpty(Model.PaymentSoundUrl))
{
- <link rel="preload" href="@Model.PaymentSoundUrl" as="audio" />
+ <link rel="preload" href="@Model.PaymentSoundUrl" as="fetch" crossorigin="anonymous" />
}
@if (!string.IsNullOrEmpty(Model.NfcReadSoundUrl))
{
- <link rel="preload" href="@Model.NfcReadSoundUrl" as="audio" />
+ <link rel="preload" href="@Model.NfcReadSoundUrl" as="fetch" crossorigin="anonymous" />
}
@if (!string.IsNullOrEmpty(Model.ErrorSoundUrl))
{
- <link rel="preload" href="@Model.ErrorSoundUrl" as="audio" />
+ <link rel="preload" href="@Model.ErrorSoundUrl" as="fetch" crossorigin="anonymous" />
}
</head>
<body class="min-vh-100">
### BTCPayServer/Views/UILNURLAuth/Create.cshtml
@@ -51,7 +51,7 @@
request.onload = function() {
if (request.readyState === 4 && request.status === 200) {
setTimeout(check, 1000);
- } else if (request.readyState === 4 ){
+ } else if (request.readyState === 4 && request.status === 204) {
window.location.href = @Safe.Json(Url.Action("CreateComplete"));
}
}
### BTCPayServer/Views/UIPaymentRequest/EditPaymentRequest.cshtml
@@ -118,8 +118,8 @@
<div class="form-group">
<label asp-for="ExpiryDate" class="form-label"></label>
<div class="input-group ">
- <input asp-for="ExpiryDate"
- value="@(Model.ExpiryDate?.ToString("u", CultureInfo.InvariantCulture))"
+ <input type="text" asp-for="ExpiryDate"
+ value="@(Model.ExpiryDate?.ToString("o", CultureInfo.InvariantCulture))"
class="form-control flatdtpicker" min="today" placeholder="@StringLocalizer["No expiry date has been set for this payment request"]" />
<button id="ClearExpiryDate" class="btn btn-secondary input-group-clear" type="button" title="@StringLocalizer["Clear"]">
<vc:icon symbol="close" />
### BTCPayServer/Views/UIStores/Rates.Source.cshtml
@@ -39,7 +39,7 @@ else
}
else
{
- <button type="submit" id="@Html.IdFor(o => o.ShowScripting)_submit" class="btcpay-toggle me-3" value="scripting-toggle-@(Model.IsFallback ? "fallback" : "primary")" name="command" data-bs-toggle="modal" permission="@Policies.CanModifyStoreSettings" text-translate="true">Enable advanced rate rule scripting</button>
+ <button type="submit" id="@Html.IdFor(o => o.ShowScripting)_submit" class="btcpay-toggle me-3" value="scripting-toggle-@(Model.IsFallback ? "fallback" : "primary")" name="command" permission="@Policies.CanModifyStoreSettings" text-translate="true">Enable advanced rate rule scripting</button>
}
<div>
@@ -56,4 +56,3 @@ else
</label>
</div>
-Why this scored 21/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.