Skip to content

Commit 977eaaf

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 d604510 commit 977eaaf

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

lightning/src/ln/channel.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10561,6 +10561,27 @@ where
1056110561
self.sign_channel_announcement(node_signer, announcement).ok()
1056210562
}
1056310563

10564+
fn get_next_local_commitment_number(&self) -> u64 {
10565+
let next_local_commitment_number =
10566+
INITIAL_COMMITMENT_NUMBER - self.holder_commitment_point.transaction_number();
10567+
10568+
// The sending node:
10569+
// - if it has sent `commitment_signed` for an interactive transaction construction but
10570+
// it has not received `tx_signatures`:
10571+
// - MUST set `next_funding_txid` to the txid of that interactive transaction.
10572+
// - if it has not received `commitment_signed` for that interactive transaction:
10573+
// - MUST set `next_commitment_number` to the commitment number of the `commitment_signed` it sent.
10574+
if let Some(session) = &self.interactive_tx_signing_session {
10575+
if !self.context.channel_state.is_their_tx_signatures_sent()
10576+
&& !session.has_received_commitment_signed()
10577+
{
10578+
return next_local_commitment_number + 1;
10579+
}
10580+
}
10581+
10582+
next_local_commitment_number
10583+
}
10584+
1056410585
#[rustfmt::skip]
1056510586
fn maybe_get_next_funding_txid(&self) -> Option<Txid> {
1056610587
// If we've sent `commtiment_signed` for an interactively constructed transaction
@@ -10649,7 +10670,7 @@ where
1064910670

1065010671
// next_local_commitment_number is the next commitment_signed number we expect to
1065110672
// receive (indicating if they need to resend one that we missed).
10652-
next_local_commitment_number: INITIAL_COMMITMENT_NUMBER - self.holder_commitment_point.transaction_number(),
10673+
next_local_commitment_number: self.get_next_local_commitment_number(),
1065310674
// We have to set next_remote_commitment_number to the next revoke_and_ack we expect to
1065410675
// receive, however we track it by the next commitment number for a remote transaction
1065510676
// (which is one further, as they always revoke previous commitment transaction, not

0 commit comments

Comments
 (0)