Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 3 additions & 16 deletions app/src/main/java/to/bitkit/ext/ChannelDetails.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,9 @@ import org.lightningdevkit.ldknode.ChannelConfig
import org.lightningdevkit.ldknode.ChannelDetails
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).
* Approximates ldk-node's `ClaimableOnChannelClose.amountSatoshis` (excluding HTLCs).
*
* Formula: outbound_capacity + our_reserve
* - outbound_capacity: What we can spend now over Lightning
* - our_reserve: Our reserve that we get back on close
*/
/** The amount we would receive if the channel closes now, from ldk-node's channel monitor. */
val ChannelDetails.amountOnClose: ULong
get() {
val outboundCapacitySat = this.outboundCapacityMsat / 1000u
val ourReserve = this.unspendablePunishmentReserve ?: 0u

return outboundCapacitySat + ourReserve
}
get() = claimableOnCloseSats ?: 0uL

/** Returns only `open` channels, filtering out pending ones. */
fun List<ChannelDetails>.filterOpen(): List<ChannelDetails> {
Expand Down Expand Up @@ -86,5 +72,6 @@ fun createChannelDetails(): ChannelDetails {
forceCloseAvoidanceMaxFeeSatoshis = 0u,
acceptUnderpayingHtlcs = false,
),
claimableOnCloseSats = 0u,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,8 @@ private fun PreviewAutoMode() {
maxDustHtlcExposure = org.lightningdevkit.ldknode.MaxDustHtlcExposure.FeeRateMultiplier(0uL),
forceCloseAvoidanceMaxFeeSatoshis = 0uL,
acceptUnderpayingHtlcs = false
)
),
claimableOnCloseSats = 0uL,
)

AppThemeSurface {
Expand Down Expand Up @@ -771,7 +772,8 @@ private fun PreviewSpendingMode() {
maxDustHtlcExposure = org.lightningdevkit.ldknode.MaxDustHtlcExposure.FeeRateMultiplier(0uL),
forceCloseAvoidanceMaxFeeSatoshis = 0uL,
acceptUnderpayingHtlcs = false
)
),
claimableOnCloseSats = 0uL,
)

AppThemeSurface {
Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ activity-compose = { module = "androidx.activity:activity-compose", version = "1
appcompat = { module = "androidx.appcompat:appcompat", version = "1.7.1" }
barcode-scanning = { module = "com.google.mlkit:barcode-scanning", version = "17.3.0" }
biometric = { module = "androidx.biometric:biometric", version = "1.4.0-alpha05" }
bitkit-core = { module = "com.synonym:bitkit-core-android", version = "0.1.35" }
bitkit-core = { module = "com.synonym:bitkit-core-android", version = "0.1.37" }
bouncycastle-provider-jdk = { module = "org.bouncycastle:bcprov-jdk18on", version = "1.83" }
camera-camera2 = { module = "androidx.camera:camera-camera2", version.ref = "camera" }
camera-lifecycle = { module = "androidx.camera:camera-lifecycle", version.ref = "camera" }
Expand Down Expand Up @@ -58,7 +58,7 @@ ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" }
ktor-client-logging = { module = "io.ktor:ktor-client-logging", version.ref = "ktor" }
ktor-client-okhttp = { module = "io.ktor:ktor-client-okhttp", version.ref = "ktor" }
ktor-serialization-kotlinx-json = { module = "io.ktor:ktor-serialization-kotlinx-json", version.ref = "ktor" }
ldk-node-android = { module = "com.github.synonymdev:ldk-node", version = "v0.7.0-rc.8" } # fork | local: remove `v`
ldk-node-android = { module = "com.github.synonymdev:ldk-node", version = "v0.7.0-rc.11" } # fork | local: remove `v`
lifecycle-process = { group = "androidx.lifecycle", name = "lifecycle-process", version.ref = "lifecycle" }
lifecycle-runtime-compose = { module = "androidx.lifecycle:lifecycle-runtime-compose", version.ref = "lifecycle" }
lifecycle-runtime-ktx = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version.ref = "lifecycle" }
Expand Down
Loading