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

Function peer_start_closingd

lightningd/closing_control.c:355–506  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

353}
354
355void peer_start_closingd(struct channel *channel, struct peer_fd *peer_fd)
356{
357 u8 *initmsg;
358 u32 min_feerate, feerate, max_feerate;
359 struct amount_msat their_msat;
360 int hsmfd;
361 struct lightningd *ld = channel->peer->ld;
362 u32 final_commit_feerate;
363 bool option_anchor_outputs = channel_has(channel, OPT_ANCHOR_OUTPUTS_DEPRECATED);
364 bool option_anchors_zero_fee_htlc_tx = channel_has(channel, OPT_ANCHORS_ZERO_FEE_HTLC_TX);
365
366 if (!channel->shutdown_scriptpubkey[REMOTE]) {
367 channel_internal_error(channel,
368 "Can't start closing: no remote info");
369 return;
370 }
371
372 hsmfd = hsm_get_client_fd(ld, &channel->peer->id, channel->dbid,
373 HSM_PERM_SIGN_CLOSING_TX
374 | HSM_PERM_COMMITMENT_POINT);
375 if (hsmfd < 0) {
376 log_broken(channel->log, "Could not get hsm fd for closing: %s",
377 strerror(errno));
378 force_peer_disconnect(ld, channel->peer,
379 "Failed to get hsm fd for closingd");
380 return;
381 }
382
383 channel_set_owner(channel,
384 new_channel_subd(channel, ld,
385 "lightning_closingd",
386 channel, &channel->peer->id,
387 channel->log, true,
388 closingd_wire_name, closing_msg,
389 channel_errmsg,
390 channel_set_billboard,
391 take(&peer_fd->fd),
392 take(&hsmfd),
393 NULL));
394
395 if (!channel->owner) {
396 log_broken(channel->log, "Could not subdaemon closing: %s",
397 strerror(errno));
398 /* Disconnect it. */
399 force_peer_disconnect(ld, channel->peer,
400 "Failed to create closingd");
401 return;
402 }
403
404 /* BOLT #2:
405 * The sending node:
406 * - SHOULD set the initial `fee_satoshis` according to its estimate of cost of
407 * inclusion in a block.
408 * - SHOULD set `fee_range` according to the minimum and maximum fees it is
409 * prepared to pay for a close transaction.
410 */
411 final_commit_feerate = get_feerate(channel->fee_states,
412 channel->opener, LOCAL);

Callers 2

handle_channel_closedFunction · 0.85

Calls 15

hsm_get_client_fdFunction · 0.85
channel_set_ownerFunction · 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
get_feerate_floorFunction · 0.70

Tested by

no test coverage detected