lnd
lnd copied to clipboard
invoice+rpc: add exit hop InvoiceAcceptor sub-systems and RPC calls
Change Description
Closes https://github.com/lightningnetwork/lnd/issues/8616
This pull request introduces the following components:
- An interceptor service for invoice settlements.
- An invoice acceptor RPC server and endpoint which makes use of the invoice settlement interceptor.
- An integration test demonstrating the settlement of an invoice through the invoice acceptor, using a HTLC with an amount smaller than the specified invoice amount.
Steps to Test
Steps for reviewers to follow to test the change.
Pull Request Checklist
Testing
- [ ] Your PR passes all CI checks.
- [ ] Tests covering the positive and negative (error paths) are included.
- [ ] Bug fixes contain tests triggering the bug to prevent regressions.
Code Style and Documentation
- [ ] The change obeys the Code Documentation and Commenting guidelines, and lines wrap at 80.
- [ ] Commits follow the Ideal Git Commit Structure.
- [ ] Any new logging statements use an appropriate subsystem and logging level.
- [ ] Any new lncli commands have appropriate tags in the comments for the rpc in the proto file.
- [ ] There is a change description in the release notes, or
[skip ci]
in the commit message for small changes.
📝 Please see our Contribution Guidelines for further guidance.
[!IMPORTANT]
Auto Review Skipped
Auto reviews are disabled on this repository.
Please check the settings in the CodeRabbit UI or the
.coderabbit.yaml
file in this repository. To trigger a single review, invoke the@coderabbitai review
command.You can disable this status message by setting the
reviews.review_status
tofalse
in the CodeRabbit configuration file.
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
-
I pushed a fix in commit <commit_id>.
-
Generate unit testing code for this file.
-
Open a follow-up GitHub issue for this discussion.
-
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitai
in a new review comment at the desired location with your query. Examples:-
@coderabbitai generate unit testing code for this file.
-
@coderabbitai modularize this function.
-
- PR comments: Tag
@coderabbitai
in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:-
@coderabbitai generate interesting stats about this repository and render them as a table.
-
@coderabbitai show all the console.log statements in this repository.
-
@coderabbitai read src/utils.ts and generate unit testing code.
-
@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
-
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (invoked as PR comments)
-
@coderabbitai pause
to pause the reviews on a PR. -
@coderabbitai resume
to resume the paused reviews. -
@coderabbitai review
to trigger a review. This is useful when automatic reviews are disabled for the repository. -
@coderabbitai resolve
resolve all the CodeRabbit review comments. -
@coderabbitai help
to get help.
Additionally, you can add @coderabbitai ignore
anywhere in the PR description to prevent this PR from being reviewed.
CodeRabbit Configration File (.coderabbit.yaml
)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yaml
file to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
@jharveyb and @GeorgeTsagk will review
I think I also need to pass circuit key for latest HTLC along with invoice to settlement interceptor client. This way the client can inspect the correct HTLC.
I think I also need to pass circuit key for latest HTLC along with invoice to settlement interceptor client. This way the client can inspect the correct HTLC.
This is included in the latest commits.
I'm in the process of writing an itest for this PR. I noticed that providing the exit HTLC circuit key to the acceptor interceptor client is insufficient. The invoice will only include the exit HTLC if it is a replayed HTLC.
I will therefore need to provide fields from the invoice update context to the interceptor client. I will make changes to that effect.
reviewed diff, left out the WIP commits also haven't locally tested anything
Latest state:
-
New integration test which shows that an invoice can be forced into the settled state (using the new interceptor) when the exit HTLC amount is less than the invoice amount.
-
The latest modifications account for the MPP invoice settlement flow.
-
I've simplified and reduced the necessary code changes.
Things to consider:
-
The smallest exit HTLC payment amount I could send was 1000 msat. I'm not sure if we're hopping to send 0.
-
We may need to add additional fields to the interceptor client request (provide more data to the interceptor client). In particular the custom records that are sent along with the p2p messages (
UpdateAddHtlc
etc.). That is not currently implemented.
1. The smallest exit HTLC payment amount I could send was 1000 msat. I'm not sure if we're hopping to send 0.
IIRC the plan was for the HTLC to be >= dust threshold / 330ish sats, so that seems fine.
@roasbeef: review reminder @jharveyb: review reminder @georgetsagk: review reminder
I need to double check whether there are modifications in the PoC branch which relate to this PR.
Replaced by https://github.com/lightningnetwork/lnd/pull/8771.