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

Function wallet_state_change_get

wallet/wallet.c:2100–2131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2098}
2099
2100struct state_change_entry *wallet_state_change_get(struct wallet *w,
2101 const tal_t *ctx,
2102 u64 channel_id)
2103{
2104 struct db_stmt *stmt;
2105 struct state_change_entry tmp;
2106 struct state_change_entry *res = tal_arr(ctx,
2107 struct state_change_entry, 0);
2108 stmt = db_prepare_v2(
2109 w->db, SQL("SELECT"
2110 " timestamp,"
2111 " old_state,"
2112 " new_state,"
2113 " cause,"
2114 " message "
2115 "FROM channel_state_changes "
2116 "WHERE channel_id = ? "
2117 "ORDER BY timestamp ASC;"));
2118 db_bind_int(stmt, 0, channel_id);
2119 db_query_prepared(stmt);
2120
2121 while (db_step(stmt)) {
2122 tmp.timestamp = db_col_timeabs(stmt, "timestamp");
2123 tmp.old_state = db_col_int(stmt, "old_state");
2124 tmp.new_state = db_col_int(stmt, "new_state");
2125 tmp.cause = db_col_int(stmt, "cause");
2126 tmp.message = db_col_strdup(res, stmt, "message");
2127 tal_arr_expand(&res, tmp);
2128 }
2129 tal_free(stmt);
2130 return res;
2131}
2132
2133static void wallet_peer_save(struct wallet *w, struct peer *peer)
2134{

Callers

nothing calls this directly

Calls 7

db_bind_intFunction · 0.85
db_query_preparedFunction · 0.85
db_stepFunction · 0.85
db_col_timeabsFunction · 0.85
db_col_intFunction · 0.85
db_col_strdupFunction · 0.85
tal_freeFunction · 0.85

Tested by

no test coverage detected