Skip to content

Commit adaf33b

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 6ed1189 commit adaf33b

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

lightning/src/ln/channel.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10146,6 +10146,19 @@ where
1014610146
self.sign_channel_announcement(node_signer, announcement).ok()
1014710147
}
1014810148

10149+
fn get_next_local_commitment_number(&self) -> u64 {
10150+
if let Some(session) = &self.interactive_tx_signing_session {
10151+
if !self.context.channel_state.is_their_tx_signatures_sent()
10152+
&& !session.has_received_commitment_signed()
10153+
{
10154+
// FIXME
10155+
return unimplemented!();
10156+
}
10157+
}
10158+
10159+
INITIAL_COMMITMENT_NUMBER - self.holder_commitment_point.transaction_number()
10160+
}
10161+
1014910162
#[rustfmt::skip]
1015010163
fn maybe_get_next_funding_txid(&self) -> Option<Txid> {
1015110164
// If we've sent `commtiment_signed` for an interactively constructed transaction
@@ -10247,7 +10260,7 @@ where
1024710260

1024810261
// next_local_commitment_number is the next commitment_signed number we expect to
1024910262
// receive (indicating if they need to resend one that we missed).
10250-
next_local_commitment_number: INITIAL_COMMITMENT_NUMBER - self.holder_commitment_point.transaction_number(),
10263+
next_local_commitment_number: self.get_next_local_commitment_number(),
1025110264
// We have to set next_remote_commitment_number to the next revoke_and_ack we expect to
1025210265
// receive, however we track it by the next commitment number for a remote transaction
1025310266
// (which is one further, as they always revoke previous commitment transaction, not

0 commit comments

Comments
 (0)