ToUpper for lightning invoice part of unified QR code

Ref: https://github.com/btcpayserver/btcpayserver/pull/2060#issuecomment-723828348
This commit is contained in:
rockstardev
2020-11-09 02:05:17 -06:00
parent 4dd0ae8bdc
commit c581b80132

View File

@@ -55,18 +55,23 @@ namespace BTCPayServer.Payments.Bitcoin
model.IsLightning = false;
model.PaymentMethodName = GetPaymentMethodName(network);
var invoiceBitcoinUrl = cryptoInfo.PaymentUrls.BIP21;
var lightningFallback = "";
if (storeBlob.OnChainWithLnInvoiceFallback)
{
var lightningInfo = invoiceResponse.CryptoInfo.FirstOrDefault(a =>
a.GetpaymentMethodId() == new PaymentMethodId(model.CryptoCode, PaymentTypes.LightningLike));
if (!String.IsNullOrEmpty(lightningInfo?.PaymentUrls?.BOLT11))
invoiceBitcoinUrl += "&" + lightningInfo.PaymentUrls.BOLT11.Replace("lightning:", "lightning=", StringComparison.OrdinalIgnoreCase);
lightningFallback = "&" + lightningInfo.PaymentUrls.BOLT11.Replace("lightning:", "lightning=", StringComparison.OrdinalIgnoreCase);
}
model.InvoiceBitcoinUrl = invoiceBitcoinUrl;
model.InvoiceBitcoinUrlQR = invoiceBitcoinUrl;
model.InvoiceBitcoinUrl = cryptoInfo.PaymentUrls.BIP21 + lightningFallback;
// We're trying to make as many characters uppercase to make QR smaller
// Ref: https://github.com/btcpayserver/btcpayserver/pull/2060#issuecomment-723828348
model.InvoiceBitcoinUrlQR = cryptoInfo.PaymentUrls.BIP21
// .Replace("bitcoin:", "BITCOIN:", StringComparison.OrdinalIgnoreCase)
+ lightningFallback.ToUpperInvariant().Replace("LIGHTNING=", "lightning=", StringComparison.OrdinalIgnoreCase);
;
}
public override string GetCryptoImage(PaymentMethodId paymentMethodId)