What changed, and why it matters
This commit fixes how QR codes are generated for LNURL (a way to pay or log in via Bitcoin Lightning). Previously, non-Bech32 URI-style LNURLs were being converted to ALL UPPERCASE for QR codes, which can break some QR readers and wallet apps because the 'lightning:' prefix should stay lowercase. The change makes QR codes keep the correct casing depending on the LNURL format, reducing the chance that a customer or user can't scan or pay.
Treat as a low-risk bugfix. Verify that QR codes for both Bech32 and URI-style LNURLs scan correctly with common Lightning wallets after deployment. No urgent security response is indicated.
Security signals we found
QR-code URI casing corrected to match expected wallet behavior
Potential denial-of-payment / usability failure from malformed uppercase URI scheme
No input validation, authentication, or cryptographic changes observed
Evidence from the diff
The patch centralizes QR-code formatting for LNURL payment links into a new helper, FormatPaymentLinkForQRCode. In Bech32 mode it uppercases the whole string but re-lowercases the ‘LIGHTNING:’ scheme prefix; in non-Bech32 URI mode it leaves the original casing unchanged. Previously, non-Bech32 URIs were also uppercased, producing invalid-looking ‘LIGHTNING://…’ URIs that some wallets/QR scanners may reject. The same fix is applied to checkout, point-of-sale print view, and LNURL-auth login/create views.
Changed components
BTCPayServer/Payments/LNURLPay/LNURLCheckoutModelExtension.csBTCPayServer/Payments/LNURLPay/LNURLPayPaymentLinkExtension.csBTCPayServer/Plugins/PointOfSale/Views/Public/Print.cshtmlBTCPayServer/Views/UIAccount/LoginWithLNURLAuth.cshtmlBTCPayServer/Views/UILNURLAuth/Create.cshtmlInspect captured patch +14 / −5
### BTCPayServer/Payments/LNURLPay/LNURLCheckoutModelExtension.cs
@@ -32,14 +32,15 @@ public LNURLCheckoutModelExtension(
private const string UriScheme = "lightning:";
public void ModifyCheckoutModel(CheckoutModelContext context)
{
- if (context is not { Handler: LNURLPayPaymentHandler })
+ if (context is not { Handler: LNURLPayPaymentHandler handler })
return;
var lnurl = paymentLinkExtension.GetPaymentLink(context.Prompt, context.UrlHelper);
if (lnurl is not null)
{
+ var details = handler.ParsePaymentPromptDetails(context.Prompt.Details);
context.Model.Address = lnurl.Replace(UriScheme, "");
context.Model.InvoiceBitcoinUrl = lnurl;
- context.Model.InvoiceBitcoinUrlQR = lnurl.ToUpperInvariant().Replace(UriScheme.ToUpperInvariant(), UriScheme);
+ context.Model.InvoiceBitcoinUrlQR = LNURLPayPaymentLinkExtension.FormatPaymentLinkForQRCode(lnurl, details.Bech32Mode);
}
context.Model.CheckoutBodyComponentName = LNCheckoutModelExtension.CheckoutBodyComponentName;
if (context.StoreBlob.LightningAmountInSatoshi && context.Model.PaymentMethodCurrency == "BTC")
### BTCPayServer/Payments/LNURLPay/LNURLPayPaymentLinkExtension.cs
@@ -22,6 +22,13 @@ public LNURLPayPaymentLinkExtension(
}
public PaymentMethodId PaymentMethodId { get; }
+ internal static string FormatPaymentLinkForQRCode(string paymentLink, bool bech32Mode)
+ {
+ return bech32Mode
+ ? paymentLink.ToUpperInvariant().Replace("LIGHTNING:", "lightning:")
+ : paymentLink;
+ }
+
public string? GetPaymentLink(PaymentPrompt paymentPrompt, IUrlHelper? urlHelper)
{
if (!_handlers.TryGetValue(PaymentMethodId, out var o) || o is not LNURLPayPaymentHandler handler)
### BTCPayServer/Plugins/PointOfSale/Views/Public/Print.cshtml
@@ -1,6 +1,7 @@
@using BTCPayServer.Client.Models
@using BTCPayServer.Payments
@using BTCPayServer.Payments.Lightning
+@using BTCPayServer.Payments.LNURLPay
@using BTCPayServer.Plugins.PointOfSale.Models
@using BTCPayServer.Services
@using BTCPayServer.Services.Invoices
@@ -128,7 +129,7 @@ else
}, Context.Request.Scheme, Context.Request.Host.ToString())!);
var lnUrl = LNURL.EncodeUri(lnurlEndpoint, "payRequest", supported.UseBech32Scheme);
<a href="@lnUrl" rel="noreferrer noopener" class="card-img-bottom">
- <vc:qr-code data="@lnUrl.ToString().ToUpperInvariant()" />
+ <vc:qr-code data="@LNURLPayPaymentLinkExtension.FormatPaymentLinkForQRCode(lnUrl.ToString(), supported.UseBech32Scheme)" />
</a>
}
}
### BTCPayServer/Views/UIAccount/LoginWithLNURLAuth.cshtml
@@ -3,7 +3,7 @@
Dictionary<string, string> formats = new Dictionary<string, string>()
{
{ "Bech32", LNURL.LNURL.EncodeUri(Model.LNURLEndpoint, "login", true).ToString().ToUpperInvariant() },
- { "URI", LNURL.LNURL.EncodeUri(Model.LNURLEndpoint, "login", false).ToString().ToUpperInvariant() }
+ { "URI", LNURL.LNURL.EncodeUri(Model.LNURLEndpoint, "login", false).ToString() }
};
}
### BTCPayServer/Views/UILNURLAuth/Create.cshtml
@@ -5,7 +5,7 @@
var formats = new Dictionary<string, string>
{
{ "Bech32", LNURL.EncodeUri(Model, "login", true).ToString().ToUpperInvariant() },
- { "URI", LNURL.EncodeUri(Model, "login", false).ToString().ToUpperInvariant() }
+ { "URI", LNURL.EncodeUri(Model, "login", false).ToString() }
};
}
Why this scored 25/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.