* wallet_stmt2channel - Helper to populate a wallet_channel from a `db_stmt` */
| 1254 | * wallet_stmt2channel - Helper to populate a wallet_channel from a `db_stmt` |
| 1255 | */ |
| 1256 | static struct channel *wallet_stmt2channel(struct wallet *w, struct db_stmt *stmt) |
| 1257 | { |
| 1258 | bool ok = true; |
| 1259 | struct channel_info channel_info; |
| 1260 | struct fee_states *fee_states; |
| 1261 | struct height_states *height_states; |
| 1262 | struct short_channel_id *scid, *alias[NUM_SIDES]; |
| 1263 | struct channel_id cid; |
| 1264 | struct channel *chan; |
| 1265 | u64 peer_dbid; |
| 1266 | struct peer *peer; |
| 1267 | struct wallet_shachain wshachain; |
| 1268 | struct channel_config our_config; |
| 1269 | struct bitcoin_outpoint funding; |
| 1270 | struct bitcoin_outpoint *shutdown_wrong_funding; |
| 1271 | struct bitcoin_signature last_sig; |
| 1272 | struct bitcoin_tx *last_tx; |
| 1273 | u8 *remote_shutdown_scriptpubkey; |
| 1274 | u8 *local_shutdown_scriptpubkey; |
| 1275 | struct changed_htlc *last_sent_commit; |
| 1276 | s64 final_key_idx, channel_config_id; |
| 1277 | struct basepoints local_basepoints; |
| 1278 | struct pubkey local_funding_pubkey; |
| 1279 | struct pubkey *future_per_commitment_point; |
| 1280 | struct amount_sat funding_sat, our_funding_sat; |
| 1281 | struct amount_msat push_msat, our_msat, msat_to_us_min, msat_to_us_max, htlc_minimum_msat, htlc_maximum_msat; |
| 1282 | struct channel_type *type; |
| 1283 | secp256k1_ecdsa_signature *lease_commit_sig; |
| 1284 | u32 lease_chan_max_msat; |
| 1285 | u16 lease_chan_max_ppt; |
| 1286 | |
| 1287 | peer_dbid = db_col_u64(stmt, "peer_id"); |
| 1288 | peer = find_peer_by_dbid(w->ld, peer_dbid); |
| 1289 | if (!peer) { |
| 1290 | peer = wallet_peer_load(w, peer_dbid); |
| 1291 | if (!peer) { |
| 1292 | return NULL; |
| 1293 | } |
| 1294 | } |
| 1295 | |
| 1296 | if (!db_col_is_null(stmt, "scid")) { |
| 1297 | scid = tal(tmpctx, struct short_channel_id); |
| 1298 | db_col_scid(stmt, "scid", scid); |
| 1299 | } else { |
| 1300 | scid = NULL; |
| 1301 | } |
| 1302 | |
| 1303 | if (!db_col_is_null(stmt, "alias_local")) { |
| 1304 | alias[LOCAL] = tal(tmpctx, struct short_channel_id); |
| 1305 | db_col_scid(stmt, "alias_local", alias[LOCAL]); |
| 1306 | } else { |
| 1307 | alias[LOCAL] = NULL; |
| 1308 | } |
| 1309 | |
| 1310 | if (!db_col_is_null(stmt, "alias_remote")) { |
| 1311 | alias[REMOTE] = tal(tmpctx, struct short_channel_id); |
| 1312 | db_col_scid(stmt, "alias_remote", alias[REMOTE]); |
| 1313 | } else { |
no test coverage detected