@@ -1662,12 +1662,12 @@ where
1662
1662
/// send our peer to begin the channel reconnection process.
1663
1663
#[rustfmt::skip]
1664
1664
pub fn peer_connected_get_handshake<L: Deref>(
1665
- &mut self, chain_hash: ChainHash, logger: &L,
1665
+ &mut self, chain_hash: ChainHash, features: &InitFeatures, logger: &L,
1666
1666
) -> ReconnectionMsg where L::Target: Logger {
1667
1667
match &mut self.phase {
1668
1668
ChannelPhase::Undefined => unreachable!(),
1669
1669
ChannelPhase::Funded(chan) =>
1670
- ReconnectionMsg::Reestablish(chan.get_channel_reestablish(logger)),
1670
+ ReconnectionMsg::Reestablish(chan.get_channel_reestablish(features, logger)),
1671
1671
ChannelPhase::UnfundedOutboundV1(chan) => {
1672
1672
chan.get_open_channel(chain_hash, logger)
1673
1673
.map(|msg| ReconnectionMsg::Open(OpenChannelMessage::V1(msg)))
@@ -9403,6 +9403,12 @@ where
9403
9403
false
9404
9404
}
9405
9405
9406
+ /// Returns true if thier channel_ready has been received
9407
+ pub fn is_their_channel_ready(&self) -> bool {
9408
+ matches!(self.context.channel_state, ChannelState::AwaitingChannelReady(flags) if flags.is_set(AwaitingChannelReadyFlags::THEIR_CHANNEL_READY))
9409
+ || matches!(self.context.channel_state, ChannelState::ChannelReady(_))
9410
+ }
9411
+
9406
9412
/// Returns true if our channel_ready has been sent
9407
9413
pub fn is_our_channel_ready(&self) -> bool {
9408
9414
matches!(self.context.channel_state, ChannelState::AwaitingChannelReady(flags) if flags.is_set(AwaitingChannelReadyFlags::OUR_CHANNEL_READY))
@@ -10150,10 +10156,41 @@ where
10150
10156
}
10151
10157
}
10152
10158
10159
+ fn maybe_get_your_last_funding_locked_txid(&self, features: &InitFeatures) -> Option<Txid> {
10160
+ if !features.supports_splicing() {
10161
+ return None;
10162
+ }
10163
+
10164
+ self.pending_splice
10165
+ .as_ref()
10166
+ .and_then(|pending_splice| pending_splice.received_funding_txid)
10167
+ .or_else(|| {
10168
+ self.is_their_channel_ready().then(|| self.funding.get_funding_txid()).flatten()
10169
+ })
10170
+ }
10171
+
10172
+ fn maybe_get_my_current_funding_locked_txid(&self, features: &InitFeatures) -> Option<Txid> {
10173
+ if !features.supports_splicing() {
10174
+ return None;
10175
+ }
10176
+
10177
+ self.pending_splice
10178
+ .as_ref()
10179
+ .and_then(|pending_splice| pending_splice.sent_funding_txid)
10180
+ .or_else(|| {
10181
+ self.is_our_channel_ready().then(|| self.funding.get_funding_txid()).flatten()
10182
+ })
10183
+ }
10184
+
10153
10185
/// May panic if called on a channel that wasn't immediately-previously
10154
10186
/// self.remove_uncommitted_htlcs_and_mark_paused()'d
10155
10187
#[rustfmt::skip]
10156
- fn get_channel_reestablish<L: Deref>(&mut self, logger: &L) -> msgs::ChannelReestablish where L::Target: Logger {
10188
+ fn get_channel_reestablish<L: Deref>(
10189
+ &mut self, features: &InitFeatures, logger: &L,
10190
+ ) -> msgs::ChannelReestablish
10191
+ where
10192
+ L::Target: Logger,
10193
+ {
10157
10194
assert!(self.context.channel_state.is_peer_disconnected());
10158
10195
assert_ne!(self.context.cur_counterparty_commitment_transaction_number, INITIAL_COMMITMENT_NUMBER);
10159
10196
// This is generally the first function which gets called on any given channel once we're
@@ -10201,8 +10238,8 @@ where
10201
10238
your_last_per_commitment_secret: remote_last_secret,
10202
10239
my_current_per_commitment_point: dummy_pubkey,
10203
10240
next_funding_txid: self.maybe_get_next_funding_txid(),
10204
- your_last_funding_locked_txid: None ,
10205
- my_current_funding_locked_txid: None ,
10241
+ your_last_funding_locked_txid: self.maybe_get_your_last_funding_locked_txid(features) ,
10242
+ my_current_funding_locked_txid: self.maybe_get_my_current_funding_locked_txid(features) ,
10206
10243
}
10207
10244
}
10208
10245
@@ -13690,15 +13727,15 @@ mod tests {
13690
13727
// Now disconnect the two nodes and check that the commitment point in
13691
13728
// Node B's channel_reestablish message is sane.
13692
13729
assert!(node_b_chan.remove_uncommitted_htlcs_and_mark_paused(&&logger).is_ok());
13693
- let msg = node_b_chan.get_channel_reestablish(&&logger);
13730
+ let msg = node_b_chan.get_channel_reestablish(&channelmanager::provided_init_features(&config), & &logger);
13694
13731
assert_eq!(msg.next_local_commitment_number, 1); // now called next_commitment_number
13695
13732
assert_eq!(msg.next_remote_commitment_number, 0); // now called next_revocation_number
13696
13733
assert_eq!(msg.your_last_per_commitment_secret, [0; 32]);
13697
13734
13698
13735
// Check that the commitment point in Node A's channel_reestablish message
13699
13736
// is sane.
13700
13737
assert!(node_a_chan.remove_uncommitted_htlcs_and_mark_paused(&&logger).is_ok());
13701
- let msg = node_a_chan.get_channel_reestablish(&&logger);
13738
+ let msg = node_a_chan.get_channel_reestablish(&channelmanager::provided_init_features(&config), & &logger);
13702
13739
assert_eq!(msg.next_local_commitment_number, 1); // now called next_commitment_number
13703
13740
assert_eq!(msg.next_remote_commitment_number, 0); // now called next_revocation_number
13704
13741
assert_eq!(msg.your_last_per_commitment_secret, [0; 32]);
0 commit comments