mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-08 08:34:31 +01:00
wallet: Add function to retrieve a list of payments
Used by the JSON-RPC for the listtransfers call. Currently does not support any form of paging. Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
committed by
Rusty Russell
parent
e0d86376e2
commit
be97673259
@@ -1252,3 +1252,26 @@ void wallet_payment_set_status(struct wallet *wallet,
|
||||
sqlite3_bind_sha256(stmt, 2, payment_hash);
|
||||
db_exec_prepared(wallet->db, stmt);
|
||||
}
|
||||
|
||||
const struct wallet_payment **wallet_payment_list(const tal_t *ctx,
|
||||
struct wallet *wallet)
|
||||
{
|
||||
const struct wallet_payment **payments;
|
||||
sqlite3_stmt *stmt;
|
||||
|
||||
payments = tal_arr(ctx, const struct wallet_payment *, 0);
|
||||
stmt = db_prepare(
|
||||
wallet->db,
|
||||
"SELECT id, status, direction, destination, "
|
||||
"msatoshi , payment_hash, timestamp "
|
||||
"FROM payments;");
|
||||
|
||||
for (int i = 0; sqlite3_step(stmt) == SQLITE_ROW; i++) {
|
||||
tal_resize(&payments, i+1);
|
||||
payments[i] = wallet_stmt2payment(payments, stmt);
|
||||
}
|
||||
|
||||
sqlite3_finalize(stmt);
|
||||
|
||||
return payments;
|
||||
}
|
||||
|
||||
@@ -407,4 +407,10 @@ void wallet_payment_set_status(struct wallet *wallet,
|
||||
const struct sha256 *payment_hash,
|
||||
const enum wallet_payment_status newstatus);
|
||||
|
||||
/**
|
||||
* wallet_payment_list - Retrieve a list of payments
|
||||
*/
|
||||
const struct wallet_payment **wallet_payment_list(const tal_t *ctx,
|
||||
struct wallet *wallet);
|
||||
|
||||
#endif /* WALLET_WALLET_H */
|
||||
|
||||
Reference in New Issue
Block a user