From ba91535cb6604afb22db419587030c970feca810 Mon Sep 17 00:00:00 2001 From: benk10 Date: Thu, 15 Jan 2026 12:25:18 -0500 Subject: [PATCH] fix: resolve discrepancy between balance and ln channels view --- app/src/main/java/to/bitkit/ext/ChannelDetails.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/to/bitkit/ext/ChannelDetails.kt b/app/src/main/java/to/bitkit/ext/ChannelDetails.kt index 081acca0e..00441336b 100644 --- a/app/src/main/java/to/bitkit/ext/ChannelDetails.kt +++ b/app/src/main/java/to/bitkit/ext/ChannelDetails.kt @@ -8,18 +8,18 @@ import org.lightningdevkit.ldknode.MaxDustHtlcExposure * Calculates our total balance in the channel (see `value_to_self_msat` in rust-lightning). * * This represents the amount we would receive if the channel closes now (excluding fees). - * Matches ldk-node's `ClaimableOnChannelClose.amountSatoshis` (excluding HTLCs). + * Approximates ldk-node's `ClaimableOnChannelClose.amountSatoshis` (excluding HTLCs). * - * Formula: outbound_capacity + counterparty_reserve + * Formula: outbound_capacity + our_reserve * - outbound_capacity: What we can spend now over Lightning - * - counterparty_reserve: Their reserve that comes back to us on close + * - our_reserve: Our reserve that we get back on close */ val ChannelDetails.amountOnClose: ULong get() { val outboundCapacitySat = this.outboundCapacityMsat / 1000u - val counterpartyReserve = this.counterpartyUnspendablePunishmentReserve + val ourReserve = this.unspendablePunishmentReserve ?: 0u - return outboundCapacitySat + counterpartyReserve + return outboundCapacitySat + ourReserve } /** Returns only `open` channels, filtering out pending ones. */