From 0150f0dc0c98ec780311a037cabb7902c203b746 Mon Sep 17 00:00:00 2001 From: jvsena42 Date: Fri, 6 Feb 2026 14:39:39 -0300 Subject: [PATCH 1/3] fix: remove lightning scheme --- .../java/to/bitkit/viewmodels/AppViewModel.kt | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt b/app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt index 47f8d7f36..f36b0fb79 100644 --- a/app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt +++ b/app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt @@ -1067,8 +1067,10 @@ class AppViewModel @Inject constructor( resetSendState() resetQuickPay() + val input = result.removeLightningSchemes() + // TODO Workaround for https://github.com/synonymdev/bitkit-core/issues/63 - if (Bip21Utils.isDuplicatedBip21(result)) { + if (Bip21Utils.isDuplicatedBip21(input)) { toast( type = Toast.ToastType.ERROR, title = context.getString(R.string.other__scan_err_decoding), @@ -1078,14 +1080,14 @@ class AppViewModel @Inject constructor( return@withContext } - val scan = runCatching { coreService.decode(result) } - .onFailure { Logger.error("Failed to decode scan data: '$result'", it, context = TAG) } + val scan = runCatching { coreService.decode(input) } + .onFailure { Logger.error("Failed to decode scan data: '$input'", it, context = TAG) } .onSuccess { Logger.info("Handling decoded scan data: $it", context = TAG) } .getOrNull() when (scan) { - is Scanner.OnChain -> onScanOnchain(scan.invoice, result) - is Scanner.Lightning -> onScanLightning(scan.invoice, result) + is Scanner.OnChain -> onScanOnchain(scan.invoice, input) + is Scanner.Lightning -> onScanLightning(scan.invoice, input) is Scanner.LnurlPay -> onScanLnurlPay(scan.data) is Scanner.LnurlWithdraw -> onScanLnurlWithdraw(scan.data) is Scanner.LnurlAuth -> onScanLnurlAuth(scan.data) @@ -2221,17 +2223,18 @@ class AppViewModel @Inject constructor( val data = uri.toString() delay(SCREEN_TRANSITION_DELAY_MS) - handleScan(data.removeLightningSchemes()) + handleScan(data) } // TODO Temporary fix while these schemes can't be decoded @Suppress("SpellCheckingInspection") private fun String.removeLightningSchemes(): String { return this - .replace("lnurl:", "") - .replace("lnurlw:", "") - .replace("lnurlc:", "") - .replace("lnurlp:", "") + .replace(Regex("^lightning:", RegexOption.IGNORE_CASE), "") + .replace(Regex("^lnurl:", RegexOption.IGNORE_CASE), "") + .replace(Regex("^lnurlw:", RegexOption.IGNORE_CASE), "") + .replace(Regex("^lnurlc:", RegexOption.IGNORE_CASE), "") + .replace(Regex("^lnurlp:", RegexOption.IGNORE_CASE), "") } fun checkTimedSheets() = timedSheetManager.onHomeScreenEntered() From 0ae190bece08c4fd2daf6f9dd05b12ac8b8c4964 Mon Sep 17 00:00:00 2001 From: jvsena42 Date: Mon, 9 Feb 2026 11:03:11 -0300 Subject: [PATCH 2/3] chore: add issue link --- app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt b/app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt index cfcd26040..e211e460a 100644 --- a/app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt +++ b/app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt @@ -2226,7 +2226,7 @@ class AppViewModel @Inject constructor( handleScan(data) } - // TODO Temporary fix while these schemes can't be decoded + // TODO Temporary fix while these schemes can't be decoded https://github.com/synonymdev/bitkit-core/issues/70 @Suppress("SpellCheckingInspection") private fun String.removeLightningSchemes(): String { return this From 5599b699eafb768be25999c25d45d0a0f7c0d3ab Mon Sep 17 00:00:00 2001 From: jvsena42 Date: Mon, 9 Feb 2026 11:17:16 -0300 Subject: [PATCH 3/3] fix: add validation also to manual input --- app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt b/app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt index e211e460a..da614ec88 100644 --- a/app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt +++ b/app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt @@ -750,7 +750,7 @@ class AppViewModel @Inject constructor( return@withContext } - val scanResult = runCatching { coreService.decode(input) } + val scanResult = runCatching { coreService.decode(input.removeLightningSchemes()) } if (scanResult.isFailure) { showAddressValidationError(