Skip to content

Commit e083a2d

Browse files
committed
Document some channel_reestablish spec requirements
1 parent 9c2ead2 commit e083a2d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lightning/src/ln/channel.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9380,6 +9380,10 @@ where
93809380
return Err(ChannelError::close("Peer sent a loose channel_reestablish not after reconnect".to_owned()));
93819381
}
93829382

9383+
// A node:
9384+
// - if `next_commitment_number` is zero:
9385+
// - MUST immediately fail the channel and broadcast any relevant latest commitment
9386+
// transaction.
93839387
if msg.next_local_commitment_number == 0
93849388
|| msg.next_local_commitment_number >= INITIAL_COMMITMENT_NUMBER
93859389
|| msg.next_remote_commitment_number >= INITIAL_COMMITMENT_NUMBER
@@ -9610,6 +9614,13 @@ where
96109614
let is_awaiting_remote_revoke = self.context.channel_state.is_awaiting_remote_revoke();
96119615
let next_counterparty_commitment_number = INITIAL_COMMITMENT_NUMBER - self.context.counterparty_next_commitment_transaction_number + if is_awaiting_remote_revoke { 1 } else { 0 };
96129616

9617+
// A node:
9618+
// - if `next_commitment_number` is 1 in both the `channel_reestablish` it
9619+
// sent and received:
9620+
// - MUST retransmit `channel_ready`.
9621+
// - otherwise:
9622+
// - MUST NOT retransmit `channel_ready`, but MAY send `channel_ready` with
9623+
// a different `short_channel_id` `alias` field.
96139624
let channel_ready = if msg.next_local_commitment_number == 1 && INITIAL_COMMITMENT_NUMBER - self.holder_commitment_point.next_transaction_number() == 1 {
96149625
// We should never have to worry about MonitorUpdateInProgress resending ChannelReady
96159626
self.get_channel_ready(logger)

0 commit comments

Comments
 (0)