| 5551 | } |
| 5552 | |
| 5553 | struct db_stmt *forwarding_first(struct wallet *w, |
| 5554 | enum forward_status status, |
| 5555 | const struct short_channel_id *chan_in, |
| 5556 | const struct short_channel_id *chan_out, |
| 5557 | const enum wait_index *listindex, |
| 5558 | u64 liststart, |
| 5559 | const u32 *listlimit) |
| 5560 | { |
| 5561 | struct db_stmt *stmt; |
| 5562 | |
| 5563 | // placeholder for any parameter, the value doesn't matter because it's discarded by sql |
| 5564 | const int any = -1; |
| 5565 | |
| 5566 | /* We don't support start/limits with this */ |
| 5567 | if (chan_in || chan_out) { |
| 5568 | stmt = db_prepare_v2( |
| 5569 | w->db, |
| 5570 | SQL("SELECT" |
| 5571 | " state" |
| 5572 | ", in_msatoshi" |
| 5573 | ", out_msatoshi" |
| 5574 | ", in_channel_scid" |
| 5575 | ", out_channel_scid" |
| 5576 | ", in_htlc_id" |
| 5577 | ", out_htlc_id" |
| 5578 | ", received_time" |
| 5579 | ", resolved_time" |
| 5580 | ", failcode " |
| 5581 | ", forward_style " |
| 5582 | ", rowid " |
| 5583 | ", updated_index " |
| 5584 | "FROM forwards " |
| 5585 | "WHERE (1 = ? OR state = ?) AND " |
| 5586 | "(1 = ? OR in_channel_scid = ?) AND " |
| 5587 | "(1 = ? OR out_channel_scid = ?)")); |
| 5588 | |
| 5589 | if (status == FORWARD_ANY) { |
| 5590 | // any status |
| 5591 | db_bind_int(stmt, 1); |
| 5592 | db_bind_int(stmt, any); |
| 5593 | } else { |
| 5594 | // specific forward status |
| 5595 | db_bind_int(stmt, 0); |
| 5596 | db_bind_int(stmt, status); |
| 5597 | } |
| 5598 | |
| 5599 | if (chan_in) { |
| 5600 | // specific in_channel |
| 5601 | db_bind_int(stmt, 0); |
| 5602 | db_bind_short_channel_id(stmt, *chan_in); |
| 5603 | } else { |
| 5604 | // any in_channel |
| 5605 | db_bind_int(stmt, 1); |
| 5606 | db_bind_int(stmt, any); |
| 5607 | } |
| 5608 | |
| 5609 | if (chan_out) { |
| 5610 | // specific out_channel |
no test coverage detected