@@ -1694,8 +1694,7 @@ where
1694
1694
pending_v2_channel.interactive_tx_constructor.take();
1695
1695
},
1696
1696
ChannelPhase::Funded(funded_channel) => {
1697
- if funded_channel.should_reset_pending_splice_funding_negotiation().unwrap_or(true)
1698
- {
1697
+ if funded_channel.should_reset_pending_splice_state() {
1699
1698
funded_channel.reset_pending_splice_state();
1700
1699
} else {
1701
1700
debug_assert!(false, "We should never fail an interactive funding negotiation once we're exchanging tx_signatures");
@@ -1829,8 +1828,10 @@ where
1829
1828
pending_v2_channel.interactive_tx_constructor.take().is_some()
1830
1829
},
1831
1830
ChannelPhase::Funded(funded_channel) => {
1832
- if let Some(should_reset) =
1833
- funded_channel.should_reset_pending_splice_funding_negotiation()
1831
+ if let Some(should_reset) = funded_channel
1832
+ .pending_splice
1833
+ .as_ref()
1834
+ .map(|pending_splice| pending_splice.can_abandon_state())
1834
1835
{
1835
1836
if should_reset {
1836
1837
// We may have still tracked the pending funding negotiation state, so we
@@ -2583,13 +2584,13 @@ impl FundingNegotiation {
2583
2584
}
2584
2585
2585
2586
impl PendingFunding {
2586
- fn can_abandon_funding_negotiation (&self) -> bool {
2587
+ fn can_abandon_state (&self) -> bool {
2587
2588
self.funding_negotiation
2588
2589
.as_ref()
2589
2590
.map(|funding_negotiation| {
2590
2591
!matches!(funding_negotiation, FundingNegotiation::AwaitingSignatures { .. })
2591
2592
})
2592
- .unwrap_or(true )
2593
+ .unwrap_or(self.negotiated_candidates.is_empty() )
2593
2594
}
2594
2595
2595
2596
fn check_get_splice_locked<SP: Deref>(
@@ -6773,40 +6774,25 @@ where
6773
6774
)
6774
6775
}
6775
6776
6776
- /// Returns `None` if there is no [`FundedChannel::pending_splice`], otherwise a boolean
6777
- /// indicating whether we should reset the splice's [`PendingFunding::funding_negotiation`].
6778
- fn should_reset_pending_splice_funding_negotiation(&self) -> Option<bool> {
6779
- self.pending_splice.as_ref().map(|pending_splice| {
6780
- if pending_splice.can_abandon_funding_negotiation() {
6781
- true
6782
- } else {
6783
- self.context
6784
- .interactive_tx_signing_session
6785
- .as_ref()
6786
- .map(|signing_session| !signing_session.has_received_commitment_signed())
6787
- .unwrap_or_else(|| {
6788
- debug_assert!(false);
6789
- false
6790
- })
6791
- }
6792
- })
6793
- }
6794
-
6777
+ /// Returns a boolean indicating whether we should reset the splice's
6778
+ /// [`PendingFunding::funding_negotiation`].
6795
6779
fn should_reset_pending_splice_state(&self) -> bool {
6796
- self.should_reset_pending_splice_funding_negotiation().unwrap_or(true)
6797
- && self.pending_funding().is_empty()
6780
+ self.pending_splice
6781
+ .as_ref()
6782
+ .map(|pending_splice| pending_splice.can_abandon_state())
6783
+ .unwrap_or(true)
6798
6784
}
6799
6785
6800
6786
fn reset_pending_splice_state(&mut self) -> bool {
6801
- debug_assert!(self.should_reset_pending_splice_funding_negotiation().unwrap_or(true ));
6787
+ debug_assert!(self.should_reset_pending_splice_state( ));
6802
6788
self.context.channel_state.clear_quiescent();
6803
6789
self.context.interactive_tx_signing_session.take();
6804
6790
let has_funding_negotiation = self
6805
6791
.pending_splice
6806
6792
.as_mut()
6807
6793
.and_then(|pending_splice| pending_splice.funding_negotiation.take())
6808
6794
.is_some();
6809
- if self.should_reset_pending_splice_state () {
6795
+ if self.pending_funding().is_empty () {
6810
6796
self.pending_splice.take();
6811
6797
}
6812
6798
has_funding_negotiation
@@ -8948,7 +8934,7 @@ where
8948
8934
}
8949
8935
self.context.channel_state.clear_local_stfu_sent();
8950
8936
self.context.channel_state.clear_remote_stfu_sent();
8951
- if self.should_reset_pending_splice_funding_negotiation().unwrap_or(true ) {
8937
+ if self.should_reset_pending_splice_state( ) {
8952
8938
// If we were in quiescence but a splice was never negotiated, or the negotiation
8953
8939
// failed due to disconnecting, we shouldn't be quiescent anymore upon reconnecting.
8954
8940
// If there was a pending splice negotiation that has failed due to disconnecting,
@@ -14021,7 +14007,7 @@ where
14021
14007
}
14022
14008
channel_state.clear_local_stfu_sent();
14023
14009
channel_state.clear_remote_stfu_sent();
14024
- if self.should_reset_pending_splice_funding_negotiation().unwrap_or(true ) {
14010
+ if self.should_reset_pending_splice_state( ) {
14025
14011
// If we were in quiescence but a splice was never negotiated, or the
14026
14012
// negotiation failed due to disconnecting, we shouldn't be quiescent
14027
14013
// anymore upon reconnecting.
@@ -14389,19 +14375,14 @@ where
14389
14375
let holder_commitment_point_next = self.holder_commitment_point.next_point();
14390
14376
let holder_commitment_point_pending_next = self.holder_commitment_point.pending_next_point;
14391
14377
14392
- let interactive_tx_signing_session =
14393
- if self.should_reset_pending_splice_funding_negotiation().unwrap_or(false ) {
14394
- None
14378
+ let ( interactive_tx_signing_session, pending_splice) =
14379
+ if self.should_reset_pending_splice_state( ) {
14380
+ ( None, None)
14395
14381
} else {
14396
- self.context.interactive_tx_signing_session.as_ref()
14382
+ // We don't have to worry about resetting the pending `FundingNegotiation` because we
14383
+ // can only read `FundingNegotiation::AwaitingSignatures` variants anyway.
14384
+ (self.context.interactive_tx_signing_session.as_ref(), self.pending_splice.as_ref())
14397
14385
};
14398
- let pending_splice = if self.should_reset_pending_splice_state() {
14399
- None
14400
- } else {
14401
- // We don't have to worry about resetting the pending `FundingNegotiation` because we
14402
- // can only read `FundingNegotiation::AwaitingSignatures` variants anyway.
14403
- self.pending_splice.as_ref()
14404
- };
14405
14386
14406
14387
write_tlv_fields!(writer, {
14407
14388
(0, self.context.announcement_sigs, option),
0 commit comments