@@ -1665,12 +1665,12 @@ where
1665
1665
/// send our peer to begin the channel reconnection process.
1666
1666
#[rustfmt::skip]
1667
1667
pub fn peer_connected_get_handshake<L: Deref>(
1668
- &mut self, chain_hash: ChainHash, logger: &L,
1668
+ &mut self, chain_hash: ChainHash, their_features: &InitFeatures, logger: &L,
1669
1669
) -> ReconnectionMsg where L::Target: Logger {
1670
1670
match &mut self.phase {
1671
1671
ChannelPhase::Undefined => unreachable!(),
1672
1672
ChannelPhase::Funded(chan) =>
1673
- ReconnectionMsg::Reestablish(chan.get_channel_reestablish(logger)),
1673
+ ReconnectionMsg::Reestablish(chan.get_channel_reestablish(their_features, logger)),
1674
1674
ChannelPhase::UnfundedOutboundV1(chan) => {
1675
1675
chan.get_open_channel(chain_hash, logger)
1676
1676
.map(|msg| ReconnectionMsg::Open(OpenChannelMessage::V1(msg)))
@@ -9381,6 +9381,13 @@ where
9381
9381
self.context.latest_inbound_scid_alias.or(self.funding.get_short_channel_id())
9382
9382
}
9383
9383
9384
+ /// Returns true if their channel_ready has been received
9385
+ #[cfg(splicing)]
9386
+ pub fn is_their_channel_ready(&self) -> bool {
9387
+ matches!(self.context.channel_state, ChannelState::AwaitingChannelReady(flags) if flags.is_set(AwaitingChannelReadyFlags::THEIR_CHANNEL_READY))
9388
+ || matches!(self.context.channel_state, ChannelState::ChannelReady(_))
9389
+ }
9390
+
9384
9391
/// Returns true if our channel_ready has been sent
9385
9392
pub fn is_our_channel_ready(&self) -> bool {
9386
9393
matches!(self.context.channel_state, ChannelState::AwaitingChannelReady(flags) if flags.is_set(AwaitingChannelReadyFlags::OUR_CHANNEL_READY))
@@ -10128,10 +10135,52 @@ where
10128
10135
}
10129
10136
}
10130
10137
10138
+ #[cfg(splicing)]
10139
+ fn maybe_get_your_last_funding_locked_txid(&self, features: &InitFeatures) -> Option<Txid> {
10140
+ if !features.supports_splicing() {
10141
+ return None;
10142
+ }
10143
+
10144
+ self.pending_splice
10145
+ .as_ref()
10146
+ .and_then(|pending_splice| pending_splice.received_funding_txid)
10147
+ .or_else(|| {
10148
+ self.is_their_channel_ready().then(|| self.funding.get_funding_txid()).flatten()
10149
+ })
10150
+ }
10151
+ #[cfg(not(splicing))]
10152
+ fn maybe_get_your_last_funding_locked_txid(&self, _features: &InitFeatures) -> Option<Txid> {
10153
+ None
10154
+ }
10155
+
10156
+ #[cfg(splicing)]
10157
+ fn maybe_get_my_current_funding_locked_txid(&self, features: &InitFeatures) -> Option<Txid> {
10158
+ if !features.supports_splicing() {
10159
+ return None;
10160
+ }
10161
+
10162
+ self.pending_splice
10163
+ .as_ref()
10164
+ .and_then(|pending_splice| pending_splice.sent_funding_txid)
10165
+ .or_else(|| {
10166
+ self.is_our_channel_ready().then(|| self.funding.get_funding_txid()).flatten()
10167
+ })
10168
+ }
10169
+
10170
+ #[cfg(not(splicing))]
10171
+ fn maybe_get_my_current_funding_locked_txid(&self, _features: &InitFeatures) -> Option<Txid> {
10172
+ None
10173
+ }
10174
+
10131
10175
/// May panic if called on a channel that wasn't immediately-previously
10132
10176
/// self.remove_uncommitted_htlcs_and_mark_paused()'d
10133
10177
#[rustfmt::skip]
10134
- fn get_channel_reestablish<L: Deref>(&mut self, logger: &L) -> msgs::ChannelReestablish where L::Target: Logger {
10178
+ fn get_channel_reestablish<L: Deref>(
10179
+ &mut self, their_features: &InitFeatures, logger: &L,
10180
+ ) -> msgs::ChannelReestablish
10181
+ where
10182
+ L::Target: Logger,
10183
+ {
10135
10184
assert!(self.context.channel_state.is_peer_disconnected());
10136
10185
assert_ne!(self.context.cur_counterparty_commitment_transaction_number, INITIAL_COMMITMENT_NUMBER);
10137
10186
// This is generally the first function which gets called on any given channel once we're
@@ -10179,8 +10228,8 @@ where
10179
10228
your_last_per_commitment_secret: remote_last_secret,
10180
10229
my_current_per_commitment_point: dummy_pubkey,
10181
10230
next_funding_txid: self.maybe_get_next_funding_txid(),
10182
- your_last_funding_locked_txid: None ,
10183
- my_current_funding_locked_txid: None ,
10231
+ your_last_funding_locked_txid: self.maybe_get_your_last_funding_locked_txid(their_features) ,
10232
+ my_current_funding_locked_txid: self.maybe_get_my_current_funding_locked_txid(their_features) ,
10184
10233
}
10185
10234
}
10186
10235
@@ -13691,15 +13740,15 @@ mod tests {
13691
13740
// Now disconnect the two nodes and check that the commitment point in
13692
13741
// Node B's channel_reestablish message is sane.
13693
13742
assert!(node_b_chan.remove_uncommitted_htlcs_and_mark_paused(&&logger).is_ok());
13694
- let msg = node_b_chan.get_channel_reestablish(&&logger);
13743
+ let msg = node_b_chan.get_channel_reestablish(&channelmanager::provided_init_features(&config), & &logger);
13695
13744
assert_eq!(msg.next_local_commitment_number, 1); // now called next_commitment_number
13696
13745
assert_eq!(msg.next_remote_commitment_number, 0); // now called next_revocation_number
13697
13746
assert_eq!(msg.your_last_per_commitment_secret, [0; 32]);
13698
13747
13699
13748
// Check that the commitment point in Node A's channel_reestablish message
13700
13749
// is sane.
13701
13750
assert!(node_a_chan.remove_uncommitted_htlcs_and_mark_paused(&&logger).is_ok());
13702
- let msg = node_a_chan.get_channel_reestablish(&&logger);
13751
+ let msg = node_a_chan.get_channel_reestablish(&channelmanager::provided_init_features(&config), & &logger);
13703
13752
assert_eq!(msg.next_local_commitment_number, 1); // now called next_commitment_number
13704
13753
assert_eq!(msg.next_remote_commitment_number, 0); // now called next_revocation_number
13705
13754
assert_eq!(msg.your_last_per_commitment_secret, [0; 32]);
0 commit comments