fix lnurl from scan button (#3332)

malik1004x committed Jun 13, 2026 at 11:19 UTC 3eaf0731205856b7575e82136c423ab38d85761f
2 files changed +20 -15
cw_core/lib/lnurl.dart
+9 -4
@@ -7,12 +7,17 @@ const _BOLT_PREFIXES = ["lnbcrt", "lntbs", "lnbc", "lntb"];
7 const _LUD17_PREFIXES = ['lnurlw', 'lnurlc', 'lnurlp', 'keyauth'];
8
9 bool isBolt11ZeroInvoice(String invoice) {
10 - final request = Bech32Codec().decode(invoice.replaceFirst("lightning:", ""), invoice.length);
10 + try {
11 + final request = Bech32Codec().decode(invoice.replaceFirst("lightning:", ""), invoice.length);
12 +
13
12 - final prefix = _BOLT_PREFIXES
13 - .firstWhere((prefix) => request.hrp.startsWith(prefix), orElse: () => "");
14 + final prefix = _BOLT_PREFIXES
15 + .firstWhere((prefix) => request.hrp.startsWith(prefix), orElse: () => "");
16
15 - return request.hrp.length == prefix.length;
17 + return request.hrp.length == prefix.length;
18 + } catch(e) {
19 + return false;
20 + }
21 }
22
23 /// Get the amount of a Bolt 11 Invoice in
lib/new-ui/widgets/coins_page/action_row/coin_action_row.dart
+11 -11
@@ -163,17 +163,17 @@ class CoinActionRow extends StatelessWidget {
163
164 late final PaymentRequest req;
165 var unspentCoinType = UnspentCoinType.any;
166 - // if (false && SendViewModelBase.isNonZeroAmountLightningInvoice(code)) {
167 - // unspentCoinType = UnspentCoinType.lightning;
168 - // final amount = CryptoCurrency.btcln.formatAmount(BigInt.from(getBolt11Amount(code) ?? 0));
169 - // req = PaymentRequest(code, amount, "", "", "");
170 - // } else if (false && SendViewModelBase.isLnurlInvoice(code)) {
171 - // unspentCoinType = UnspentCoinType.lightning;
172 - // final amount = CryptoCurrency.btcln.formatAmount(BigInt.from(await LNURL.getPayRequestAmount(code) ?? 0));
173 - // req = PaymentRequest(code, amount, "", "", "");
174 - // } else if (false &&OpenCryptoPayService.isOpenCryptoPayQR(code)) {
175 - // req = PaymentRequest(code, "", "", "", "");
176 - // } else
166 + if (SendViewModelBase.isNonZeroAmountLightningInvoice(code)) {
167 + unspentCoinType = UnspentCoinType.lightning;
168 + final amount = CryptoCurrency.btcln.formatAmount(BigInt.from(getBolt11Amount(code) ?? 0));
169 + req = PaymentRequest(code, amount, "", "", "");
170 + } else if (SendViewModelBase.isLnurlInvoice(code)) {
171 + unspentCoinType = UnspentCoinType.lightning;
172 + final amount = CryptoCurrency.btcln.formatAmount(BigInt.from(await LNURL.getPayRequestAmount(code) ?? 0));
173 + req = PaymentRequest(code, amount, "", "", "");
174 + } else if (OpenCryptoPayService.isOpenCryptoPayQR(code)) {
175 + req = PaymentRequest(code, "", "", "", "");
176 + } else
177 if (Uri.tryParse(code)?.scheme == "wc") {
178 if (!isWalletConnectCompatibleChain(walletType)) {
179 showPopUp<void>(