| 292 | } |
| 293 | |
| 294 | void drop_to_chain(struct lightningd *ld, struct channel *channel, |
| 295 | bool cooperative) |
| 296 | { |
| 297 | struct channel_inflight *inflight; |
| 298 | const char *cmd_id; |
| 299 | |
| 300 | /* If this was triggered by a close command, get a copy of the cmd id */ |
| 301 | cmd_id = resolve_close_command(tmpctx, ld, channel, cooperative); |
| 302 | |
| 303 | /* BOLT #2: |
| 304 | * |
| 305 | * - if `next_revocation_number` is greater than expected |
| 306 | * above, AND `your_last_per_commitment_secret` is correct for that |
| 307 | * `next_revocation_number` minus 1: |
| 308 | * - MUST NOT broadcast its commitment transaction. |
| 309 | */ |
| 310 | if (channel->future_per_commitment_point && !cooperative) { |
| 311 | log_broken(channel->log, |
| 312 | "Cannot broadcast our commitment tx:" |
| 313 | " they have a future one"); |
| 314 | } else if (invalid_last_tx(channel->last_tx)) { |
| 315 | log_broken(channel->log, |
| 316 | "Cannot broadcast our commitment tx:" |
| 317 | " it's invalid! (ancient channel?)"); |
| 318 | } else { |
| 319 | /* We need to drop *every* commitment transaction to chain */ |
| 320 | if (!cooperative && !list_empty(&channel->inflights)) { |
| 321 | list_for_each(&channel->inflights, inflight, list) |
| 322 | sign_and_send_last(ld, channel, cmd_id, |
| 323 | inflight->last_tx, |
| 324 | &inflight->last_sig); |
| 325 | } else |
| 326 | sign_and_send_last(ld, channel, cmd_id, channel->last_tx, |
| 327 | &channel->last_sig); |
| 328 | } |
| 329 | |
| 330 | } |
| 331 | |
| 332 | void resend_closing_transactions(struct lightningd *ld) |
| 333 | { |
no test coverage detected