Skip to content

Commit 02ec193

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 5e3d8c1 commit 02ec193

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
@@ -10140,6 +10140,21 @@ where
1014010140
self.sign_channel_announcement(node_signer, announcement).ok()
1014110141
}
1014210142

10143+
fn get_next_local_commitment_number(&self) -> u64 {
10144+
let next_local_commitment_number =
10145+
INITIAL_COMMITMENT_NUMBER - self.holder_commitment_point.transaction_number();
10146+
10147+
if let Some(session) = &self.interactive_tx_signing_session {
10148+
if !self.context.channel_state.is_their_tx_signatures_sent()
10149+
&& !session.has_received_commitment_signed()
10150+
{
10151+
return next_local_commitment_number + 1;
10152+
}
10153+
}
10154+
10155+
next_local_commitment_number
10156+
}
10157+
1014310158
#[rustfmt::skip]
1014410159
fn maybe_get_next_funding_txid(&self) -> Option<Txid> {
1014510160
// If we've sent `commtiment_signed` for an interactively constructed transaction
@@ -10241,7 +10256,7 @@ where
1024110256

1024210257
// next_local_commitment_number is the next commitment_signed number we expect to
1024310258
// receive (indicating if they need to resend one that we missed).
10244-
next_local_commitment_number: INITIAL_COMMITMENT_NUMBER - self.holder_commitment_point.transaction_number(),
10259+
next_local_commitment_number: self.get_next_local_commitment_number(),
1024510260
// We have to set next_remote_commitment_number to the next revoke_and_ack we expect to
1024610261
// receive, however we track it by the next commitment number for a remote transaction
1024710262
// (which is one further, as they always revoke previous commitment transaction, not

0 commit comments

Comments
 (0)