mirror of
https://github.com/aljazceru/lightning.git
synced 2026-02-23 06:54:30 +01:00
listinvoices: add index and start params.
Now we have defined ordering, we can add a start param. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Changelog-Added: JSON-RPC: `listinvoices` has `index` and `start` parameters for listing control.
This commit is contained in:
@@ -964,6 +964,7 @@ static struct migration dbmigrations[] = {
|
||||
{SQL("ALTER TABLE channels ADD ignore_fee_limits INTEGER DEFAULT 0;"), NULL},
|
||||
{NULL, migrate_initialize_wait_indexes},
|
||||
{SQL("ALTER TABLE invoices ADD updated_index BIGINT DEFAULT 0"), NULL},
|
||||
{SQL("CREATE INDEX invoice_update_idx ON invoices (updated_index)"), NULL},
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -470,11 +470,24 @@ void invoices_delete_expired(struct invoices *invoices,
|
||||
}
|
||||
|
||||
struct db_stmt *invoices_first(struct invoices *invoices,
|
||||
const enum wait_index *listindex,
|
||||
u64 liststart,
|
||||
u64 *inv_dbid)
|
||||
{
|
||||
struct db_stmt *stmt;
|
||||
|
||||
stmt = db_prepare_v2(invoices->wallet->db, SQL("SELECT id FROM invoices ORDER by id;"));
|
||||
if (listindex && *listindex == WAIT_INDEX_UPDATED) {
|
||||
stmt = db_prepare_v2(invoices->wallet->db,
|
||||
SQL("SELECT id FROM invoices"
|
||||
" WHERE updated_index >= ?"
|
||||
" ORDER BY updated_index;"));
|
||||
} else {
|
||||
stmt = db_prepare_v2(invoices->wallet->db,
|
||||
SQL("SELECT id FROM invoices"
|
||||
" WHERE id >= ?"
|
||||
" ORDER BY id;"));
|
||||
}
|
||||
db_bind_u64(stmt, liststart);
|
||||
db_query_prepared(stmt);
|
||||
|
||||
return invoices_next(invoices, stmt, inv_dbid);
|
||||
|
||||
@@ -138,12 +138,16 @@ void invoices_delete_expired(struct invoices *invoices,
|
||||
/**
|
||||
* Iterate through all the invoices.
|
||||
* @invoices: the invoices
|
||||
* @listindex: what index order to use (if you care)
|
||||
* @liststart: first index to return (0 == all).
|
||||
* @inv_dbid: the first invoice dbid (if returns non-NULL)
|
||||
*
|
||||
* Returns pointer to hand as @stmt to invoices_next(), or NULL.
|
||||
* If you choose not to call invoices_next() you must free it!
|
||||
*/
|
||||
struct db_stmt *invoices_first(struct invoices *invoices,
|
||||
const enum wait_index *listindex,
|
||||
u64 liststart,
|
||||
u64 *inv_dbid);
|
||||
|
||||
/**
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <lightningd/bitcoind.h>
|
||||
#include <lightningd/log.h>
|
||||
#include <lightningd/peer_htlcs.h>
|
||||
#include <lightningd/wait.h>
|
||||
|
||||
struct amount_msat;
|
||||
struct invoices;
|
||||
|
||||
Reference in New Issue
Block a user