fix: handle cjit channel ready notification#787
Conversation
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
Pull request was converted to draft
# Conflicts: # app/src/main/java/to/bitkit/androidServices/LightningNodeService.kt
Fixes #666
Closes #626
This PR adds CJIT (just-in-time channel) payment notifications to the foreground-service path and de-duplicates channel-ready / payment notifications across the two producers (
WakeNodeWorkerandLightningNodeService), so a single, correctly-formatted notification is shown per event.NotifyChannelReadyCQRS command + handler to process CJIT payment notifications when a JIT channel becomes ready.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(notPaymentReceived). The foreground service (LightningNodeService) only handledPaymentReceivedandOnchainTransactionReceived, so CJIT payments were silently ignored. The newNotifyChannelReadyHandlerencapsulates channel lookup, CJIT verification via Blocktank, activity recording, and notification building, following the same CQRS pattern asNotifyPaymentReceivedHandler.A
ChannelReady(and an incoming payment) event has two notification producers —WakeNodeWorker(push/wake path) and theLightningNodeServiceforeground-service handler — which both fired when active. The review surfaced three issues from this, now resolved:WakeNodeWorkernow formats amounts withformatToModernDisplay()(space-grouped thousands) instead of raw sats (₿ 48 064, not₿ 48064).WakeNodeWorkerskips its own user-facing notification when an in-process handler already covers the event (app in foreground, orLightningNodeService.isRunning), leaving a single, richer notification. It still wakes the node, opens the channel, and records the activity. Applies to both the CJIT channel-ready path and the regular incoming-payment (incomingHtlc) path, which shared the same root cause.WakeNodeWorkeronly posts the "via new channel" notification when the channel actually has a Blocktank CJIT entry; a regular channel opening no longer surfaces a false "payment received" notification.Also removed a dead
amountOnCloseimport left inAppViewModelby the refactor.Preview
fg-notification.webm
wake-2.webm
QA Notes
1. CJIT notification via foreground service
₿ 48 064)2. CJIT notification via push (app killed)
3. Non-CJIT channel opening
4. Tests
WakeNodeWorkerTest— formatting, non-CJIT (no notification), dedup for CJIT + regular paymentLightningNodeServiceTest— channel-ready notification (background) / non-CJIT / foregroundNotifyChannelReadyHandlerTest— 6 tests passjust compile,just test,just lint— all greenjourneys/cjit-notifications/reproducing all three scenarios