Skip to content

Commit eafdd93

Browse files
vincenzopalazzodaywalker90
authored andcommitted
channeld: fail channel on zero next_commitment_number
The existing BOLT #2 quote already required this, but the first bullet was unimplemented: the only zero check sat under next_commitment_number == next_index[REMOTE] - 1, after the stale-revocation warning. Implement that bullet next to the quote, and drop the nested copy. Fixes: #9425 Changelog-Fixed: Protocol: immediately fail the channel if channel_reestablish next_commitment_number is zero. Reported-by: Leo Nash (@tankyleo) Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
1 parent cea73b8 commit eafdd93

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

‎channeld/channeld.c‎

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5990,6 +5990,11 @@ static void peer_reconnect(struct peer *peer,
59905990
* - MUST NOT retransmit `channel_ready`, but MAY send `channel_ready` with
59915991
* a different `short_channel_id` `alias` field.
59925992
*/
5993+
if (next_commitment_number == 0)
5994+
peer_failed_err(peer->pps,
5995+
&peer->channel_id,
5996+
"bad reestablish commitment_number: %"PRIu64,
5997+
next_commitment_number);
59935998

59945999
if (peer->channel_ready[LOCAL]
59956000
&& peer->next_index[LOCAL] == 1
@@ -6102,14 +6107,6 @@ static void peer_reconnect(struct peer *peer,
61026107
* `commitment_signed`.
61036108
*/
61046109
if (next_commitment_number == peer->next_index[REMOTE] - 1) {
6105-
/* We completed opening, we don't re-transmit that one! */
6106-
if (next_commitment_number == 0)
6107-
peer_failed_err(peer->pps,
6108-
&peer->channel_id,
6109-
"bad reestablish commitment_number: %"
6110-
PRIu64,
6111-
next_commitment_number);
6112-
61136110
if (!recv_tlvs || !recv_tlvs->next_funding)
61146111
retransmit_commitment_signed = true;
61156112
else

0 commit comments

Comments
 (0)