MCPcopy Create free account
hub / github.com/ElementsProject/lightning / forwarding_first

Function forwarding_first

wallet/wallet.c:5590–5734  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5588}
5589
5590struct db_stmt *forwarding_first(struct wallet *w,
5591 enum forward_status status,
5592 const struct short_channel_id *chan_in,
5593 const struct short_channel_id *chan_out,
5594 const enum wait_index *listindex,
5595 u64 liststart,
5596 const u32 *listlimit)
5597{
5598 struct db_stmt *stmt;
5599
5600 // placeholder for any parameter, the value doesn't matter because it's discarded by sql
5601 const int any = -1;
5602
5603 /* We don't support start/limits with this */
5604 if (chan_in || chan_out) {
5605 stmt = db_prepare_v2(
5606 w->db,
5607 SQL("SELECT"
5608 " state"
5609 ", in_msatoshi"
5610 ", out_msatoshi"
5611 ", in_channel_scid"
5612 ", out_channel_scid"
5613 ", in_htlc_id"
5614 ", out_htlc_id"
5615 ", received_time"
5616 ", resolved_time"
5617 ", failcode "
5618 ", forward_style "
5619 ", rowid "
5620 ", updated_index "
5621 "FROM forwards "
5622 "WHERE (1 = ? OR state = ?) AND "
5623 "(1 = ? OR in_channel_scid = ?) AND "
5624 "(1 = ? OR out_channel_scid = ?)"));
5625
5626 if (status == FORWARD_ANY) {
5627 // any status
5628 db_bind_int(stmt, 1);
5629 db_bind_int(stmt, any);
5630 } else {
5631 // specific forward status
5632 db_bind_int(stmt, 0);
5633 db_bind_int(stmt, status);
5634 }
5635
5636 if (chan_in) {
5637 // specific in_channel
5638 db_bind_int(stmt, 0);
5639 db_bind_short_channel_id(stmt, *chan_in);
5640 } else {
5641 // any in_channel
5642 db_bind_int(stmt, 1);
5643 db_bind_int(stmt, any);
5644 }
5645
5646 if (chan_out) {
5647 // specific out_channel

Callers 1

Calls 5

db_bind_intFunction · 0.85
db_bind_short_channel_idFunction · 0.85
db_bind_u64Function · 0.85
db_query_preparedFunction · 0.85
forwarding_nextFunction · 0.85

Tested by

no test coverage detected