Attribute earned Lightning forwarding fees to channel pairs

A routing node earns fees when forwards settle. Grouping the incoming and outgoing channels shows which pairs contributed to observed revenue.

Keep settled forwards only

Use this query on a node with a manageable forwarding history. Both channel IDs are local routing records. The calculation sums the reported fee field in millisatoshis.

lightning-cli listforwards settled | jq '.forwards | group_by([.in_channel,.out_channel]) | map({incoming: .[0].in_channel, outgoing: .[0].out_channel, earned_msat: (map(.fee_msat) | add)})'

Set the reporting period explicitly

The example totals the returned history. For monthly reporting, filter by the settlement timestamp and record the timezone before grouping. Offered and failed forwards can explain demand, but their advertised fees should not enter earned revenue. Add pagination for larger histories.

docs.corelightning.org listforwards