File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
app/src/main/java/to/bitkit/viewmodels Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -535,16 +535,24 @@ class AppViewModel @Inject constructor(
535535
536536 private suspend fun onScanOnchain (invoice : OnChainInvoice , scanResult : String ) {
537537 val lnInvoice: LightningInvoice ? = invoice.params?.get(" lightning" )?.let { bolt11 ->
538- val decoded = runCatching { decode(bolt11) }.getOrNull()
539- (decoded as ? Scanner .Lightning )?.invoice
538+ runCatching { decode(bolt11) }.getOrNull()
539+ ?.let { it as ? Scanner .Lightning }
540+ ?.invoice
541+ ?.takeIf { invoice ->
542+ val canSend = lightningRepo.canSend(invoice.amountSatoshis.coerceAtLeast(1u ))
543+ if (! canSend) {
544+ Logger .debug(" Cannot pay unified invoice using LN, defaulting to onchain-only" , context = TAG )
545+ }
546+ return @takeIf canSend
547+ }
540548 }
541549 _sendUiState .update {
542550 it.copy(
543551 address = invoice.address,
544552 addressInput = scanResult,
545553 isAddressInputValid = true ,
546554 amount = invoice.amountSatoshis,
547- isUnified = invoice.params?.containsKey( " lightning " ) == true ,
555+ isUnified = lnInvoice != null ,
548556 decodedInvoice = lnInvoice,
549557 payMethod = lnInvoice?.let { SendMethod .LIGHTNING } ? : SendMethod .ONCHAIN ,
550558 )
You can’t perform that action at this time.
0 commit comments