Skip to content

Commit 4277cdd

Browse files
committed
chore: clarify coop-close wording
1 parent 76f5132 commit 4277cdd

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

app/src/main/java/to/bitkit/usecases/DeriveBalanceStateUseCase.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ class DeriveBalanceStateUseCase @Inject constructor(
4545

4646
val toSavingsAmount = getTransferToSavingsSats(activeTransfers, channels, balanceDetails)
4747
val coopCloseSavingsSats = getCoopCloseTransferSats(activeTransfers, channels, balanceDetails)
48-
val orphanCoopCloseSats = getOrphanCoopCloseSats(activeTransfers, channels, balanceDetails)
48+
val lingeringCoopCloseSats = getLingeringCoopCloseSats(activeTransfers, channels, balanceDetails)
4949
val toSpendingAmount = paidOrdersSats.safe() + pendingChannelsSats.safe()
5050

5151
val totalOnchainSats = balanceDetails.totalOnchainBalanceSats
5252
val channelFundableBalance = getMaxChannelFundableAmount(lightningRepo.getChannelFundableBalance())
5353
val afterPendingChannels = balanceDetails.totalLightningBalanceSats.safe() - pendingChannelsSats.safe()
5454
val afterClosingChannels = afterPendingChannels.safe() - toSavingsAmount.safe()
55-
val totalLightningSats = afterClosingChannels.safe() - orphanCoopCloseSats.safe()
55+
val totalLightningSats = afterClosingChannels.safe() - lingeringCoopCloseSats.safe()
5656

5757
val balanceState = BalanceState(
5858
totalOnchainSats = totalOnchainSats,
@@ -160,7 +160,7 @@ class DeriveBalanceStateUseCase @Inject constructor(
160160
return amount
161161
}
162162

163-
private suspend fun getOrphanCoopCloseSats(
163+
private suspend fun getLingeringCoopCloseSats(
164164
transfers: List<TransferEntity>,
165165
channels: List<ChannelDetails>,
166166
balanceDetails: BalanceDetails,
@@ -175,11 +175,11 @@ class DeriveBalanceStateUseCase @Inject constructor(
175175
val claimableBalances = balanceDetails.lightningBalances
176176
.filterIsInstance<LightningBalance.ClaimableAwaitingConfirmations>()
177177
for (balance in claimableBalances) {
178-
val isOrphanCoopClose = balance.source == BalanceSource.COOP_CLOSE &&
178+
val isLingeringCoopClose = balance.source == BalanceSource.COOP_CLOSE &&
179179
balance.channelId !in channelIds &&
180180
balance.channelId !in transferChannelIds
181181

182-
if (isOrphanCoopClose) {
182+
if (isLingeringCoopClose) {
183183
amount = amount.safe() + balance.amountSatoshis.safe()
184184
}
185185
}

app/src/test/java/to/bitkit/usecases/DeriveBalanceStateUseCaseTest.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -401,18 +401,18 @@ class DeriveBalanceStateUseCaseTest : BaseUnitTest() {
401401
}
402402

403403
@Test
404-
fun `should subtract orphan coop close balance from lightning while keeping new channel balance`() = test {
404+
fun `should subtract lingering coop close claimable from lightning while keeping new channel balance`() = test {
405405
val closedChannelId = "closed-channel-id"
406406
val newChannelId = "new-channel-id"
407407
val closedChannelSats = 1_531_123uL
408408
val newChannelSats = 62_158uL
409-
val orphanClosingBalance = newClosingChannelBalance(closedChannelId, closedChannelSats)
409+
val lingeringClosingBalance = newClosingChannelBalance(closedChannelId, closedChannelSats)
410410
val newChannelBalance = newChannelBalance(newChannelId, newChannelSats)
411411

412412
val balance = newBalanceDetails().copy(
413413
totalOnchainBalanceSats = closedChannelSats,
414414
totalLightningBalanceSats = 1_593_281uL,
415-
lightningBalances = listOf(orphanClosingBalance, newChannelBalance),
415+
lightningBalances = listOf(lingeringClosingBalance, newChannelBalance),
416416
)
417417
whenever(lightningRepo.getBalancesAsync()).thenReturn(Result.success(balance))
418418

@@ -435,7 +435,7 @@ class DeriveBalanceStateUseCaseTest : BaseUnitTest() {
435435
}
436436

437437
@Test
438-
fun `should not subtract orphan non coop close balance from lightning`() = test {
438+
fun `should keep non coop close claimable in lightning`() = test {
439439
val channelId = "force-closed-channel-id"
440440
val amountSats = 40_000uL
441441
val closingChannelBalance = newClosingChannelBalance(

0 commit comments

Comments
 (0)