Skip to content

Commit 087de21

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 b47b0d2 commit 087de21

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
@@ -10167,6 +10167,19 @@ where
1016710167
self.sign_channel_announcement(node_signer, announcement).ok()
1016810168
}
1016910169

10170+
fn get_next_local_commitment_number(&self) -> u64 {
10171+
if let Some(session) = &self.interactive_tx_signing_session {
10172+
if !self.context.channel_state.is_their_tx_signatures_sent()
10173+
&& !session.has_received_commitment_signed()
10174+
{
10175+
// FIXME
10176+
return unimplemented!();
10177+
}
10178+
}
10179+
10180+
INITIAL_COMMITMENT_NUMBER - self.holder_commitment_point.transaction_number()
10181+
}
10182+
1017010183
#[rustfmt::skip]
1017110184
fn maybe_get_next_funding_txid(&self) -> Option<Txid> {
1017210185
// If we've sent `commtiment_signed` for an interactively constructed transaction
@@ -10257,7 +10270,7 @@ where
1025710270

1025810271
// next_local_commitment_number is the next commitment_signed number we expect to
1025910272
// receive (indicating if they need to resend one that we missed).
10260-
next_local_commitment_number: INITIAL_COMMITMENT_NUMBER - self.holder_commitment_point.transaction_number(),
10273+
next_local_commitment_number: self.get_next_local_commitment_number(),
1026110274
// We have to set next_remote_commitment_number to the next revoke_and_ack we expect to
1026210275
// receive, however we track it by the next commitment number for a remote transaction
1026310276
// (which is one further, as they always revoke previous commitment transaction, not

0 commit comments

Comments
 (0)