| 1365 | } |
| 1366 | |
| 1367 | static void send_commit(struct peer *peer) |
| 1368 | { |
| 1369 | const struct htlc **changed_htlcs; |
| 1370 | u32 our_blockheight; |
| 1371 | u32 feerate_target; |
| 1372 | u8 **msgs = tal_arr(tmpctx, u8*, 1); |
| 1373 | u8 *msg; |
| 1374 | u16 batch_size = tal_count(peer->splice_state->inflights) + 1; |
| 1375 | struct local_anchor_info *local_anchor, *anchors_info; |
| 1376 | |
| 1377 | if (peer->dev_disable_commit && !*peer->dev_disable_commit) { |
| 1378 | peer->commit_timer = NULL; |
| 1379 | return; |
| 1380 | } |
| 1381 | |
| 1382 | /* FIXME: Document this requirement in BOLT 2! */ |
| 1383 | /* We can't send two commits in a row. */ |
| 1384 | if (peer->revocations_received != peer->next_index[REMOTE] - 1) { |
| 1385 | assert(peer->revocations_received |
| 1386 | == peer->next_index[REMOTE] - 2); |
| 1387 | status_debug("Can't send commit: waiting for revoke_and_ack"); |
| 1388 | /* Mark this as done: handle_peer_revoke_and_ack will |
| 1389 | * restart. */ |
| 1390 | peer->commit_timer = NULL; |
| 1391 | return; |
| 1392 | } |
| 1393 | |
| 1394 | /* BOLT #2: |
| 1395 | * |
| 1396 | * - if no HTLCs remain in either commitment transaction (including dust HTLCs) |
| 1397 | * and neither side has a pending `revoke_and_ack` to send: |
| 1398 | * - MUST NOT send any `update` message after that point. |
| 1399 | */ |
| 1400 | if (peer->shutdown_sent[LOCAL] && !num_channel_htlcs(peer->channel)) { |
| 1401 | status_debug("Can't send commit: final shutdown phase"); |
| 1402 | |
| 1403 | peer->commit_timer = NULL; |
| 1404 | return; |
| 1405 | } |
| 1406 | |
| 1407 | /* If we wanted to update fees, do it now. */ |
| 1408 | if (want_fee_update(peer, &feerate_target)) { |
| 1409 | /* FIXME: We occasionally desynchronize with LND here, so |
| 1410 | * don't stress things by having more than one feerate change |
| 1411 | * in-flight! */ |
| 1412 | if (feerate_changes_done(peer->channel->fee_states, false)) { |
| 1413 | /* BOLT-919 #2: |
| 1414 | * |
| 1415 | * A sending node: |
| 1416 | * - if the `dust_balance_on_counterparty_tx` at the |
| 1417 | * new `dust_buffer_feerate` is superior to |
| 1418 | * `max_dust_htlc_exposure_msat`: |
| 1419 | * - MAY NOT send `update_fee` |
| 1420 | * - MAY fail the channel |
| 1421 | * - if the `dust_balance_on_holder_tx` at the |
| 1422 | * new `dust_buffer_feerate` is superior to |
| 1423 | * the `max_dust_htlc_exposure_msat`: |
| 1424 | * - MAY NOT send `update_fee` |
no test coverage detected