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