Skip to content

fix: handle cjit channel ready notification#787

Draft
jvsena42 wants to merge 5 commits intomasterfrom
fix/channelready-cjit
Draft

fix: handle cjit channel ready notification#787
jvsena42 wants to merge 5 commits intomasterfrom
fix/channelready-cjit

Conversation

@jvsena42
Copy link
Member

@jvsena42 jvsena42 commented Feb 17, 2026

Fixes #666
Closes #626

This PR:

  1. Adds a NotifyChannelReady CQRS command and handler to process CJIT payment notifications when a JIT channel becomes ready
  2. Fixes missing payment notification for CJIT payments received via the foreground service when the app is in background
  3. Refactors AppViewModel.notifyChannelReady() to use the new handler, consolidating duplicated CJIT logic

Description

When a CJIT payment arrives as a JIT channel opening, LDK emits ChannelReady (not PaymentReceived). The foreground service (LightningNodeService) only handled PaymentReceived and OnchainTransactionReceived, so CJIT payments were silently ignored. The background path (WakeNodeWorker) already handled this correctly.

The new NotifyChannelReadyHandler encapsulates channel lookup, CJIT verification via Blocktank, activity recording, and notification building. It follows the same CQRS pattern as the existing NotifyPaymentReceivedHandler.

Preview

fg-notification.webm
wake-2.webm

QA Notes

1. CJIT notification via foreground service

  1. Enable background notifications (foreground service)
  2. Move the app to background
  3. Send a CJIT payment (first Lightning payment that opens a new channel)
  4. Verify the "Payment Received" notification appears
  5. Tap the notification and verify the transaction sheet shows the correct amount

2. CJIT notification via push (WakeNodeWorker)

  1. Close the app completely
  2. Send a CJIT payment
  3. Verify the push notification arrives and shows the correct amount
  4. This path should still work as before (regression check)

3. Non-CJIT channel opening

  1. Open a regular (non-CJIT) Lightning channel
  2. Verify the "Spending balance ready" toast appears (not a payment notification)

4. Unit tests

  • ./gradlew testDevDebugUnitTest --tests NotifyChannelReadyHandlerTest — 6 tests pass
  • ./gradlew testDevDebugUnitTest — all tests pass
  • ./gradlew detekt — no new lint issues

@jvsena42 jvsena42 self-assigned this Feb 17, 2026
@jvsena42 jvsena42 marked this pull request as ready for review February 18, 2026 10:59
@jvsena42 jvsena42 requested a review from ovitrif February 18, 2026 11:00
Copy link
Collaborator

@ovitrif ovitrif left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tAck

Tests

1. 🟢 CJIT notification via foreground service

nit: we miss currency formatting (space separators for thousands)

2. 🟠 CJIT notification via push (WakeNodeWorker)

Got 2 notifications now, I don't think this used to be the case before (🤔 ❓). Anyways ideally we only show the 2nd one, it's much more polished IMO.

3. 🔴 Non-CJIT channel opening

There's something totally off here, not sure what happened…

Logs: bitkit_logs_1771958898408.zip


PS. Bummer that we have these bugs, because the way the code is architected is really nice 👏🏻 .

val converted = currencyRepo.convertSatsToFiat(sats).getOrNull()

val amountText = converted?.let {
val btcDisplay = it.bitcoinDisplay(settings.displayUnit)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: we will have to create a model class for AmountUi to encapsulate all requirements related to displaying monetary values so we can easily replicate enforcing the same rules with minimal effort.

There's a concern not yet covered here but also not in scope of this PR, TBH: we don't format currency symbol applying the same formatting rule of whether the symbol is a prefix of a suffix based on the currencies' symbol locale, as recently implemented for the main in-app amount values UI by @piotr-iohk

@jvsena42 jvsena42 marked this pull request as draft February 25, 2026 11:43
auto-merge was automatically disabled February 25, 2026 11:43

Pull request was converted to draft

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Payment Received notification didn't work for CJIT via FG service (not CJIT), app in BG [Bug]: CJIT received sheet & activity item have wrong amount

2 participants