File tree Expand file tree Collapse file tree
app/src/main/java/to/bitkit/viewmodels Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -758,7 +758,7 @@ class AppViewModel @Inject constructor(
758758 _sendUiState .update { it.copy(isAddressInputValid = true ) }
759759 }
760760
761- private fun validateOnChainAddress (invoice : OnChainInvoice ) {
761+ private suspend fun validateOnChainAddress (invoice : OnChainInvoice ) {
762762 val validatedAddress = runCatching { validateBitcoinAddress(invoice.address) }
763763 .getOrElse {
764764 showAddressValidationError(
@@ -778,6 +778,22 @@ class AppViewModel @Inject constructor(
778778 return
779779 }
780780
781+ // Check if this is a unified invoice with Lightning available
782+ val lnInvoice: LightningInvoice ? = invoice.params?.get(" lightning" )?.let { bolt11 ->
783+ runCatching { decode(bolt11) }.getOrNull()
784+ ?.let { it as ? Scanner .Lightning }
785+ ?.invoice
786+ ?.takeIf { lnInv ->
787+ ! lnInv.isExpired && lightningRepo.canSend(lnInv.amountSatoshis.coerceAtLeast(1u ))
788+ }
789+ }
790+
791+ // If Lightning path is available, accept the unified invoice
792+ if (lnInvoice != null ) {
793+ _sendUiState .update { it.copy(isAddressInputValid = true ) }
794+ return
795+ }
796+
781797 val maxSendOnchain = walletRepo.balanceState.value.maxSendOnchainSats
782798
783799 if (maxSendOnchain == 0uL ) {
You can’t perform that action at this time.
0 commit comments