Skip to content

fix(lightning): closed channel short channel ID#591

Merged
jvsena42 merged 2 commits into
masterfrom
fix/closed-channel-id-formatting
Jun 10, 2026
Merged

fix(lightning): closed channel short channel ID#591
jvsena42 merged 2 commits into
masterfrom
fix/closed-channel-id-formatting

Conversation

@jvsena42

@jvsena42 jvsena42 commented Jun 10, 2026

Copy link
Copy Markdown
Member

This PR fixes the Channel ID shown on the Lightning Connection Detail screen for closed channels. Connection Details falls back to a confidently linked Blocktank order's short channel ID when a closed channel carries none, but Blocktank delivers that value already in Core Lightning block x tx x output form (for example 792906x599x1). The previous code only accepted a numeric value, so the conversion failed and the Channel ID row was hidden even when the order supplied one.

The display now keeps an already-formatted block x tx x output value as-is and still decodes a numeric value as a safeguard. The Channel ID row stays hidden only when no value is available.

This is a port of the Android fix in synonymdev/bitkit-android#1002 and a follow-up to the iOS Connection Details work in #587.

Linked Issues/Tasks

Screenshot / Video

https://mempool.bitkit.stag0.blocktank.to/tx/043a0c37888ed1f6be2057c1eb5357c2049b92b64a561ca837cc9f6e2a790807#vout=0

oppened-channel.mov
closed-channel.mov

QA Notes

Manual Tests

  • 1. Settings → Advanced → Lightning Connections → Show Closed & Failed → tap a closed connection opened through Blocktank → Connection Detail: Channel ID shows the short channel ID (block x tx x output), not hidden.
  • 2. Connection Detail → tap Channel ID row: copies the short channel ID.
  • 3. regression: Lightning Connections → tap an open connection → Connection Detail: Channel ID still shows the short channel ID from the node.

Automated Checks

  • Unit tests added: cover the short channel id resolver in BitkitTests/ShortChannelIdTests.swift — a CLN-form order scid is kept as-is (792906x599x1), a numeric order scid is decoded (854845001888432128777477x916x0), and empty/malformed values return nothing.
  • Unit tests added: cover the closed-channel CLN-form case end-to-end through the confident-link gating in BitkitTests/ChannelDetailsViewModelTests.swift.
  • Local: swiftformat clean; xcodebuild ... build-for-testing on the iOS Simulator succeeds.
  • CI: standard build and test checks run by the PR bot.

@jvsena42 jvsena42 self-assigned this Jun 10, 2026
@greptile-apps

greptile-apps Bot commented Jun 10, 2026

Copy link
Copy Markdown

Greptile Summary

This PR fixes the Channel ID row being hidden on the Connection Detail screen for closed Blocktank channels by teaching the scid resolver to accept a CLN-form blockXtxXoutput string from the order in addition to a raw numeric value.

  • ShortChannelId.swift: Extracts a new resolveDisplayShortChannelId free function that first tries the channel's own numeric scid, then falls back to the linked order's scid — accepting it as-is if it is already in CLN form, or decoding it if it is numeric.
  • ChannelDetailsViewModel.swift: displayShortChannelId is simplified to a single delegating call; confidence-gating of the order link is unchanged.
  • Tests: New unit tests cover the CLN-form passthrough, numeric decode, nil/empty, malformed inputs, and the end-to-end path through the view model.

Confidence Score: 4/5

Safe to merge; the fix is narrow, well-tested, and the confidence-gating that guards borrowed scid values is preserved.

The resolver logic and split handling are correct, tests cover the full range of expected inputs, and the view-model refactor is a straightforward delegation. The one minor concern is that isNumber accepts non-ASCII Unicode numeric glyphs, which could theoretically allow a malformed-looking CLN-form string through; in practice the data comes from a trusted API so the impact is negligible.

No files require special attention; ShortChannelId.swift has the minor isNumber validator note worth a quick look.

Important Files Changed

Filename Overview
Bitkit/Extensions/ShortChannelId.swift Adds isClnShortChannelId helper and resolveDisplayShortChannelId function to accept CLN-form scids from Blocktank orders. Logic and split handling look correct; isNumber includes non-ASCII Unicode numerals (minor).
Bitkit/ViewModels/ChannelDetailsViewModel.swift Refactors displayShortChannelId to delegate to the new resolveDisplayShortChannelId; confidence-gating of the linked order's scid is preserved correctly.
BitkitTests/ShortChannelIdTests.swift Good unit coverage: CLN-form passthrough, numeric decode, nil/empty, and several malformed inputs all tested.
BitkitTests/ChannelDetailsViewModelTests.swift New end-to-end test covers the CLN-form order scid path through confidence gating; existing regression tests are intact.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[displayShortChannelId] --> B{channelScid non-nil?}
    B -- Yes --> C[format UInt64 as block×tx×output]
    B -- No --> D{isLinkedOrderConfident AND order.channel.shortChannelId non-nil?}
    D -- No --> E[return nil]
    D -- Yes --> F{UInt64 parse succeeds?}
    F -- Yes --> G[decode numeric scid → block×tx×output]
    F -- No --> H{isClnShortChannelId?}
    H -- Yes --> I[return CLN-form string as-is]
    H -- No --> E
Loading

Reviews (1): Last reviewed commit: "fix: handle blocktank order short chann..." | Re-trigger Greptile

Comment thread Bitkit/Extensions/ShortChannelId.swift Outdated
@jvsena42
jvsena42 requested a review from pwltr June 10, 2026 13:18
@jvsena42 jvsena42 added this to the 2.4.0 milestone Jun 10, 2026
@jvsena42
jvsena42 enabled auto-merge June 10, 2026 13:18
@jvsena42
jvsena42 merged commit b9423ed into master Jun 10, 2026
17 of 20 checks passed
@jvsena42
jvsena42 deleted the fix/closed-channel-id-formatting branch June 10, 2026 13:59
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.

3 participants