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 into
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
|
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.
1affd68 to
6bc0965
Compare
e0bc98a to
34a7563
Compare
|
Hi @ziggie1984. I've updated the PR to address the latest feedback and fixed the linting issues. This is my current approach to solve Issue #4951 |
34a7563 to
2e928b5
Compare
🔴 PR Severity: CRITICAL
🔴 Critical (6 files)
🟠 High (3 files)
🟢 Low (3 files)
AnalysisThe highest-severity files touched are in For reference, this PR also touches multiple distinct critical packages (htlcswitch, lnwallet, peer, plus rpcserver.go), which would normally trigger a one-level severity bump — but since CRITICAL is already the highest tier, this has no further effect. File count (9) and line changes (307, excluding tests/generated code) are both well under the size-based bump thresholds (20 files / 500 lines), so those thresholds are not a factor here. Given the changes to To override, add a |
|
/gateway review |
|
✅ Review posted: #10624 (review) 6 finding(s); 6 inline, 0 in body. 🔁 Need a re-review after pushing changes? Reply with |
There was a problem hiding this comment.
This PR exposes local/remote spendable balance in listchannels by adding RemoteAvailableBalance()/RemoteBandwidth() and refactoring lnwallet/channel.go's balance computation into a party-generic form. The intent and the reserve/dust/initiator mapping are sound, and the RPC/proto plumbing is consistent.
The refactor, however, silently changes the HTLC view used by the pre-existing AvailableBalance() path — it now folds in un-ACKed remote updates rather than only remote-ACKed ones. Because that value drives Bandwidth() on a high-reach HTLC-forwarding path, this is the primary concern and needs to be confirmed intentional or reverted. A secondary correctness/usability gap is that the new RPC fields silently report 0 for any channel without an active link, with no signal to the consumer.
Findings: 🔴 0 Blocker · 🟠 2 Major · 🟡 4 Minor · 🔵 0 Nit
|
🤖 gateway audit metadata for this PR — auto-generated, please don't edit. |
6185e0b to
1410c20
Compare
|
@Euler-B, remember to re-request review from reviewers when ready |
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 and peer test mocks have 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.
1410c20 to
cbb522a
Compare
|
@Euler-B, remember to re-request review from reviewers when ready |
2 similar comments
|
@Euler-B, remember to re-request review from reviewers when ready |
|
@Euler-B, remember to re-request review from reviewers when ready |
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.