| 491 | } |
| 492 | |
| 493 | static void handle_peer_shutdown(struct state *state, u8 *msg) |
| 494 | { |
| 495 | u8 *scriptpubkey; |
| 496 | struct channel_id cid; |
| 497 | struct tlv_shutdown_tlvs *tlvs; |
| 498 | |
| 499 | if (!fromwire_shutdown(tmpctx, msg, &cid, &scriptpubkey, &tlvs)) |
| 500 | open_err_fatal(state, "Bad shutdown %s", tal_hex(msg, msg)); |
| 501 | |
| 502 | if (tal_count(state->upfront_shutdown_script[REMOTE]) |
| 503 | && !tal_arr_eq(scriptpubkey, state->upfront_shutdown_script[REMOTE])) |
| 504 | open_err_fatal(state, |
| 505 | "scriptpubkey %s is not as agreed upfront (%s)", |
| 506 | tal_hex(state, scriptpubkey), |
| 507 | tal_hex(state, |
| 508 | state->upfront_shutdown_script[REMOTE])); |
| 509 | |
| 510 | /* @niftynei points out that negotiated this together, so this |
| 511 | * hack is not required (or safe!). */ |
| 512 | if (tlvs->wrong_funding) |
| 513 | open_err_fatal(state, |
| 514 | "wrong_funding shutdown" |
| 515 | " invalid for dual-funding"); |
| 516 | |
| 517 | wire_sync_write(REQ_FD, |
| 518 | take(towire_dualopend_got_shutdown(NULL, |
| 519 | scriptpubkey))); |
| 520 | msg = wire_sync_read(tmpctx, REQ_FD); |
| 521 | if (!fromwire_dualopend_send_shutdown(tmpctx, msg, &scriptpubkey)) |
| 522 | master_badmsg(fromwire_peektype(msg), msg); |
| 523 | |
| 524 | state->shutdown_sent[REMOTE] = true; |
| 525 | if (!state->shutdown_sent[LOCAL]) |
| 526 | send_shutdown(state, scriptpubkey); |
| 527 | |
| 528 | billboard_update(state); |
| 529 | } |
| 530 | |
| 531 | static void handle_our_shutdown(struct state *state, u8 *msg) |
| 532 | { |
no test coverage detected