| 1191 | } |
| 1192 | |
| 1193 | struct account **list_accounts(const tal_t *ctx, struct db *db) |
| 1194 | { |
| 1195 | struct db_stmt *stmt; |
| 1196 | struct account **results; |
| 1197 | |
| 1198 | stmt = db_prepare_v2(db, SQL("SELECT" |
| 1199 | " id" |
| 1200 | ", name" |
| 1201 | ", peer_id" |
| 1202 | ", opened_event_id" |
| 1203 | ", closed_event_id" |
| 1204 | ", onchain_resolved_block" |
| 1205 | ", is_wallet" |
| 1206 | ", we_opened" |
| 1207 | ", leased" |
| 1208 | ", closed_count" |
| 1209 | " FROM accounts;")); |
| 1210 | db_query_prepared(stmt); |
| 1211 | |
| 1212 | results = tal_arr(ctx, struct account *, 0); |
| 1213 | while (db_step(stmt)) { |
| 1214 | struct account *a = stmt2account(results, stmt); |
| 1215 | tal_arr_expand(&results, a); |
| 1216 | } |
| 1217 | tal_free(stmt); |
| 1218 | |
| 1219 | return results; |
| 1220 | } |
| 1221 | |
| 1222 | void account_add(struct db *db, struct account *acct) |
| 1223 | { |