Skip to content

Commit 19b0d1b

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 770640f commit 19b0d1b

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

lightning/src/ln/channel.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10506,6 +10506,25 @@ where
1050610506
self.sign_channel_announcement(node_signer, announcement).ok()
1050710507
}
1050810508

10509+
fn get_next_local_commitment_number(&self) -> u64 {
10510+
// The sending node:
10511+
// - if it has sent `commitment_signed` for an interactive transaction construction but
10512+
// it has not received `tx_signatures`:
10513+
// - MUST set `next_funding_txid` to the txid of that interactive transaction.
10514+
// - if it has not received `commitment_signed` for that interactive transaction:
10515+
// - MUST set `next_commitment_number` to the commitment number of the `commitment_signed` it sent.
10516+
if let Some(session) = &self.interactive_tx_signing_session {
10517+
if !self.context.channel_state.is_their_tx_signatures_sent()
10518+
&& !session.has_received_commitment_signed()
10519+
{
10520+
return INITIAL_COMMITMENT_NUMBER
10521+
- self.holder_commitment_point.current_transaction_number();
10522+
}
10523+
}
10524+
10525+
INITIAL_COMMITMENT_NUMBER - self.holder_commitment_point.next_transaction_number()
10526+
}
10527+
1050910528
#[rustfmt::skip]
1051010529
fn maybe_get_next_funding_txid(&self) -> Option<Txid> {
1051110530
// If we've sent `commtiment_signed` for an interactively constructed transaction
@@ -10581,7 +10600,7 @@ where
1058110600

1058210601
// next_local_commitment_number is the next commitment_signed number we expect to
1058310602
// receive (indicating if they need to resend one that we missed).
10584-
next_local_commitment_number: INITIAL_COMMITMENT_NUMBER - self.holder_commitment_point.next_transaction_number(),
10603+
next_local_commitment_number: self.get_next_local_commitment_number(),
1058510604
// We have to set next_remote_commitment_number to the next revoke_and_ack we expect to
1058610605
// receive, however we track it by the next commitment number for a remote transaction
1058710606
// (which is one further, as they always revoke previous commitment transaction, not

0 commit comments

Comments
 (0)