MCPcopy Create free account
hub / github.com/ElementsProject/lightning / handle_peer_shutdown

Function handle_peer_shutdown

openingd/dualopend.c:493–529  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

491}
492
493static 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
531static void handle_our_shutdown(struct state *state, u8 *msg)
532{

Callers 2

opening_negotiate_msgFunction · 0.70
handle_peer_inFunction · 0.70

Calls 8

open_err_fatalFunction · 0.85
tal_hexFunction · 0.85
fromwire_peektypeFunction · 0.85
send_shutdownFunction · 0.85
billboard_updateFunction · 0.70
wire_sync_writeFunction · 0.50
wire_sync_readFunction · 0.50
master_badmsgFunction · 0.50

Tested by

no test coverage detected