Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

invoice+rpc: add exit hop InvoiceAcceptor sub-systems and RPC calls #8616

Open
2 tasks
Roasbeef opened this issue Apr 3, 2024 · 2 comments · May be fixed by #8669
Open
2 tasks

invoice+rpc: add exit hop InvoiceAcceptor sub-systems and RPC calls #8616

Roasbeef opened this issue Apr 3, 2024 · 2 comments · May be fixed by #8669
Assignees
Labels
enhancement Improvements to existing features / behaviour invoices rpc Related to the RPC interface

Comments

@Roasbeef
Copy link
Member

Roasbeef commented Apr 3, 2024

Today we have the HtlcInterceptor which is useful for modifying the default forwarding behavior of an lnd node. Callers of the RPC get a call back like construct that they can use to accept/deny forwarding attempts. However, we don't have such an option for the exit hop, as that logic bypasses the HltcSwitch and will be sent directly to the InvoiceRegistry.We should add a new interceptor-like RPC call, the InvoiceAcceptor, which can be used to modify why/how lnd accepts a payment as a final hop.

One example use case is the popular "JIT channel" construct where a channel is opened on the fly to allow the final hop to accept a payment. In typical instantiations, the receiver might actually get an HTLC with an amount below the original invoice. Service providers can use this little trick to collect a service fee as they provided inbound capacity to the target node.

The existing hodl invoice RPC call partially fills this gap, but today we don't yet have a good way of subscribing to all the active hodl invoices (#3120).

Steps To Completion

  • Within the NotifyExitHopHTLC call, add a way for an external subscriber to make decisions w.r.t settling the invoice with priority over the existing logic. The caller should be able to return an HtlcResolution which is executed in line with the existing logic.
  • Expose the new invoice call back system over the RPC interface. Look to the HtlcInterceptor and FundingAcceptor as inspiration.
@Roasbeef Roasbeef added enhancement Improvements to existing features / behaviour rpc Related to the RPC interface invoices labels Apr 3, 2024
@ffranr
Copy link
Collaborator

ffranr commented Apr 29, 2024

Next steps for this PR:

  1. Ensure that the normal invoice checking logic (expiry check etc.) is still executed.
  2. The interceptor should be able to bypass checks that would reject settling an invoice based on amt. Ensure that that's possible with the new interceptor.
  3. If the interceptor decrees, then an exit hop HTLC should be accepted.
  4. Checkout updateMpp. Ensure that the total settled amount is correct given the interceptor client response.

I think the "accept" notion is used to accept a HTLC which doesn't settle the entire amount of the invoice. Where as in settling we loop over all "accepted" HTLCs associated with an invoice, and if the amount is sufficient, those accepted HTLCs become settled.

@ffranr
Copy link
Collaborator

ffranr commented Apr 30, 2024

I've provided a status update on the PR: #8669

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvements to existing features / behaviour invoices rpc Related to the RPC interface
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants