mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-03-03 09:29:10 +01:00
Uppercasing destination address in QR code if it's Bech32
This commit is contained in:
parent
f17a6f13a4
commit
35e45333b1
2 changed files with 12 additions and 2 deletions
|
@ -2006,7 +2006,7 @@ namespace BTCPayServer.Tests
|
|||
await tester.EnsureChannelsSetup();
|
||||
var user = tester.NewAccount();
|
||||
user.GrantAccess();
|
||||
user.RegisterDerivationScheme("BTC");
|
||||
user.RegisterDerivationScheme("BTC", ScriptPubKeyType.Segwit);
|
||||
user.RegisterLightningNode("BTC", LightningConnectionType.CLightning);
|
||||
|
||||
var invoice = user.BitPay.CreateInvoice(
|
||||
|
@ -2043,6 +2043,8 @@ namespace BTCPayServer.Tests
|
|||
);
|
||||
Assert.Contains("&lightning=", paymentMethodSecond.InvoiceBitcoinUrlQR);
|
||||
Assert.StartsWith("BITCOIN:", paymentMethodSecond.InvoiceBitcoinUrlQR);
|
||||
var split = paymentMethodSecond.InvoiceBitcoinUrlQR.Split('?')[0];
|
||||
Assert.True($"BITCOIN:{paymentMethodSecond.BtcAddress.ToUpperInvariant()}" == split);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -71,8 +71,16 @@ namespace BTCPayServer.Payments.Bitcoin
|
|||
model.InvoiceBitcoinUrlQR = cryptoInfo.PaymentUrls.BIP21
|
||||
.Replace("bitcoin:", "BITCOIN:", StringComparison.OrdinalIgnoreCase)
|
||||
+ lightningFallback.ToUpperInvariant().Replace("LIGHTNING=", "lightning=", StringComparison.OrdinalIgnoreCase);
|
||||
;
|
||||
|
||||
if (bech32Prefixes.Any(a => model.BtcAddress.StartsWith(a, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
model.InvoiceBitcoinUrlQR = model.InvoiceBitcoinUrlQR.Replace(
|
||||
$"BITCOIN:{model.BtcAddress}", $"BITCOIN:{model.BtcAddress.ToUpperInvariant()}",
|
||||
StringComparison.OrdinalIgnoreCase
|
||||
);
|
||||
}
|
||||
}
|
||||
private static string[] bech32Prefixes = new[] { "bc1", "tb1", "bcrt1" };
|
||||
|
||||
public override string GetCryptoImage(PaymentMethodId paymentMethodId)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue