Skip to content

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

@Roasbeef

Description

@Roasbeef

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.

Metadata

Metadata

Assignees

Labels

enhancementImprovements to existing features / behaviourinvoicesrpcRelated to the RPC interface

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions