@@ -22,7 +22,6 @@ import com.synonym.bitkitcore.LnurlWithdrawData
2222import com.synonym.bitkitcore.OnChainInvoice
2323import com.synonym.bitkitcore.PaymentType
2424import com.synonym.bitkitcore.Scanner
25- import com.synonym.bitkitcore.decode
2625import com.synonym.bitkitcore.validateBitcoinAddress
2726import dagger.hilt.android.lifecycle.HiltViewModel
2827import dagger.hilt.android.qualifiers.ApplicationContext
@@ -101,6 +100,7 @@ import to.bitkit.repositories.SweepRepo
101100import to.bitkit.repositories.TransferRepo
102101import to.bitkit.repositories.WalletRepo
103102import to.bitkit.services.AppUpdaterService
103+ import to.bitkit.services.CoreService
104104import to.bitkit.services.MigrationService
105105import to.bitkit.ui.Routes
106106import to.bitkit.ui.components.Sheet
@@ -149,6 +149,7 @@ class AppViewModel @Inject constructor(
149149 private val transferRepo : TransferRepo ,
150150 private val migrationService : MigrationService ,
151151 private val sweepRepo : SweepRepo ,
152+ private val coreService : CoreService ,
152153 private val appUpdateSheet : AppUpdateTimedSheet ,
153154 private val backupSheet : BackupTimedSheet ,
154155 private val notificationsSheet : NotificationsTimedSheet ,
@@ -715,7 +716,7 @@ class AppViewModel @Inject constructor(
715716 return @withContext
716717 }
717718
718- val scanResult = runCatching { decode(input) }
719+ val scanResult = runCatching { coreService. decode(input) }
719720
720721 if (scanResult.isFailure) {
721722 showAddressValidationError(
@@ -819,7 +820,7 @@ class AppViewModel @Inject constructor(
819820
820821 private suspend fun extractViableLightningInvoice (params : Map <String , String >? ): LightningInvoice ? =
821822 params?.get(" lightning" )?.let { bolt11 ->
822- runCatching { decode(bolt11) }.getOrNull()
823+ runCatching { coreService. decode(bolt11) }.getOrNull()
823824 ?.let { it as ? Scanner .Lightning }
824825 ?.invoice
825826 ?.takeIf { lnInv ->
@@ -1043,8 +1044,7 @@ class AppViewModel @Inject constructor(
10431044 return @withContext
10441045 }
10451046
1046- @Suppress(" ForbiddenComment" ) // TODO: wrap `decode` from bindings in a `CoreService` method and call that one
1047- val scan = runCatching { decode(result) }
1047+ val scan = runCatching { coreService.decode(result) }
10481048 .onFailure { Logger .error(" Failed to decode scan data: '$result '" , it, context = TAG ) }
10491049 .onSuccess { Logger .info(" Handling decoded scan data: $it " , context = TAG ) }
10501050 .getOrNull()
@@ -2111,6 +2111,10 @@ class AppViewModel @Inject constructor(
21112111 }
21122112 // endregion
21132113
2114+ suspend fun canDecodeClipboard (text : String ): Boolean = withContext(bgDispatcher) {
2115+ runCatching { coreService.decode(text) }.isSuccess
2116+ }
2117+
21142118 fun onClipboardAutoRead (data : String ) {
21152119 viewModelScope.launch {
21162120 mainScreenEffect(MainScreenEffect .ProcessClipboardAutoRead (data))
0 commit comments