@@ -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,13 @@ where
9403
9403
false
9404
9404
}
9405
9405
9406
+ /// Returns true if thier channel_ready has been received
9407
+ #[cfg(splicing)]
9408
+ pub fn is_their_channel_ready(&self) -> bool {
9409
+ matches!(self.context.channel_state, ChannelState::AwaitingChannelReady(flags) if flags.is_set(AwaitingChannelReadyFlags::THEIR_CHANNEL_READY))
9410
+ || matches!(self.context.channel_state, ChannelState::ChannelReady(_))
9411
+ }
9412
+
9406
9413
/// Returns true if our channel_ready has been sent
9407
9414
pub fn is_our_channel_ready(&self) -> bool {
9408
9415
matches!(self.context.channel_state, ChannelState::AwaitingChannelReady(flags) if flags.is_set(AwaitingChannelReadyFlags::OUR_CHANNEL_READY))
@@ -10150,10 +10157,52 @@ where
10150
10157
}
10151
10158
}
10152
10159
10160
+ #[cfg(splicing)]
10161
+ fn maybe_get_your_last_funding_locked_txid(&self, features: &InitFeatures) -> Option<Txid> {
10162
+ if !features.supports_splicing() {
10163
+ return None;
10164
+ }
10165
+
10166
+ self.pending_splice
10167
+ .as_ref()
10168
+ .and_then(|pending_splice| pending_splice.received_funding_txid)
10169
+ .or_else(|| {
10170
+ self.is_their_channel_ready().then(|| self.funding.get_funding_txid()).flatten()
10171
+ })
10172
+ }
10173
+ #[cfg(not(splicing))]
10174
+ fn maybe_get_your_last_funding_locked_txid(&self, _features: &InitFeatures) -> Option<Txid> {
10175
+ None
10176
+ }
10177
+
10178
+ #[cfg(splicing)]
10179
+ fn maybe_get_my_current_funding_locked_txid(&self, features: &InitFeatures) -> Option<Txid> {
10180
+ if !features.supports_splicing() {
10181
+ return None;
10182
+ }
10183
+
10184
+ self.pending_splice
10185
+ .as_ref()
10186
+ .and_then(|pending_splice| pending_splice.sent_funding_txid)
10187
+ .or_else(|| {
10188
+ self.is_our_channel_ready().then(|| self.funding.get_funding_txid()).flatten()
10189
+ })
10190
+ }
10191
+
10192
+ #[cfg(not(splicing))]
10193
+ fn maybe_get_my_current_funding_locked_txid(&self, _features: &InitFeatures) -> Option<Txid> {
10194
+ None
10195
+ }
10196
+
10153
10197
/// May panic if called on a channel that wasn't immediately-previously
10154
10198
/// self.remove_uncommitted_htlcs_and_mark_paused()'d
10155
10199
#[rustfmt::skip]
10156
- fn get_channel_reestablish<L: Deref>(&mut self, logger: &L) -> msgs::ChannelReestablish where L::Target: Logger {
10200
+ fn get_channel_reestablish<L: Deref>(
10201
+ &mut self, features: &InitFeatures, logger: &L,
10202
+ ) -> msgs::ChannelReestablish
10203
+ where
10204
+ L::Target: Logger,
10205
+ {
10157
10206
assert!(self.context.channel_state.is_peer_disconnected());
10158
10207
assert_ne!(self.context.cur_counterparty_commitment_transaction_number, INITIAL_COMMITMENT_NUMBER);
10159
10208
// This is generally the first function which gets called on any given channel once we're
@@ -10201,8 +10250,8 @@ where
10201
10250
your_last_per_commitment_secret: remote_last_secret,
10202
10251
my_current_per_commitment_point: dummy_pubkey,
10203
10252
next_funding_txid: self.maybe_get_next_funding_txid(),
10204
- your_last_funding_locked_txid: None ,
10205
- my_current_funding_locked_txid: None ,
10253
+ your_last_funding_locked_txid: self.maybe_get_your_last_funding_locked_txid(features) ,
10254
+ my_current_funding_locked_txid: self.maybe_get_my_current_funding_locked_txid(features) ,
10206
10255
}
10207
10256
}
10208
10257
@@ -13690,15 +13739,15 @@ mod tests {
13690
13739
// Now disconnect the two nodes and check that the commitment point in
13691
13740
// Node B's channel_reestablish message is sane.
13692
13741
assert!(node_b_chan.remove_uncommitted_htlcs_and_mark_paused(&&logger).is_ok());
13693
- let msg = node_b_chan.get_channel_reestablish(&&logger);
13742
+ let msg = node_b_chan.get_channel_reestablish(&channelmanager::provided_init_features(&config), & &logger);
13694
13743
assert_eq!(msg.next_local_commitment_number, 1); // now called next_commitment_number
13695
13744
assert_eq!(msg.next_remote_commitment_number, 0); // now called next_revocation_number
13696
13745
assert_eq!(msg.your_last_per_commitment_secret, [0; 32]);
13697
13746
13698
13747
// Check that the commitment point in Node A's channel_reestablish message
13699
13748
// is sane.
13700
13749
assert!(node_a_chan.remove_uncommitted_htlcs_and_mark_paused(&&logger).is_ok());
13701
- let msg = node_a_chan.get_channel_reestablish(&&logger);
13750
+ let msg = node_a_chan.get_channel_reestablish(&channelmanager::provided_init_features(&config), & &logger);
13702
13751
assert_eq!(msg.next_local_commitment_number, 1); // now called next_commitment_number
13703
13752
assert_eq!(msg.next_remote_commitment_number, 0); // now called next_revocation_number
13704
13753
assert_eq!(msg.your_last_per_commitment_secret, [0; 32]);
0 commit comments