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

Function wallet_state_change_get

wallet/wallet.c:1836–1869  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1834}
1835
1836static struct channel_state_change **wallet_state_change_get(const tal_t *ctx,
1837 struct wallet *w,
1838 u64 channel_id)
1839{
1840 struct db_stmt *stmt;
1841 struct channel_state_change **res = tal_arr(ctx,
1842 struct channel_state_change *, 0);
1843 stmt = db_prepare_v2(
1844 w->db, SQL("SELECT"
1845 " timestamp,"
1846 " old_state,"
1847 " new_state,"
1848 " cause,"
1849 " message "
1850 "FROM channel_state_changes "
1851 "WHERE channel_id = ? "
1852 "ORDER BY timestamp ASC;"));
1853 db_bind_int(stmt, channel_id);
1854 db_query_prepared(stmt);
1855
1856 while (db_step(stmt)) {
1857 struct channel_state_change *c;
1858
1859 c = new_channel_state_change(res,
1860 db_col_timeabs(stmt, "timestamp"),
1861 db_col_int(stmt, "old_state"),
1862 db_col_int(stmt, "new_state"),
1863 state_change_in_db(db_col_int(stmt, "cause")),
1864 take(db_col_strdup(NULL, stmt, "message")));
1865 tal_arr_expand(&res, c);
1866 }
1867 tal_free(stmt);
1868 return res;
1869}
1870
1871/**
1872 * wallet_stmt2channel - Helper to populate a wallet_channel from a `db_stmt`

Callers 1

wallet_stmt2channelFunction · 0.85

Calls 9

db_bind_intFunction · 0.85
db_query_preparedFunction · 0.85
db_stepFunction · 0.85
db_col_timeabsFunction · 0.85
db_col_intFunction · 0.85
state_change_in_dbFunction · 0.85
db_col_strdupFunction · 0.85
tal_freeFunction · 0.85
new_channel_state_changeFunction · 0.50

Tested by

no test coverage detected