@@ -1664,12 +1664,12 @@ where
1664
1664
/// send our peer to begin the channel reconnection process.
1665
1665
#[rustfmt::skip]
1666
1666
pub fn peer_connected_get_handshake<L: Deref>(
1667
- &mut self, chain_hash: ChainHash, logger: &L,
1667
+ &mut self, chain_hash: ChainHash, their_features: &InitFeatures, logger: &L,
1668
1668
) -> ReconnectionMsg where L::Target: Logger {
1669
1669
match &mut self.phase {
1670
1670
ChannelPhase::Undefined => unreachable!(),
1671
1671
ChannelPhase::Funded(chan) =>
1672
- ReconnectionMsg::Reestablish(chan.get_channel_reestablish(logger)),
1672
+ ReconnectionMsg::Reestablish(chan.get_channel_reestablish(their_features, logger)),
1673
1673
ChannelPhase::UnfundedOutboundV1(chan) => {
1674
1674
chan.get_open_channel(chain_hash, logger)
1675
1675
.map(|msg| ReconnectionMsg::Open(OpenChannelMessage::V1(msg)))
@@ -9779,6 +9779,13 @@ where
9779
9779
self.context.latest_inbound_scid_alias.or(self.funding.get_short_channel_id())
9780
9780
}
9781
9781
9782
+ /// Returns true if their channel_ready has been received
9783
+ #[cfg(splicing)]
9784
+ pub fn is_their_channel_ready(&self) -> bool {
9785
+ matches!(self.context.channel_state, ChannelState::AwaitingChannelReady(flags) if flags.is_set(AwaitingChannelReadyFlags::THEIR_CHANNEL_READY))
9786
+ || matches!(self.context.channel_state, ChannelState::ChannelReady(_))
9787
+ }
9788
+
9782
9789
/// Returns true if our channel_ready has been sent
9783
9790
pub fn is_our_channel_ready(&self) -> bool {
9784
9791
matches!(self.context.channel_state, ChannelState::AwaitingChannelReady(flags) if flags.is_set(AwaitingChannelReadyFlags::OUR_CHANNEL_READY))
@@ -10553,10 +10560,52 @@ where
10553
10560
}
10554
10561
}
10555
10562
10563
+ #[cfg(splicing)]
10564
+ fn maybe_get_your_last_funding_locked_txid(&self, features: &InitFeatures) -> Option<Txid> {
10565
+ if !features.supports_splicing() {
10566
+ return None;
10567
+ }
10568
+
10569
+ self.pending_splice
10570
+ .as_ref()
10571
+ .and_then(|pending_splice| pending_splice.received_funding_txid)
10572
+ .or_else(|| {
10573
+ self.is_their_channel_ready().then(|| self.funding.get_funding_txid()).flatten()
10574
+ })
10575
+ }
10576
+ #[cfg(not(splicing))]
10577
+ fn maybe_get_your_last_funding_locked_txid(&self, _features: &InitFeatures) -> Option<Txid> {
10578
+ None
10579
+ }
10580
+
10581
+ #[cfg(splicing)]
10582
+ fn maybe_get_my_current_funding_locked_txid(&self, features: &InitFeatures) -> Option<Txid> {
10583
+ if !features.supports_splicing() {
10584
+ return None;
10585
+ }
10586
+
10587
+ self.pending_splice
10588
+ .as_ref()
10589
+ .and_then(|pending_splice| pending_splice.sent_funding_txid)
10590
+ .or_else(|| {
10591
+ self.is_our_channel_ready().then(|| self.funding.get_funding_txid()).flatten()
10592
+ })
10593
+ }
10594
+
10595
+ #[cfg(not(splicing))]
10596
+ fn maybe_get_my_current_funding_locked_txid(&self, _features: &InitFeatures) -> Option<Txid> {
10597
+ None
10598
+ }
10599
+
10556
10600
/// May panic if called on a channel that wasn't immediately-previously
10557
10601
/// self.remove_uncommitted_htlcs_and_mark_paused()'d
10558
10602
#[rustfmt::skip]
10559
- fn get_channel_reestablish<L: Deref>(&mut self, logger: &L) -> msgs::ChannelReestablish where L::Target: Logger {
10603
+ fn get_channel_reestablish<L: Deref>(
10604
+ &mut self, their_features: &InitFeatures, logger: &L,
10605
+ ) -> msgs::ChannelReestablish
10606
+ where
10607
+ L::Target: Logger,
10608
+ {
10560
10609
assert!(self.context.channel_state.is_peer_disconnected());
10561
10610
assert_ne!(self.context.cur_counterparty_commitment_transaction_number, INITIAL_COMMITMENT_NUMBER);
10562
10611
// This is generally the first function which gets called on any given channel once we're
@@ -10604,8 +10653,8 @@ where
10604
10653
your_last_per_commitment_secret: remote_last_secret,
10605
10654
my_current_per_commitment_point: dummy_pubkey,
10606
10655
next_funding_txid: self.maybe_get_next_funding_txid(),
10607
- your_last_funding_locked_txid: None ,
10608
- my_current_funding_locked_txid: None ,
10656
+ your_last_funding_locked_txid: self.maybe_get_your_last_funding_locked_txid(their_features) ,
10657
+ my_current_funding_locked_txid: self.maybe_get_my_current_funding_locked_txid(their_features) ,
10609
10658
}
10610
10659
}
10611
10660
@@ -14468,15 +14517,15 @@ mod tests {
14468
14517
// Now disconnect the two nodes and check that the commitment point in
14469
14518
// Node B's channel_reestablish message is sane.
14470
14519
assert!(node_b_chan.remove_uncommitted_htlcs_and_mark_paused(&&logger).is_ok());
14471
- let msg = node_b_chan.get_channel_reestablish(&&logger);
14520
+ let msg = node_b_chan.get_channel_reestablish(&channelmanager::provided_init_features(&config), & &logger);
14472
14521
assert_eq!(msg.next_local_commitment_number, 1); // now called next_commitment_number
14473
14522
assert_eq!(msg.next_remote_commitment_number, 0); // now called next_revocation_number
14474
14523
assert_eq!(msg.your_last_per_commitment_secret, [0; 32]);
14475
14524
14476
14525
// Check that the commitment point in Node A's channel_reestablish message
14477
14526
// is sane.
14478
14527
assert!(node_a_chan.remove_uncommitted_htlcs_and_mark_paused(&&logger).is_ok());
14479
- let msg = node_a_chan.get_channel_reestablish(&&logger);
14528
+ let msg = node_a_chan.get_channel_reestablish(&channelmanager::provided_init_features(&config), & &logger);
14480
14529
assert_eq!(msg.next_local_commitment_number, 1); // now called next_commitment_number
14481
14530
assert_eq!(msg.next_remote_commitment_number, 0); // now called next_revocation_number
14482
14531
assert_eq!(msg.your_last_per_commitment_secret, [0; 32]);
0 commit comments