| 403 | } |
| 404 | |
| 405 | static void handle_peer_shutdown(struct state *state, u8 *msg) |
| 406 | { |
| 407 | u8 *scriptpubkey; |
| 408 | struct channel_id cid; |
| 409 | struct tlv_shutdown_tlvs *tlvs; |
| 410 | |
| 411 | if (!fromwire_shutdown(tmpctx, msg, &cid, &scriptpubkey, &tlvs)) |
| 412 | open_err_warn(state, "Bad shutdown %s", tal_hex(msg, msg)); |
| 413 | |
| 414 | if (tal_count(state->upfront_shutdown_script[REMOTE]) |
| 415 | && !memeq(scriptpubkey, tal_count(scriptpubkey), |
| 416 | state->upfront_shutdown_script[REMOTE], |
| 417 | tal_count(state->upfront_shutdown_script[REMOTE]))) |
| 418 | open_err_warn(state, |
| 419 | "scriptpubkey %s is not as agreed upfront (%s)", |
| 420 | tal_hex(state, scriptpubkey), |
| 421 | tal_hex(state, |
| 422 | state->upfront_shutdown_script[REMOTE])); |
| 423 | |
| 424 | /* @niftynei points out that negotiated this together, so this |
| 425 | * hack is not required (or safe!). */ |
| 426 | if (tlvs->wrong_funding) |
| 427 | open_err_warn(state, |
| 428 | "wrong_funding shutdown" |
| 429 | " invalid for dual-funding"); |
| 430 | |
| 431 | wire_sync_write(REQ_FD, |
| 432 | take(towire_dualopend_got_shutdown(NULL, |
| 433 | scriptpubkey))); |
| 434 | msg = wire_sync_read(tmpctx, REQ_FD); |
| 435 | if (!fromwire_dualopend_send_shutdown(tmpctx, msg, &scriptpubkey)) |
| 436 | master_badmsg(fromwire_peektype(msg), msg); |
| 437 | |
| 438 | state->shutdown_sent[REMOTE] = true; |
| 439 | if (!state->shutdown_sent[LOCAL]) |
| 440 | send_shutdown(state, scriptpubkey); |
| 441 | |
| 442 | billboard_update(state); |
| 443 | } |
| 444 | |
| 445 | static void handle_our_shutdown(struct state *state, u8 *msg) |
| 446 | { |
no test coverage detected