| 282 | } |
| 283 | |
| 284 | void fillin_missing_local_basepoints(struct lightningd *ld, |
| 285 | struct db *db) |
| 286 | { |
| 287 | |
| 288 | struct db_stmt *stmt; |
| 289 | stmt = db_prepare_v2( |
| 290 | db, |
| 291 | SQL("SELECT" |
| 292 | " channels.id" |
| 293 | ", peers.node_id " |
| 294 | "FROM" |
| 295 | " channels JOIN" |
| 296 | " peers " |
| 297 | "ON (peers.id = channels.peer_id)")); |
| 298 | |
| 299 | db_query_prepared(stmt); |
| 300 | while (db_step(stmt)) { |
| 301 | struct node_id peer_id; |
| 302 | u64 dbid; |
| 303 | u8 *msg; |
| 304 | struct db_stmt *upstmt; |
| 305 | struct basepoints base; |
| 306 | struct pubkey funding_pubkey; |
| 307 | |
| 308 | dbid = db_col_u64(stmt, "channels.id"); |
| 309 | db_col_node_id(stmt, "peers.node_id", &peer_id); |
| 310 | |
| 311 | if (!wire_sync_write(ld->hsm_fd, |
| 312 | towire_hsmd_get_channel_basepoints( |
| 313 | tmpctx, &peer_id, dbid))) |
| 314 | fatal("could not retrieve basepoint from hsmd"); |
| 315 | |
| 316 | msg = wire_sync_read(tmpctx, ld->hsm_fd); |
| 317 | if (!fromwire_hsmd_get_channel_basepoints_reply( |
| 318 | msg, &base, &funding_pubkey)) |
| 319 | fatal("malformed hsmd_get_channel_basepoints_reply " |
| 320 | "from hsmd"); |
| 321 | |
| 322 | upstmt = db_prepare_v2( |
| 323 | db, |
| 324 | SQL("UPDATE channels SET" |
| 325 | " revocation_basepoint_local = ?" |
| 326 | ", payment_basepoint_local = ?" |
| 327 | ", htlc_basepoint_local = ?" |
| 328 | ", delayed_payment_basepoint_local = ?" |
| 329 | ", funding_pubkey_local = ? " |
| 330 | "WHERE id = ?;")); |
| 331 | db_bind_pubkey(upstmt, &base.revocation); |
| 332 | db_bind_pubkey(upstmt, &base.payment); |
| 333 | db_bind_pubkey(upstmt, &base.htlc); |
| 334 | db_bind_pubkey(upstmt, &base.delayed_payment); |
| 335 | db_bind_pubkey(upstmt, &funding_pubkey); |
| 336 | |
| 337 | db_bind_u64(upstmt, dbid); |
| 338 | |
| 339 | db_exec_prepared_v2(take(upstmt)); |
| 340 | } |
| 341 |
nothing calls this directly
no test coverage detected