Skip to content

LSP accounting: per-channel profitability #298

Description

@f3r10

Following up on my comment in #121, where "Accounting / profitability tooling" is still unchecked. With #283 merged the data is all there, it's just not connected.

Today:

  • revenue per channel: ListChannelForwardingStats / GetChannelForwardingStats give
    total_fee_earned_msat and total_skimmed_fee_msat (the latter covers LSPS2 JIT opening
    fees), plus counts and first/last timestamps
  • costs: ListPayments returns on-chain payments with fee_paid_msat and a tx_type
    (Funding, CooperativeClose, UnilateralClose, AnchorBump, Claim, Sweep), and those
    variants carry the channel id and counterparty

To find out whether a channel is paying for itself, a client has to paginate every payment and join it against the stats on channel ids. That's the same work for every operator, and it's work the server can do once.

I'd like to add an RPC that does the join:

      ListChannelEarnings(optional time range, page token)
        -> per channel: counterparty, capacity, forwards count,
           fee_earned_msat, skimmed_fee_msat,
           onchain_cost_msat broken down by tx_type,
           net_msat
           plus a totals row

Scope I have in mind for a first version: open channels, an optional time range, and the existing pagination style. Capital and opportunity cost stay out, since the node can't know an operator's cost of capital.

One known limitation: most of a channel's cost lands when it closes, and ldk-server can't list closed channels yet. I have an ldk-node PR open for list_closed_channels() (lightningdevkit/ldk-node#882); once that lands, closed channels can be folded in as a follow-up.

I'd like to work on this, happy to adjust the shape in review.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions