mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-26 06:08:40 +01:00
fix lnurl from scan button (#3332)
This commit is contained in:
@@ -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>(
|
||||
|
||||
Reference in New Issue
Block a user