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

Function send_commit

channeld/channeld.c:1449–1622  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1447}
1448
1449static void send_commit(struct peer *peer)
1450{
1451 const struct htlc **changed_htlcs;
1452 u32 our_blockheight;
1453 u32 feerate_target;
1454 u8 **msgs = tal_arr(tmpctx, u8*, 1);
1455 u8 *msg;
1456 u16 batch_size = tal_count(peer->splice_state->inflights) + 1;
1457 struct local_anchor_info *local_anchor, *anchors_info;
1458
1459 if (peer->dev_disable_commit && !*peer->dev_disable_commit) {
1460 peer->commit_timer = NULL;
1461 return;
1462 }
1463
1464 /* FIXME: Document this requirement in BOLT 2! */
1465 /* We can't send two commits in a row. */
1466 if (peer->revocations_received != peer->next_index[REMOTE] - 1) {
1467 assert(peer->revocations_received
1468 == peer->next_index[REMOTE] - 2);
1469 status_debug("Can't send commit: waiting for revoke_and_ack");
1470 /* Mark this as done: handle_peer_revoke_and_ack will
1471 * restart. */
1472 peer->commit_timer = NULL;
1473 return;
1474 }
1475
1476 /* BOLT #2:
1477 *
1478 * - if no HTLCs remain in either commitment transaction (including dust HTLCs)
1479 * and neither side has a pending `revoke_and_ack` to send:
1480 * - MUST NOT send any `update` message after that point.
1481 */
1482 if (peer->shutdown_sent[LOCAL] && !num_channel_htlcs(peer->channel)) {
1483 status_debug("Can't send commit: final shutdown phase");
1484
1485 peer->commit_timer = NULL;
1486 return;
1487 }
1488
1489 /* If we wanted to update fees, do it now. */
1490 if (want_fee_update(peer, &feerate_target)) {
1491 /* FIXME: We occasionally desynchronize with LND here, so
1492 * don't stress things by having more than one feerate change
1493 * in-flight! */
1494 if (feerate_changes_done(peer->channel->fee_states, false)) {
1495 /* BOLT-919 #2:
1496 *
1497 * A sending node:
1498 * - if the `dust_balance_on_counterparty_tx` at the
1499 * new `dust_buffer_feerate` is superior to
1500 * `max_dust_htlc_exposure_msat`:
1501 * - MAY NOT send `update_fee`
1502 * - MAY fail the channel
1503 * - if the `dust_balance_on_holder_tx` at the
1504 * new `dust_buffer_feerate` is superior to
1505 * the `max_dust_htlc_exposure_msat`:
1506 * - MAY NOT send `update_fee`

Callers 1

send_commit_if_not_stfuFunction · 0.85

Calls 15

num_channel_htlcsFunction · 0.85
want_fee_updateFunction · 0.85
feerate_changes_doneFunction · 0.85
htlc_dust_okFunction · 0.85
peer_failed_warnFunction · 0.85
channel_update_feerateFunction · 0.85
approx_max_feerateFunction · 0.85
peer_writeFunction · 0.85
want_blockheight_updateFunction · 0.85
blockheight_changes_doneFunction · 0.85
channel_sending_commitFunction · 0.85

Tested by

no test coverage detected