| 1220 | } |
| 1221 | |
| 1222 | static bool wallet_channel_config_load(struct wallet *w, const u64 id, |
| 1223 | struct channel_config *cc) |
| 1224 | { |
| 1225 | bool ok = true; |
| 1226 | const char *query = SQL( |
| 1227 | "SELECT dust_limit_satoshis, max_htlc_value_in_flight_msat, " |
| 1228 | "channel_reserve_satoshis, htlc_minimum_msat, to_self_delay, " |
| 1229 | "max_accepted_htlcs, max_dust_htlc_exposure_msat" |
| 1230 | " FROM channel_configs WHERE id= ? ;"); |
| 1231 | struct db_stmt *stmt = db_prepare_v2(w->db, query); |
| 1232 | db_bind_u64(stmt, 0, id); |
| 1233 | db_query_prepared(stmt); |
| 1234 | |
| 1235 | if (!db_step(stmt)) |
| 1236 | return false; |
| 1237 | |
| 1238 | cc->id = id; |
| 1239 | db_col_amount_sat(stmt, "dust_limit_satoshis", &cc->dust_limit); |
| 1240 | db_col_amount_msat(stmt, "max_htlc_value_in_flight_msat", |
| 1241 | &cc->max_htlc_value_in_flight); |
| 1242 | db_col_amount_sat(stmt, "channel_reserve_satoshis", |
| 1243 | &cc->channel_reserve); |
| 1244 | db_col_amount_msat(stmt, "htlc_minimum_msat", &cc->htlc_minimum); |
| 1245 | cc->to_self_delay = db_col_int(stmt, "to_self_delay"); |
| 1246 | cc->max_accepted_htlcs = db_col_int(stmt, "max_accepted_htlcs"); |
| 1247 | db_col_amount_msat(stmt, "max_dust_htlc_exposure_msat", |
| 1248 | &cc->max_dust_htlc_exposure_msat); |
| 1249 | tal_free(stmt); |
| 1250 | return ok; |
| 1251 | } |
| 1252 | |
| 1253 | /** |
| 1254 | * wallet_stmt2channel - Helper to populate a wallet_channel from a `db_stmt` |