Add settled invoices query rpc
Closed this issue · 2 comments
The settle flow in lnmux is designed such that a connecting application is fully in control. It can keep track of all settled invoices by itself in a safe way.
Lnmux however is also storing all settled invoices so that it can handle potential replays of htlcs that come in later. Currently it is not possible to query that dataset from lnmux and a direct db query is needed.
This issue is about adding an rpc to run queries on the settled invoices. To be decided is what the best way is to do this (think pagination etc).
Good improvement,
If we want to list all settled invoices (using pagination), we need to be careful since invoices
primary key is not a sequence:
We can use settled_at
to create a cursor. But it can be tricky since we can have multiple invoices settled at the exact same microsecond (timestamp in PG is accurate up to microsecond). But it is unlikely since DB calls are sequential
(we can add a real id
like in lnd here)
It could be good to have a GET call to retrieve an invoice by hash in the DB (if the user wants to know if a specific invoice is settled, I don't think that he wants to list the whole DB to find his invoice)
I think adding a sequence number would be good.