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

Function peer_start_closingd

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

Source from the content-addressed store, hash-verified

350}
351
352void peer_start_closingd(struct channel *channel, struct peer_fd *peer_fd)
353{
354 u8 *initmsg;
355 u32 min_feerate, feerate, *max_feerate;
356 struct amount_msat their_msat;
357 struct amount_sat feelimit;
358 int hsmfd;
359 struct lightningd *ld = channel->peer->ld;
360 u32 final_commit_feerate;
361 bool option_anchor_outputs = channel_has(channel, OPT_ANCHOR_OUTPUTS);
362
363 if (!channel->shutdown_scriptpubkey[REMOTE]) {
364 channel_internal_error(channel,
365 "Can't start closing: no remote info");
366 return;
367 }
368
369 hsmfd = hsm_get_client_fd(ld, &channel->peer->id, channel->dbid,
370 HSM_CAP_SIGN_CLOSING_TX
371 | HSM_CAP_COMMITMENT_POINT);
372
373 channel_set_owner(channel,
374 new_channel_subd(channel, ld,
375 "lightning_closingd",
376 channel, &channel->peer->id,
377 channel->log, true,
378 closingd_wire_name, closing_msg,
379 channel_errmsg,
380 channel_set_billboard,
381 take(&peer_fd->fd),
382 take(&hsmfd),
383 NULL));
384
385 if (!channel->owner) {
386 log_broken(channel->log, "Could not subdaemon closing: %s",
387 strerror(errno));
388 /* Disconnect it. */
389 subd_send_msg(ld->connectd,
390 take(towire_connectd_discard_peer(NULL, &channel->peer->id,
391 channel->peer->connectd_counter)));
392 return;
393 }
394
395 /* FIXME: This is the old BOLT 2 text, which restricted the closing
396 * fee to cap at the final commitment fee. We still do this for now.
397 *
398 * The sending node:
399 * - MUST set `fee_satoshis` less than or equal to the base
400 * fee of the final commitment transaction, as calculated in
401 * [BOLT #3](03-transactions.md#fee-calculation).
402 */
403 final_commit_feerate = get_feerate(channel->fee_states,
404 channel->opener, LOCAL);
405 feelimit = commit_tx_base_fee(final_commit_feerate, 0,
406 option_anchor_outputs);
407
408 /* If we can't determine feerate, start at half unilateral feerate. */
409 feerate = mutual_close_feerate(ld->topology);

Callers 2

handle_channel_closedFunction · 0.85

Calls 15

hsm_get_client_fdFunction · 0.85
channel_set_ownerFunction · 0.85
commit_tx_base_feeFunction · 0.85
mutual_close_feerateFunction · 0.85
feerate_floorFunction · 0.85
unilateral_feerateFunction · 0.85
feerate_minFunction · 0.85
amount_sat_sub_msatFunction · 0.85
wallet_can_spendFunction · 0.85
channel_hasFunction · 0.70
channel_internal_errorFunction · 0.70

Tested by

no test coverage detected