| 87 | } |
| 88 | |
| 89 | static struct channel_event *stmt2channel_event(const tal_t *ctx, struct db_stmt *stmt) |
| 90 | { |
| 91 | struct channel_event *e = tal(ctx, struct channel_event); |
| 92 | |
| 93 | e->db_id = db_col_u64(stmt, "e.id"); |
| 94 | e->acct_db_id = db_col_u64(stmt, "e.account_id"); |
| 95 | e->acct_name = db_col_strdup(e, stmt, "a.name"); |
| 96 | |
| 97 | e->tag = db_col_strdup(e, stmt, "e.tag"); |
| 98 | |
| 99 | db_col_amount_msat(stmt, "e.credit", &e->credit); |
| 100 | db_col_amount_msat(stmt, "e.debit", &e->debit); |
| 101 | db_col_amount_msat(stmt, "e.fees", &e->fees); |
| 102 | |
| 103 | e->currency = db_col_strdup(e, stmt, "e.currency"); |
| 104 | if (!db_col_is_null(stmt, "e.payment_id")) { |
| 105 | e->payment_id = tal(e, struct sha256); |
| 106 | db_col_sha256(stmt, "e.payment_id", e->payment_id); |
| 107 | } else |
| 108 | e->payment_id = NULL; |
| 109 | e->part_id = db_col_int(stmt, "e.part_id"); |
| 110 | e->timestamp = db_col_u64(stmt, "e.timestamp"); |
| 111 | |
| 112 | if (!db_col_is_null(stmt, "e.ev_desc")) |
| 113 | e->desc = db_col_strdup(e, stmt, "e.ev_desc"); |
| 114 | else |
| 115 | e->desc = NULL; |
| 116 | |
| 117 | if (!db_col_is_null(stmt, "e.rebalance_id")) { |
| 118 | e->rebalance_id = tal(e, u64); |
| 119 | *e->rebalance_id = db_col_u64(stmt, "e.rebalance_id"); |
| 120 | } else |
| 121 | e->rebalance_id = NULL; |
| 122 | |
| 123 | return e; |
| 124 | } |
| 125 | |
| 126 | static struct rebalance *stmt2rebalance(const tal_t *ctx, struct db_stmt *stmt) |
| 127 | { |
no test coverage detected