multi: expose local and remote spendable balance in listchannels#10624
multi: expose local and remote spendable balance in listchannels#10624Euler-B wants to merge 5 commits intolightningnetwork:masterfrom
Conversation
Summary of ChangesHello, 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 significantly improves the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe 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
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 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
|
🔴 PR Severity: CRITICAL
🔴 Critical (5 files)
🟠 High (1 file, auto-generated)
🟡 Medium (2 files)
🟢 Low / Test (1 file)
AnalysisThis PR touches three distinct critical packages:
Excluding test files ( Expert review is warranted given the breadth of changes across HTLC switching, wallet channel management, and the RPC surface. To override, add a |
There was a problem hiding this comment.
Code Review
This pull request successfully exposes the local and remote spendable balances in the listchannels RPC. The core of the change is a significant but well-executed refactoring in lnwallet/channel.go to create a generic balance calculation logic applicable to both local and remote parties. The new test case, TestChanRemoteAvailableBalance, is thorough and provides good coverage for the new logic. The changes to the RPC layer are consistent with the core modifications. I have a couple of minor suggestions related to code comments to improve documentation clarity and adhere to the style guide.
Note: Security Review is unavailable for this PR.
a639166 to
4b7cb99
Compare
This commit refactors availableCommitmentBalance and applyCommitFee to be party-agnostic, allowing the calculation of the available balance from the perspective of either the local or remote party. We also introduce RemoteAvailableBalance to expose this new functionality. A new test TestChanRemoteAvailableBalance has been added to verify the accuracy of these calculations across various states.
This commit adds a new RemoteBandwidth method to the ChannelLink interface and implements it in channelLink by calling the new RemoteAvailableBalance method in lnwallet. The mockChannelLink has also been updated to satisfy the interface.
This commit adds local_spendable_msat and remote_spendable_msat to the Channel message in lightning.proto. This allows clients to see the actual amount of funds that can be sent or received in a channel, accounting for reserves and fees.
This commit updates the ListChannels RPC to populate the new local_spendable_msat and remote_spendable_msat fields by querying the active channel link from the htlcSwitch.
4b7cb99 to
1affd68
Compare
1affd68 to
6bc0965
Compare
Change Description
This PR addresses the request to expose the actual "spendable" balance in the
listchannelsRPC.Currently,
local_balanceandremote_balanceonly show total funds, not considering:ChanReserve).Fixes: #4951
Steps to Test
make installand verifylocal_spendable_msatinlncli listchannels.Pull Request Checklist
Testing
Code Style and Documentation
[skip ci]in the commit message for small changes.📝 Please see our Contribution Guidelines for further guidance.