mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-12 10:30:29 +01:00
wallet: list addresses query
This commit is contained in:
parent
bb252983c2
commit
af2f9601c6
2 changed files with 41 additions and 0 deletions
|
@ -6377,3 +6377,25 @@ struct local_anchor_info *wallet_get_local_anchors(const tal_t *ctx,
|
|||
|
||||
return anchors;
|
||||
}
|
||||
|
||||
struct issued_address_type *wallet_list_addresses(const tal_t *ctx, struct wallet *wallet,
|
||||
u64 liststart, const u32 *listlimit)
|
||||
{
|
||||
struct db_stmt *stmt;
|
||||
struct issued_address_type *addresseslist = tal_arr(ctx, struct issued_address_type, 0);
|
||||
stmt = db_prepare_v2(wallet->db, SQL("SELECT keyidx, addrtype FROM addresses WHERE keyidx >= ? ORDER BY keyidx LIMIT ?;"));
|
||||
db_bind_u64(stmt, liststart);
|
||||
if (listlimit)
|
||||
db_bind_int(stmt, *listlimit);
|
||||
else
|
||||
db_bind_int(stmt, INT_MAX);
|
||||
db_query_prepared(stmt);
|
||||
while(db_step(stmt)) {
|
||||
struct issued_address_type a;
|
||||
a.keyidx = db_col_u64(stmt, "keyidx");
|
||||
a.addrtype = wallet_addrtype_in_db(db_col_int(stmt, "addrtype"));
|
||||
tal_arr_expand(&addresseslist, a);
|
||||
}
|
||||
tal_free(stmt);
|
||||
return addresseslist;
|
||||
}
|
||||
|
|
|
@ -1798,4 +1798,23 @@ void wallet_remove_local_anchors(struct wallet *w,
|
|||
struct local_anchor_info *wallet_get_local_anchors(const tal_t *ctx,
|
||||
struct wallet *w,
|
||||
u64 channel_id);
|
||||
|
||||
/* Get the addresses addrtype */
|
||||
struct issued_address_type {
|
||||
u64 keyidx;
|
||||
enum addrtype addrtype;
|
||||
};
|
||||
|
||||
/**
|
||||
* wallet_list_addresses: get the list of addresses with addrtype
|
||||
*
|
||||
* @ctx: tal context for returned array
|
||||
* @wallet: the wallet
|
||||
* @liststart: first index to return (0 == all).
|
||||
* @listlimit: limit on number of entries to return (NULL == no limit).
|
||||
*
|
||||
* Returns NULL if none, otherwise list of addresses with addrtype.
|
||||
*/
|
||||
struct issued_address_type *wallet_list_addresses(const tal_t *ctx, struct wallet *wallet,
|
||||
u64 liststart, const u32 *listlimit);
|
||||
#endif /* LIGHTNING_WALLET_WALLET_H */
|
||||
|
|
Loading…
Add table
Reference in a new issue