| 6496 | }; |
| 6497 | |
| 6498 | struct wallet_htlc_iter *wallet_htlcs_first(const tal_t *ctx, |
| 6499 | struct wallet *w, |
| 6500 | const struct channel *chan, |
| 6501 | const enum wait_index *listindex, |
| 6502 | u64 liststart, |
| 6503 | const u32 *listlimit, |
| 6504 | struct short_channel_id *scid, |
| 6505 | u64 *htlc_id, |
| 6506 | int *cltv_expiry, |
| 6507 | enum side *owner, |
| 6508 | struct amount_msat *msat, |
| 6509 | struct sha256 *payment_hash, |
| 6510 | enum htlc_state *hstate, |
| 6511 | u64 *created_index, |
| 6512 | u64 *updated_index) |
| 6513 | { |
| 6514 | struct wallet_htlc_iter *i = tal(ctx, struct wallet_htlc_iter); |
| 6515 | |
| 6516 | if (chan) { |
| 6517 | i->scid = channel_scid_or_local_alias(chan); |
| 6518 | assert(i->scid.u64 != 0); |
| 6519 | assert(chan->dbid != 0); |
| 6520 | |
| 6521 | if (listindex && *listindex == WAIT_INDEX_UPDATED) { |
| 6522 | i->stmt = db_prepare_v2(w->db, |
| 6523 | SQL("SELECT h.channel_htlc_id" |
| 6524 | ", h.cltv_expiry" |
| 6525 | ", h.direction" |
| 6526 | ", h.msatoshi" |
| 6527 | ", h.payment_hash" |
| 6528 | ", h.hstate" |
| 6529 | ", h.id" |
| 6530 | ", h.updated_index" |
| 6531 | " FROM channel_htlcs h" |
| 6532 | " WHERE channel_id = ?" |
| 6533 | " AND" |
| 6534 | " updated_index >= ?" |
| 6535 | " ORDER BY h.updated_index ASC" |
| 6536 | " LIMIT ?;")); |
| 6537 | } else { |
| 6538 | i->stmt = db_prepare_v2(w->db, |
| 6539 | SQL("SELECT h.channel_htlc_id" |
| 6540 | ", h.cltv_expiry" |
| 6541 | ", h.direction" |
| 6542 | ", h.msatoshi" |
| 6543 | ", h.payment_hash" |
| 6544 | ", h.hstate" |
| 6545 | ", h.id" |
| 6546 | ", h.updated_index" |
| 6547 | " FROM channel_htlcs h" |
| 6548 | " WHERE channel_id = ?" |
| 6549 | " AND" |
| 6550 | " id >= ?" |
| 6551 | " ORDER BY h.id ASC" |
| 6552 | " LIMIT ?;")); |
| 6553 | } |
| 6554 | db_bind_u64(i->stmt, chan->dbid); |
| 6555 | } else { |
no test coverage detected