@@ -17,14 +17,14 @@ import kotlinx.coroutines.withContext
1717import kotlinx.datetime.Clock
1818import org.lightningdevkit.ldknode.BalanceDetails
1919import org.lightningdevkit.ldknode.Event
20- import org.lightningdevkit.ldknode.Txid
2120import to.bitkit.data.AppDb
2221import to.bitkit.data.CacheStore
2322import to.bitkit.data.SettingsStore
2423import to.bitkit.data.entities.TagMetadataEntity
2524import to.bitkit.data.keychain.Keychain
2625import to.bitkit.di.BgDispatcher
2726import to.bitkit.env.Env
27+ import to.bitkit.ext.filterOpen
2828import to.bitkit.ext.nowTimestamp
2929import to.bitkit.ext.toHex
3030import 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