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

Function handle_peer_shutdown

openingd/dualopend.c:405–443  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

403}
404
405static 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
445static void handle_our_shutdown(struct state *state, u8 *msg)
446{

Callers 2

opening_negotiate_msgFunction · 0.70
handle_peer_inFunction · 0.70

Calls 9

open_err_warnFunction · 0.85
tal_hexFunction · 0.85
memeqFunction · 0.85
send_shutdownFunction · 0.85
billboard_updateFunction · 0.70
wire_sync_writeFunction · 0.50
wire_sync_readFunction · 0.50
master_badmsgFunction · 0.50
fromwire_peektypeFunction · 0.50

Tested by

no test coverage detected