Skip to content

Commit feffea4

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 5619b37 commit feffea4

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

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

1023010245
// next_local_commitment_number is the next commitment_signed number we expect to
1023110246
// receive (indicating if they need to resend one that we missed).
10232-
next_local_commitment_number: INITIAL_COMMITMENT_NUMBER - self.holder_commitment_point.transaction_number(),
10247+
next_local_commitment_number: self.get_next_local_commitment_number(),
1023310248
// We have to set next_remote_commitment_number to the next revoke_and_ack we expect to
1023410249
// receive, however we track it by the next commitment number for a remote transaction
1023510250
// (which is one further, as they always revoke previous commitment transaction, not

0 commit comments

Comments
 (0)