| 275 | } |
| 276 | |
| 277 | struct utxo **wallet_get_utxos(const tal_t *ctx, struct wallet *w, const enum output_status state) |
| 278 | { |
| 279 | struct utxo **results; |
| 280 | int i; |
| 281 | struct db_stmt *stmt; |
| 282 | |
| 283 | if (state == OUTPUT_STATE_ANY) { |
| 284 | stmt = db_prepare_v2(w->db, SQL("SELECT" |
| 285 | " prev_out_tx" |
| 286 | ", prev_out_index" |
| 287 | ", value" |
| 288 | ", type" |
| 289 | ", status" |
| 290 | ", keyindex" |
| 291 | ", channel_id" |
| 292 | ", peer_id" |
| 293 | ", commitment_point" |
| 294 | ", option_anchor_outputs" |
| 295 | ", confirmation_height" |
| 296 | ", spend_height" |
| 297 | ", scriptpubkey " |
| 298 | ", reserved_til " |
| 299 | ", csv_lock " |
| 300 | "FROM outputs")); |
| 301 | } else { |
| 302 | stmt = db_prepare_v2(w->db, SQL("SELECT" |
| 303 | " prev_out_tx" |
| 304 | ", prev_out_index" |
| 305 | ", value" |
| 306 | ", type" |
| 307 | ", status" |
| 308 | ", keyindex" |
| 309 | ", channel_id" |
| 310 | ", peer_id" |
| 311 | ", commitment_point" |
| 312 | ", option_anchor_outputs" |
| 313 | ", confirmation_height" |
| 314 | ", spend_height" |
| 315 | ", scriptpubkey " |
| 316 | ", reserved_til " |
| 317 | ", csv_lock " |
| 318 | "FROM outputs " |
| 319 | "WHERE status= ? ")); |
| 320 | db_bind_int(stmt, 0, output_status_in_db(state)); |
| 321 | } |
| 322 | db_query_prepared(stmt); |
| 323 | |
| 324 | results = tal_arr(ctx, struct utxo*, 0); |
| 325 | for (i=0; db_step(stmt); i++) { |
| 326 | struct utxo *u = wallet_stmt2output(results, stmt); |
| 327 | tal_arr_expand(&results, u); |
| 328 | } |
| 329 | tal_free(stmt); |
| 330 | |
| 331 | return results; |
| 332 | } |
| 333 | |
| 334 | struct utxo **wallet_get_unconfirmed_closeinfo_utxos(const tal_t *ctx, |
no test coverage detected