Skip to content

Commit 1200482

Browse files
committed
Update next_commitment_number logic for channel_reestablish
The splicing spec updates the logic pertaining to next_commitment_number when sending a channel_reestablish message. Specifically: The sending node: - if it has sent `commitment_signed` for an interactive transaction construction but it has not received `tx_signatures`: - MUST set `next_funding_txid` to the txid of that interactive transaction. - if it has not received `commitment_signed` for that interactive transaction: - MUST set `next_commitment_number` to the commitment number of the `commitment_signed` it sent.
1 parent 476482a commit 1200482

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

lightning/src/ln/channel.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10572,6 +10572,21 @@ where
1057210572
self.sign_channel_announcement(node_signer, announcement).ok()
1057310573
}
1057410574

10575+
fn get_next_local_commitment_number(&self) -> u64 {
10576+
let next_local_commitment_number =
10577+
INITIAL_COMMITMENT_NUMBER - self.holder_commitment_point.transaction_number();
10578+
10579+
if let Some(session) = &self.interactive_tx_signing_session {
10580+
if !self.context.channel_state.is_their_tx_signatures_sent()
10581+
&& !session.has_received_commitment_signed()
10582+
{
10583+
return next_local_commitment_number + 1;
10584+
}
10585+
}
10586+
10587+
next_local_commitment_number
10588+
}
10589+
1057510590
#[rustfmt::skip]
1057610591
fn maybe_get_next_funding_txid(&self) -> Option<Txid> {
1057710592
// If we've sent `commtiment_signed` for an interactively constructed transaction
@@ -10660,7 +10675,7 @@ where
1066010675

1066110676
// next_local_commitment_number is the next commitment_signed number we expect to
1066210677
// receive (indicating if they need to resend one that we missed).
10663-
next_local_commitment_number: INITIAL_COMMITMENT_NUMBER - self.holder_commitment_point.transaction_number(),
10678+
next_local_commitment_number: self.get_next_local_commitment_number(),
1066410679
// We have to set next_remote_commitment_number to the next revoke_and_ack we expect to
1066510680
// receive, however we track it by the next commitment number for a remote transaction
1066610681
// (which is one further, as they always revoke previous commitment transaction, not

0 commit comments

Comments
 (0)