| 6436 | }; |
| 6437 | |
| 6438 | struct wallet_htlc_iter *wallet_htlcs_first(const tal_t *ctx, |
| 6439 | struct wallet *w, |
| 6440 | const struct channel *chan, |
| 6441 | const enum wait_index *listindex, |
| 6442 | u64 liststart, |
| 6443 | const u32 *listlimit, |
| 6444 | struct short_channel_id *scid, |
| 6445 | u64 *htlc_id, |
| 6446 | int *cltv_expiry, |
| 6447 | enum side *owner, |
| 6448 | struct amount_msat *msat, |
| 6449 | struct sha256 *payment_hash, |
| 6450 | enum htlc_state *hstate, |
| 6451 | u64 *created_index, |
| 6452 | u64 *updated_index) |
| 6453 | { |
| 6454 | struct wallet_htlc_iter *i = tal(ctx, struct wallet_htlc_iter); |
| 6455 | |
| 6456 | if (chan) { |
| 6457 | i->scid = channel_scid_or_local_alias(chan); |
| 6458 | assert(i->scid.u64 != 0); |
| 6459 | assert(chan->dbid != 0); |
| 6460 | |
| 6461 | if (listindex && *listindex == WAIT_INDEX_UPDATED) { |
| 6462 | i->stmt = db_prepare_v2(w->db, |
| 6463 | SQL("SELECT h.channel_htlc_id" |
| 6464 | ", h.cltv_expiry" |
| 6465 | ", h.direction" |
| 6466 | ", h.msatoshi" |
| 6467 | ", h.payment_hash" |
| 6468 | ", h.hstate" |
| 6469 | ", h.id" |
| 6470 | ", h.updated_index" |
| 6471 | " FROM channel_htlcs h" |
| 6472 | " WHERE channel_id = ?" |
| 6473 | " AND" |
| 6474 | " updated_index >= ?" |
| 6475 | " ORDER BY h.updated_index ASC" |
| 6476 | " LIMIT ?;")); |
| 6477 | } else { |
| 6478 | i->stmt = db_prepare_v2(w->db, |
| 6479 | SQL("SELECT h.channel_htlc_id" |
| 6480 | ", h.cltv_expiry" |
| 6481 | ", h.direction" |
| 6482 | ", h.msatoshi" |
| 6483 | ", h.payment_hash" |
| 6484 | ", h.hstate" |
| 6485 | ", h.id" |
| 6486 | ", h.updated_index" |
| 6487 | " FROM channel_htlcs h" |
| 6488 | " WHERE channel_id = ?" |
| 6489 | " AND" |
| 6490 | " id >= ?" |
| 6491 | " ORDER BY h.id ASC" |
| 6492 | " LIMIT ?;")); |
| 6493 | } |
| 6494 | db_bind_u64(i->stmt, chan->dbid); |
| 6495 | } else { |
no test coverage detected