Skip to content

Commit 725dfff

Browse files
committed
fix(receive): dont request more liquidity for 0 channels
1 parent 75ba763 commit 725dfff

File tree

1 file changed

+3
-22
lines changed

1 file changed

+3
-22
lines changed

app/src/main/java/to/bitkit/repositories/WalletRepo.kt

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ import kotlinx.coroutines.withContext
1717
import kotlinx.datetime.Clock
1818
import org.lightningdevkit.ldknode.BalanceDetails
1919
import org.lightningdevkit.ldknode.Event
20-
import org.lightningdevkit.ldknode.Txid
2120
import to.bitkit.data.AppDb
2221
import to.bitkit.data.CacheStore
2322
import to.bitkit.data.SettingsStore
2423
import to.bitkit.data.entities.TagMetadataEntity
2524
import to.bitkit.data.keychain.Keychain
2625
import to.bitkit.di.BgDispatcher
2726
import to.bitkit.env.Env
27+
import to.bitkit.ext.filterOpen
2828
import to.bitkit.ext.nowTimestamp
2929
import to.bitkit.ext.toHex
3030
import to.bitkit.ext.totalNextOutboundHtlcLimitSats
@@ -422,6 +422,8 @@ class WalletRepo @Inject constructor(
422422
if (coreService.checkGeoStatus() == true) return@withContext Result.success(false)
423423

424424
val channels = lightningRepo.lightningState.value.channels
425+
if (channels.filterOpen().isEmpty()) return@withContext Result.success(false)
426+
425427
val inboundBalanceSats = channels.sumOf { it.inboundCapacityMsat / 1000u }
426428

427429
Result.success((_walletState.value.bip21AmountSats ?: 0uL) >= inboundBalanceSats)
@@ -461,27 +463,6 @@ class WalletRepo @Inject constructor(
461463
}
462464
}
463465

464-
suspend fun searchInvoiceByPaymentHash(paymentHash: String): Result<TagMetadataEntity> = withContext(bgDispatcher) {
465-
return@withContext try {
466-
val invoiceTag =
467-
db.tagMetadataDao().searchByPaymentHash(paymentHash = paymentHash) ?: return@withContext Result.failure(
468-
Exception("Invoice not found")
469-
)
470-
Result.success(invoiceTag)
471-
} catch (e: Throwable) {
472-
Logger.error("searchInvoice error", e, context = TAG)
473-
Result.failure(e)
474-
}
475-
}
476-
477-
suspend fun deleteInvoice(txId: Txid) = withContext(bgDispatcher) {
478-
try {
479-
db.tagMetadataDao().deleteByPaymentHash(paymentHash = txId)
480-
} catch (e: Throwable) {
481-
Logger.error("deleteInvoice error", e, context = TAG)
482-
}
483-
}
484-
485466
suspend fun deleteAllInvoices() = withContext(bgDispatcher) {
486467
try {
487468
db.tagMetadataDao().deleteAll()

0 commit comments

Comments
 (0)