From 53a94183c0ea78389b21ed48ac8eaf9015345586 Mon Sep 17 00:00:00 2001 From: pm47 Date: Fri, 10 Jul 2026 16:37:25 +0200 Subject: [PATCH 1/3] better handling of initial events We use `dropWhile` instead of `drop` to ignore initial events when subscribing to flows. This avoids filtering out useful events due to race conditions when `replayCache=0`. --- src/commonMain/kotlin/fr/acinq/phoenixd/Phoenixd.kt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/commonMain/kotlin/fr/acinq/phoenixd/Phoenixd.kt b/src/commonMain/kotlin/fr/acinq/phoenixd/Phoenixd.kt index 14601eb..dc1bc0d 100644 --- a/src/commonMain/kotlin/fr/acinq/phoenixd/Phoenixd.kt +++ b/src/commonMain/kotlin/fr/acinq/phoenixd/Phoenixd.kt @@ -352,8 +352,9 @@ class Phoenixd : CliktCommand() { val listeners = scope.launch { launch { - // drop initial CLOSED event - peer.connectionState.dropWhile { it is Connection.CLOSED }.collect { + peer.connectionState + .dropWhile { it is Connection.CLOSED } // drop initial CLOSED event + .collect { when (it) { Connection.ESTABLISHING -> consoleLog(yellow("connecting to lightning peer...")) Connection.ESTABLISHED -> consoleLog(yellow("connected to lightning peer")) @@ -364,7 +365,7 @@ class Phoenixd : CliktCommand() { if (blockchainClient is ElectrumClient) { launch { blockchainClient.connectionStatus - .drop(1) // we drop the initial value which a disconnection event + .dropWhile { it is ElectrumConnectionStatus.Closed } // drop initial CLOSED event .collect { when (it) { is ElectrumConnectionStatus.Connecting -> consoleLog(yellow("connecting to electrum server ${it.serverAddress.host}:${it.serverAddress.port}...")) @@ -384,7 +385,8 @@ class Phoenixd : CliktCommand() { currentBlockHeight = currentBlockHeight, swapInParams = peer.walletParams.swapInParams ) - }.drop(1) + } + .dropWhile { it == WalletState(emptyMap()) } // drop the initial event .map { wallet -> Triple(wallet.unconfirmed.balance, wallet.weaklyConfirmed.balance, wallet.deeplyConfirmed.balance) } .distinctUntilChanged() .collect { (unconfirmedBalance, weaklyConfirmedBalance, deeplyConfirmedBalance) -> consoleLog("swap-in wallet: unconfirmed=$unconfirmedBalance weaklyConfirmed=$weaklyConfirmedBalance deeplyConfirmed=$deeplyConfirmedBalance") } @@ -452,7 +454,7 @@ class Phoenixd : CliktCommand() { } launch { peer.feeCreditFlow - .drop(1) // we drop the initial value which is 0 msat + .dropWhile { it == 0.msat } // we drop the initial value which is 0 msat .collect { feeCredit -> consoleLog("fee credit: ${feeCredit.truncateToSatoshi()}") } } } From 67d1a5b6a01036225f19a228493267401e161458 Mon Sep 17 00:00:00 2001 From: pm47 Date: Fri, 10 Jul 2026 16:45:30 +0200 Subject: [PATCH 2/3] fixup: display swap-in fees in sat --- src/commonMain/kotlin/fr/acinq/phoenixd/Phoenixd.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commonMain/kotlin/fr/acinq/phoenixd/Phoenixd.kt b/src/commonMain/kotlin/fr/acinq/phoenixd/Phoenixd.kt index dc1bc0d..071144f 100644 --- a/src/commonMain/kotlin/fr/acinq/phoenixd/Phoenixd.kt +++ b/src/commonMain/kotlin/fr/acinq/phoenixd/Phoenixd.kt @@ -406,7 +406,7 @@ class Phoenixd : CliktCommand() { consoleLog("received lightning payment: ${payment.amount.truncateToSatoshi()} ($type${if (fee > 0.sat) " fee=$fee" else ""})") } is OnChainIncomingPayment -> { - consoleLog("received on-chain payment: ${payment.amount.truncateToSatoshi()} (fee=${payment.fees})") + consoleLog("received on-chain payment: ${payment.amount.truncateToSatoshi()} (fee=${payment.fees.truncateToSatoshi()})") } else -> {} } From d1be273a8687e7a64304d8999290dce163a64d29 Mon Sep 17 00:00:00 2001 From: pm47 Date: Fri, 10 Jul 2026 18:46:21 +0200 Subject: [PATCH 3/3] use lightning-kmp 1.13.0 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index b8cc0cb..887e87d 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -4,7 +4,7 @@ kotlinx-io = "0.9.0" clikt = "5.1.0" ktor = "3.4.1" sqldelight = "2.2.1" -lightningkmp = "1.12.1-SNAPSHOT" +lightningkmp = "1.13.0" kermit-io = "2.0.8" # test dependencies