ElementsProject / lightning

Core Lightning — Lightning Network implementation focusing on spec compliance and performance
Other
2.85k stars 902 forks source link

Feature request: add start_time parameter to listforwards #7284

Closed Impa10r closed 6 months ago

Impa10r commented 6 months ago

Issue and Steps to Reproduce

Currently lighting-cli listforwards and the respective API endpoints take no parameters and return the whole history of htlc forwards, including pending and failed ones. On a sufficiently large node with a long history of routing this may take a while. If some script would like to monitor new forwards in the last minute etc, the whole history needs to be downloaded again every minute. Unless I am missing some obvious solution, please allow incremental history retrieval.

Another optional parameter would be to only return successful forwards.

getinfo output

"version": "v24.02.2",

kristapsk commented 6 months ago

See #2860 and #5884 and discussions there.

Impa10r commented 6 months ago

I read through that, did not understand the outcome. LND has both timestamp filtering and pagination, works great.

kristapsk commented 6 months ago

I read through that, did not understand the outcome. LND has both timestamp filtering and pagination, works great.

I opened a PR with code adding this functionality in 2019, it got rejected. Argument was that this is not the right way to do this. See https://github.com/ElementsProject/lightning/pull/5884#issuecomment-1377901823 .

Impa10r commented 6 months ago

Yes, I saw two PRs rejected. I am asking the devs what the right way is to poll incremental history.

daywalker90 commented 6 months ago

use the status + index + start +limit fields: https://docs.corelightning.org/reference/lightning-listforwards, i do this i my summars plugin to only pull things in the last x hours. Just have to remember the index where you looked last time.

Impa10r commented 6 months ago

use the status + index + start +limit fields: https://docs.corelightning.org/reference/lightning-listforwards, i do this i my summars plugin to only pull things in the last x hours. Just have to remember the index where you looked last time.

Oh, thanks a lot! Neither lightning-cli listforwards --help nor glighitning library has this mentioned! Got it to work like this: lightning-cli listforwards -k status="settled" index="created" start=10