Skip to content

Commit 80f952e

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 a288ff4 commit 80f952e

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
@@ -9737,6 +9737,19 @@ where
97379737
self.sign_channel_announcement(node_signer, announcement).ok()
97389738
}
97399739

9740+
fn get_next_local_commitment_number(&self) -> u64 {
9741+
if let Some(session) = &self.interactive_tx_signing_session {
9742+
if !self.context.channel_state.is_their_tx_signatures_sent()
9743+
&& !session.has_received_commitment_signed()
9744+
{
9745+
// FIXME
9746+
return unimplemented!();
9747+
}
9748+
}
9749+
9750+
INITIAL_COMMITMENT_NUMBER - self.holder_commitment_point.transaction_number()
9751+
}
9752+
97409753
#[rustfmt::skip]
97419754
fn maybe_get_next_funding_txid(&self) -> Option<Txid> {
97429755
// If we've sent `commtiment_signed` for an interactively constructed transaction
@@ -9827,7 +9840,7 @@ where
98279840

98289841
// next_local_commitment_number is the next commitment_signed number we expect to
98299842
// receive (indicating if they need to resend one that we missed).
9830-
next_local_commitment_number: INITIAL_COMMITMENT_NUMBER - self.holder_commitment_point.transaction_number(),
9843+
next_local_commitment_number: self.get_next_local_commitment_number(),
98319844
// We have to set next_remote_commitment_number to the next revoke_and_ack we expect to
98329845
// receive, however we track it by the next commitment number for a remote transaction
98339846
// (which is one further, as they always revoke previous commitment transaction, not

0 commit comments

Comments
 (0)