fix lnurl from scan button (#3332)

This commit is contained in:
malik1004x
2026-06-13 11:19:47 +02:00
committed by GitHub
parent d64199e15a
commit 3eaf073120
2 changed files with 20 additions and 15 deletions
+9 -4
View File
@@ -7,12 +7,17 @@ const _BOLT_PREFIXES = ["lnbcrt", "lntbs", "lnbc", "lntb"];
const _LUD17_PREFIXES = ['lnurlw', 'lnurlc', 'lnurlp', 'keyauth'];
bool isBolt11ZeroInvoice(String invoice) {
final request = Bech32Codec().decode(invoice.replaceFirst("lightning:", ""), invoice.length);
try {
final request = Bech32Codec().decode(invoice.replaceFirst("lightning:", ""), invoice.length);
final prefix = _BOLT_PREFIXES
.firstWhere((prefix) => request.hrp.startsWith(prefix), orElse: () => "");
return request.hrp.length == prefix.length;
final prefix = _BOLT_PREFIXES
.firstWhere((prefix) => request.hrp.startsWith(prefix), orElse: () => "");
return request.hrp.length == prefix.length;
} catch(e) {
return false;
}
}
/// Get the amount of a Bolt 11 Invoice in
@@ -163,17 +163,17 @@ class CoinActionRow extends StatelessWidget {
late final PaymentRequest req;
var unspentCoinType = UnspentCoinType.any;
// if (false && SendViewModelBase.isNonZeroAmountLightningInvoice(code)) {
// unspentCoinType = UnspentCoinType.lightning;
// final amount = CryptoCurrency.btcln.formatAmount(BigInt.from(getBolt11Amount(code) ?? 0));
// req = PaymentRequest(code, amount, "", "", "");
// } else if (false && SendViewModelBase.isLnurlInvoice(code)) {
// unspentCoinType = UnspentCoinType.lightning;
// final amount = CryptoCurrency.btcln.formatAmount(BigInt.from(await LNURL.getPayRequestAmount(code) ?? 0));
// req = PaymentRequest(code, amount, "", "", "");
// } else if (false &&OpenCryptoPayService.isOpenCryptoPayQR(code)) {
// req = PaymentRequest(code, "", "", "", "");
// } else
if (SendViewModelBase.isNonZeroAmountLightningInvoice(code)) {
unspentCoinType = UnspentCoinType.lightning;
final amount = CryptoCurrency.btcln.formatAmount(BigInt.from(getBolt11Amount(code) ?? 0));
req = PaymentRequest(code, amount, "", "", "");
} else if (SendViewModelBase.isLnurlInvoice(code)) {
unspentCoinType = UnspentCoinType.lightning;
final amount = CryptoCurrency.btcln.formatAmount(BigInt.from(await LNURL.getPayRequestAmount(code) ?? 0));
req = PaymentRequest(code, amount, "", "", "");
} else if (OpenCryptoPayService.isOpenCryptoPayQR(code)) {
req = PaymentRequest(code, "", "", "", "");
} else
if (Uri.tryParse(code)?.scheme == "wc") {
if (!isWalletConnectCompatibleChain(walletType)) {
showPopUp<void>(