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

Function peer_start_closingd

lightningd/closing_control.c:515–662  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

513}
514
515void peer_start_closingd(struct channel *channel, struct peer_fd *peer_fd)
516{
517 u8 *initmsg;
518 u32 min_feerate, feerate, max_feerate;
519 struct amount_msat their_msat;
520 int hsmfd;
521 struct lightningd *ld = channel->peer->ld;
522 u32 final_commit_feerate;
523 bool option_anchor_outputs = channel_has(channel, OPT_ANCHOR_OUTPUTS_DEPRECATED);
524 bool option_anchors_zero_fee_htlc_tx = channel_has(channel, OPT_ANCHORS_ZERO_FEE_HTLC_TX);
525
526 if (!channel->shutdown_scriptpubkey[REMOTE]) {
527 channel_internal_error(channel,
528 "Can't start closing: no remote info");
529 return;
530 }
531
532 hsmfd = hsm_get_client_fd(ld, &channel->peer->id, channel->dbid,
533 HSM_PERM_SIGN_CLOSING_TX
534 | HSM_PERM_COMMITMENT_POINT);
535 if (hsmfd < 0) {
536 log_broken(channel->log, "Could not get hsm fd for closing: %s",
537 strerror(errno));
538 force_peer_disconnect(ld, channel->peer,
539 "Failed to get hsm fd for closingd");
540 return;
541 }
542
543 channel_set_owner(channel,
544 new_channel_subd(channel, ld,
545 "lightning_closingd",
546 channel, &channel->peer->id,
547 channel->log, true,
548 closingd_wire_name, closing_msg,
549 channel_errmsg,
550 channel_set_billboard,
551 take(&peer_fd->fd),
552 take(&hsmfd),
553 NULL));
554
555 if (!channel->owner) {
556 log_broken(channel->log, "Could not subdaemon closing: %s",
557 strerror(errno));
558 /* Disconnect it. */
559 force_peer_disconnect(ld, channel->peer,
560 "Failed to create closingd");
561 return;
562 }
563
564 /* BOLT #2:
565 * The sending node:
566 * - SHOULD set the initial `fee_satoshis` according to its estimate of cost of
567 * inclusion in a block.
568 * - SHOULD set `fee_range` according to the minimum and maximum fees it is
569 * prepared to pay for a close transaction.
570 */
571 final_commit_feerate = get_feerate(channel->fee_states,
572 channel->opener, LOCAL);

Callers 2

handle_channel_closedFunction · 0.85

Calls 15

hsm_get_client_fdFunction · 0.85
channel_set_ownerFunction · 0.85
calc_max_close_feerateFunction · 0.85
feerate_minFunction · 0.85
amount_sat_sub_msatFunction · 0.85
wallet_can_spendFunction · 0.85
tal_bytelenFunction · 0.85
channel_hasFunction · 0.70
channel_internal_errorFunction · 0.70
force_peer_disconnectFunction · 0.70
mutual_close_feerateFunction · 0.70

Tested by

no test coverage detected