| 1190 | } |
| 1191 | |
| 1192 | static void fillin_missing_local_basepoints(struct lightningd *ld, |
| 1193 | struct db *db, |
| 1194 | const struct migration_context *mc) |
| 1195 | { |
| 1196 | |
| 1197 | struct db_stmt *stmt; |
| 1198 | stmt = db_prepare_v2( |
| 1199 | db, |
| 1200 | SQL("SELECT" |
| 1201 | " channels.id" |
| 1202 | ", peers.node_id " |
| 1203 | "FROM" |
| 1204 | " channels JOIN" |
| 1205 | " peers " |
| 1206 | "ON (peers.id = channels.peer_id)")); |
| 1207 | |
| 1208 | db_query_prepared(stmt); |
| 1209 | while (db_step(stmt)) { |
| 1210 | struct node_id peer_id; |
| 1211 | u64 dbid; |
| 1212 | u8 *msg; |
| 1213 | struct db_stmt *upstmt; |
| 1214 | struct basepoints base; |
| 1215 | struct pubkey funding_pubkey; |
| 1216 | |
| 1217 | dbid = db_col_u64(stmt, "channels.id"); |
| 1218 | db_col_node_id(stmt, "peers.node_id", &peer_id); |
| 1219 | |
| 1220 | if (!wire_sync_write(mc->hsm_fd, |
| 1221 | towire_hsmd_get_channel_basepoints( |
| 1222 | tmpctx, &peer_id, dbid))) |
| 1223 | fatal("could not retrieve basepoint from hsmd"); |
| 1224 | |
| 1225 | msg = wire_sync_read(tmpctx, mc->hsm_fd); |
| 1226 | if (!fromwire_hsmd_get_channel_basepoints_reply( |
| 1227 | msg, &base, &funding_pubkey)) |
| 1228 | fatal("malformed hsmd_get_channel_basepoints_reply " |
| 1229 | "from hsmd"); |
| 1230 | |
| 1231 | upstmt = db_prepare_v2( |
| 1232 | db, |
| 1233 | SQL("UPDATE channels SET" |
| 1234 | " revocation_basepoint_local = ?" |
| 1235 | ", payment_basepoint_local = ?" |
| 1236 | ", htlc_basepoint_local = ?" |
| 1237 | ", delayed_payment_basepoint_local = ?" |
| 1238 | ", funding_pubkey_local = ? " |
| 1239 | "WHERE id = ?;")); |
| 1240 | db_bind_pubkey(upstmt, 0, &base.revocation); |
| 1241 | db_bind_pubkey(upstmt, 1, &base.payment); |
| 1242 | db_bind_pubkey(upstmt, 2, &base.htlc); |
| 1243 | db_bind_pubkey(upstmt, 3, &base.delayed_payment); |
| 1244 | db_bind_pubkey(upstmt, 4, &funding_pubkey); |
| 1245 | |
| 1246 | db_bind_u64(upstmt, 5, dbid); |
| 1247 | |
| 1248 | db_exec_prepared_v2(take(upstmt)); |
| 1249 | } |
nothing calls this directly
no test coverage detected