| 319 | } |
| 320 | |
| 321 | static void handle_splice_abort(struct lightningd *ld, |
| 322 | struct channel *channel, |
| 323 | const u8 *msg) |
| 324 | { |
| 325 | struct splice_command *cc; |
| 326 | struct peer *peer = channel->peer; |
| 327 | bool did_i_abort; |
| 328 | struct bitcoin_outpoint *outpoint; |
| 329 | struct channel_inflight *inflight; |
| 330 | char *reason; |
| 331 | const u8 *error; |
| 332 | struct peer_fd *pfd; |
| 333 | int other_fd; |
| 334 | |
| 335 | if (!fromwire_channeld_splice_abort(tmpctx, msg, &did_i_abort, |
| 336 | &outpoint, &reason)) { |
| 337 | channel_internal_error(channel, |
| 338 | "bad fromwire_channeld_splice_abort %s", |
| 339 | tal_hex(channel, msg)); |
| 340 | return; |
| 341 | } |
| 342 | |
| 343 | if (outpoint) { |
| 344 | inflight = list_tail(&channel->inflights, |
| 345 | struct channel_inflight, |
| 346 | list); |
| 347 | |
| 348 | if (!bitcoin_outpoint_eq(outpoint, |
| 349 | &inflight->funding->outpoint)) |
| 350 | channel_internal_error(channel, |
| 351 | "abort outpoint %s does not" |
| 352 | " match ours %s", |
| 353 | fmt_bitcoin_outpoint(tmpctx, |
| 354 | outpoint), |
| 355 | fmt_bitcoin_outpoint(tmpctx, |
| 356 | &inflight->funding->outpoint)); |
| 357 | |
| 358 | wallet_inflight_del(ld->wallet, channel, inflight); |
| 359 | tal_free(inflight); |
| 360 | } |
| 361 | |
| 362 | cc = splice_command_for_chan(ld, channel); |
| 363 | if (cc) |
| 364 | was_pending(command_fail(cc->cmd, SPLICE_ABORT, "%s", reason)); |
| 365 | else |
| 366 | log_peer_unusual(ld->log, &peer->id, "Splice aborted" |
| 367 | " %s", reason); |
| 368 | |
| 369 | log_debug(channel->log, |
| 370 | "Restarting channeld after tx_abort on %s channel", |
| 371 | channel_state_name(channel)); |
| 372 | |
| 373 | pfd = sockpair(tmpctx, channel, &other_fd, &error); |
| 374 | if (!pfd) { |
| 375 | /* Get connectd to send error and close. */ |
| 376 | subd_send_msg(ld->connectd, |
| 377 | take(towire_connectd_peer_send_msg(NULL, |
| 378 | &peer->id, |
no test coverage detected