Skip to content

Conversation

@ellemouton
Copy link
Collaborator

backport #10410

So that we can re-use this helper else where.
When creating a missing edge, we need to populate the funding script too
so that the graph builder can update its ChainView appropriately. We use
the MakeFundingScript helper from the funding package which ensures that
we are using the same logic for creating a funding script as is used for
any of the channels that we own.
@ellemouton ellemouton force-pushed the backport-fixMissingEdge branch from 06edebf to 8416bc0 Compare December 12, 2025 08:25
@gemini-code-assist
Copy link

Summary of Changes

Hello @ellemouton, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request backports a critical fix that ensures the correct construction of the channel graph for local channels. Previously, validation checks introduced after a graph refactor prevented the addition of certain channel edges due to missing funding script details. This change addresses that by making the funding script generation function public and ensuring it is always included when creating these graph entries, thereby maintaining the integrity and completeness of the network graph.

Highlights

  • Bug Fix for Local Channel Graph Edges: Resolves an issue where local channels could not be properly added to the graph database due to missing FundingScript information during edge creation, which was required by validation checks after a graph refactor.
  • Funding Script Export: The makeFundingScript function in the funding package has been exported as MakeFundingScript, making it accessible for use by other packages like routing/localchans.
  • Graph Edge Information Enrichment: The createEdge function in routing/localchans now explicitly utilizes funding.MakeFundingScript to populate the FundingScript field within the ChannelEdgeInfo struct, ensuring complete channel information for graph validation and proper graph construction.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@ellemouton ellemouton added this to the v0.20.1 milestone Dec 12, 2025
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request appears to be a backport of a fix to correctly populate the FundingScript for missing channel edges, which resolves a bug in adding local channels to the graph database. The change involves exporting the makeFundingScript function from the funding package and utilizing it in the routing/localchans package. The implementation seems correct and is well-tested. My feedback focuses on improving the documentation for the newly exported function to align with the style guide and fixing a placeholder in the release notes.

Comment on lines +67 to +63
* Fix a bug where [missing edges for own channels could not be added to the
graph DB](https://github.com/lightningnetwork/lnd/pull/10443)

Choose a reason for hiding this comment

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

medium

The link for this bug fix points to pull/xxxxx, which seems to be a placeholder. Please update it with the correct pull request number.

Comment on lines +3040 to 3041
// MakeFundingScript re-creates the funding script for the funding transaction
// of the target channel.

Choose a reason for hiding this comment

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

medium

Per the LND Style Guide, exported functions should have detailed comments. The current comment for MakeFundingScript is quite brief. It would be beneficial to expand it to explain what kind of script is being created (e.g., P2WSH for legacy channels, P2TR for taproot channels) and why it's needed, similar to the detailed example provided in the style guide for DeriveRevocationPubkey.

References
  1. Exported functions require detailed comments for the caller. The provided example for a 'RIGHT' comment is very descriptive, explaining the 'why' and 'how' of the function. (link)

@ellemouton ellemouton force-pushed the backport-fixMissingEdge branch from 8416bc0 to 53994da Compare December 12, 2025 08:51
@ellemouton ellemouton merged commit 07b8452 into lightningnetwork:v0.20.x-branch Dec 15, 2025
39 checks passed
@ellemouton ellemouton deleted the backport-fixMissingEdge branch December 15, 2025 06:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants