Skip to content

Commit 5a212df

Browse files
committed
fix: open channel with paid orders
1 parent e711bd3 commit 5a212df

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package to.bitkit.repositories
22

3+
import com.synonym.bitkitcore.BtOrderState2
34
import com.synonym.bitkitcore.CreateCjitOptions
45
import com.synonym.bitkitcore.CreateOrderOptions
56
import com.synonym.bitkitcore.IBtEstimateFeeResponse2
@@ -146,6 +147,7 @@ class BlocktankRepo @Inject constructor(
146147
"Orders refreshed: ${orders.size} orders, ${cjitEntries.size} cjit entries",
147148
context = TAG
148149
)
150+
openChannelWithPaidOrders()
149151
} catch (e: Throwable) {
150152
Logger.error("Failed to refresh orders", e, context = TAG)
151153
} finally {
@@ -287,6 +289,12 @@ class BlocktankRepo @Inject constructor(
287289
}
288290
}
289291

292+
private suspend fun openChannelWithPaidOrders() = withContext(bgDispatcher) {
293+
_blocktankState.value.paidOrders.filter { it.state2 == BtOrderState2.PAID }.forEach { order ->
294+
openChannel(order.id)
295+
}
296+
}
297+
290298
private suspend fun defaultCreateOrderOptions(clientBalanceSat: ULong): CreateOrderOptions {
291299
val nodeId = lightningService.nodeId ?: throw ServiceError.NodeNotStarted
292300
val timestamp = nowTimestamp().toString()

0 commit comments

Comments
 (0)