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.
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:
ListChannelForwardingStats/GetChannelForwardingStatsgivetotal_fee_earned_msatandtotal_skimmed_fee_msat(the latter covers LSPS2 JIT openingfees), plus counts and first/last timestamps
ListPaymentsreturns on-chain payments withfee_paid_msatand atx_type(
Funding,CooperativeClose,UnilateralClose,AnchorBump,Claim,Sweep), and thosevariants 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:
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.