refactor: use channelPoint as uniqueId by replacing colon with hyphen#1362
refactor: use channelPoint as uniqueId by replacing colon with hyphen#1362yemmyharry wants to merge 2 commits intojamaljsr:masterfrom
Conversation
Greptile SummaryThis PR fixes a channel collision bug in the LND channel mapper where batch-opened channels sharing the same funding TXID (but different output indices) were rendered as a single channel in the graph designer, because the old Key changes:
Confidence Score: 4/5
|
| Filename | Overview |
|---|---|
| src/lib/lightning/lnd/mappers.ts | Replaces the collision-prone 12-char truncated txid with the full channelPoint (colon replaced by hyphen) as the uniqueId — correctly fixes batch-channel display bug; no unit tests added. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[LND RPC returns Channel\nchannelPoint = 'txid:vout'] --> B{mapOpenChannel /\nmapPendingChannel}
B --> C["uniqueId = channelPoint.replace(':', '-')\ne.g. 'abc123...txid-0'"]
C --> D[updateLinksAndPorts in chart.ts]
D --> E["links[uniqueId] created/updated\nports[uniqueId] created/updated"]
E --> F[Each batch channel gets its own\ndistinct link in the graph]
style C fill:#d4edda,stroke:#28a745
subgraph OLD ["Old (broken) logic"]
G["txid(channelPoint).slice(-12)\ne.g. both txid:0 and txid:1\nproduced same last-12-chars ID"]
G --> H["links[sameId] — second channel\noverwrites first → only 1 link shown"]
end
Last reviewed commit: bb91e47
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1362 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 211 211
Lines 7014 7013 -1
Branches 1398 1348 -50
=========================================
- Hits 7014 7013 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Abdulkbk
left a comment
There was a problem hiding this comment.
tACK 🚀, the fix works.
A few notes:
PR title should be "fix" not refactor per conventional commits.
Also, the newly added test file mappers.spec.ts for the two "unique IDs for batch-opened channels" directly validates the fix and is welcome. It would be easier to review if you moved the specific test to the previous commit and then added the unrelated tests in this commit.
Closes #1361
Description
This PR fixes a bug where channels opened in a single batch transaction (sharing the same funding TXID but different output indices) were not all displaying in the Polar graph designer. Previously, the uniqueId generation for channels relied on a truncated version of the channelPoint (last 12 chars) , which caused collisions for batch outputs like txid:0 and txid:1 , resulting in only one channel being rendered.
Steps to Test
Screenshots
[Only if applicable]