@@ -1265,6 +1265,7 @@ pub(super) struct ReestablishResponses {
12651265 pub shutdown_msg: Option<msgs::Shutdown>,
12661266 pub tx_signatures: Option<msgs::TxSignatures>,
12671267 pub tx_abort: Option<msgs::TxAbort>,
1268+ pub splice_locked: Option<msgs::SpliceLocked>,
12681269 pub inferred_splice_locked: Option<msgs::SpliceLocked>,
12691270}
12701271
@@ -3503,6 +3504,12 @@ pub(super) struct ChannelContext<SP: SignerProvider> {
35033504 /// See-also <https://github.com/lightningnetwork/lnd/issues/4006>
35043505 pub workaround_lnd_bug_4006: Option<msgs::ChannelReady>,
35053506
3507+ /// The `my_current_funding_locked` txid included in our `channel_reestablish` for the current
3508+ /// reconnect, if any. We track this as we cannot tell what was included after we've already
3509+ /// sent it, as it's possible it was unconfirmed at the time we sent it, but confirmed shortly
3510+ /// after.
3511+ funding_locked_txid_sent_in_reestablish: Option<Txid>,
3512+
35063513 /// An option set when we wish to track how many ticks have elapsed while waiting for a response
35073514 /// from our counterparty after entering specific states. If the peer has yet to respond after
35083515 /// reaching `DISCONNECT_PEER_AWAITING_RESPONSE_TICKS`, a reconnection should be attempted to
@@ -4225,6 +4232,7 @@ impl<SP: SignerProvider> ChannelContext<SP> {
42254232 announcement_sigs: None,
42264233
42274234 workaround_lnd_bug_4006: None,
4235+ funding_locked_txid_sent_in_reestablish: None,
42284236 sent_message_awaiting_response: None,
42294237
42304238 latest_inbound_scid_alias: None,
@@ -4536,6 +4544,7 @@ impl<SP: SignerProvider> ChannelContext<SP> {
45364544 announcement_sigs: None,
45374545
45384546 workaround_lnd_bug_4006: None,
4547+ funding_locked_txid_sent_in_reestablish: None,
45394548 sent_message_awaiting_response: None,
45404549
45414550 latest_inbound_scid_alias: None,
@@ -10512,6 +10521,8 @@ where
1051210521 // remaining cases either succeed or ErrorMessage-fail).
1051310522 self.context.channel_state.clear_peer_disconnected();
1051410523 self.mark_response_received();
10524+ let funding_locked_txid_sent_in_reestablish =
10525+ self.context.funding_locked_txid_sent_in_reestablish.take();
1051510526
1051610527 let shutdown_msg = self.get_outbound_shutdown();
1051710528
@@ -10663,6 +10674,7 @@ where
1066310674 shutdown_msg, announcement_sigs,
1066410675 tx_signatures,
1066510676 tx_abort: None,
10677+ splice_locked: None,
1066610678 inferred_splice_locked: None,
1066710679 });
1066810680 }
@@ -10676,6 +10688,7 @@ where
1067610688 shutdown_msg, announcement_sigs,
1067710689 tx_signatures,
1067810690 tx_abort,
10691+ splice_locked: None,
1067910692 inferred_splice_locked: None,
1068010693 });
1068110694 }
@@ -10745,6 +10758,15 @@ where
1074510758 splice_txid,
1074610759 })
1074710760 });
10761+ let splice_locked = self.pending_splice.as_ref().and_then(|pending_splice| {
10762+ pending_splice
10763+ .sent_funding_txid
10764+ .filter(|splice_txid| Some(*splice_txid) != funding_locked_txid_sent_in_reestablish)
10765+ .map(|splice_txid| msgs::SpliceLocked {
10766+ channel_id: self.context.channel_id,
10767+ splice_txid,
10768+ })
10769+ });
1074810770
1074910771 if msg.next_local_commitment_number == next_counterparty_commitment_number {
1075010772 if required_revoke.is_some() || self.context.signer_pending_revoke_and_ack {
@@ -10763,6 +10785,7 @@ where
1076310785 commitment_order: self.context.resend_order.clone(),
1076410786 tx_signatures,
1076510787 tx_abort,
10788+ splice_locked,
1076610789 inferred_splice_locked,
1076710790 })
1076810791 } else if msg.next_local_commitment_number == next_counterparty_commitment_number - 1 {
@@ -10788,6 +10811,7 @@ where
1078810811 commitment_order: self.context.resend_order.clone(),
1078910812 tx_signatures: None,
1079010813 tx_abort,
10814+ splice_locked,
1079110815 inferred_splice_locked,
1079210816 })
1079310817 } else {
@@ -10815,6 +10839,7 @@ where
1081510839 commitment_order: self.context.resend_order.clone(),
1081610840 tx_signatures: None,
1081710841 tx_abort,
10842+ splice_locked,
1081810843 inferred_splice_locked,
1081910844 })
1082010845 }
@@ -12492,6 +12517,9 @@ where
1249212517 log_info!(logger, "Sending a data_loss_protect with no previous remote per_commitment_secret for channel {}", &self.context.channel_id());
1249312518 [0;32]
1249412519 };
12520+ let my_current_funding_locked = self.maybe_get_my_current_funding_locked();
12521+ self.context.funding_locked_txid_sent_in_reestablish =
12522+ my_current_funding_locked.as_ref().map(|funding_locked| funding_locked.txid);
1249512523 msgs::ChannelReestablish {
1249612524 channel_id: self.context.channel_id(),
1249712525 // The protocol has two different commitment number concepts - the "commitment
@@ -12515,7 +12543,7 @@ where
1251512543 your_last_per_commitment_secret: remote_last_secret,
1251612544 my_current_per_commitment_point: dummy_pubkey,
1251712545 next_funding: self.maybe_get_next_funding(),
12518- my_current_funding_locked: self.maybe_get_my_current_funding_locked() ,
12546+ my_current_funding_locked,
1251912547 }
1252012548 }
1252112549
@@ -17196,6 +17224,7 @@ impl<'a, 'b, 'c, ES: EntropySource, SP: SignerProvider>
1719617224 announcement_sigs,
1719717225
1719817226 workaround_lnd_bug_4006: None,
17227+ funding_locked_txid_sent_in_reestablish: None,
1719917228 sent_message_awaiting_response: None,
1720017229
1720117230 latest_inbound_scid_alias,
0 commit comments