@@ -1262,6 +1262,18 @@ impl OutboundContext {
1262
1262
created_funding_transaction: None,
1263
1263
}
1264
1264
}
1265
+
1266
+ /// Determines whether an `AcceptChannel` message has been received during a previous
1267
+ /// channel handshake.
1268
+ pub fn received_accept_channel(&self) -> bool {
1269
+ self.received_accept_channel_msg.is_some()
1270
+ }
1271
+
1272
+ /// Determines whether a Funding Transaction had been created during a previous
1273
+ /// channel handshake.
1274
+ pub fn created_funding_transaction(&self) -> bool {
1275
+ self.created_funding_transaction.is_some()
1276
+ }
1265
1277
}
1266
1278
1267
1279
struct FundingTransaction {
@@ -7465,8 +7477,8 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
7465
7477
if !self.context.is_outbound() {
7466
7478
panic!("Tried to open a channel for an inbound channel?");
7467
7479
}
7468
- if self.context.have_received_message() {
7469
- panic!("Cannot generate an open_channel after we've moved forward");
7480
+ if self.context.have_received_message() && !self.deja_vu() {
7481
+ panic!("Cannot generate an open_channel after we've moved forward earlier, but doesn't know the previous accept_channel_msg ");
7470
7482
}
7471
7483
7472
7484
if self.context.cur_holder_commitment_transaction_number != INITIAL_COMMITMENT_NUMBER {
@@ -7738,6 +7750,19 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
7738
7750
Ok((channel, channel_monitor))
7739
7751
}
7740
7752
7753
+ /// Determines if the outbound channel handshake process is being retried.
7754
+ fn deja_vu(&self) -> bool {
7755
+ let negotiating = !matches!(self.context.channel_state, ChannelState::NegotiatingFunding(flags) if flags == NegotiatingFundingFlags::OUR_INIT_SENT);
7756
+ let negotiated = self.context.channel_state == ChannelState::FundingNegotiated;
7757
+
7758
+ if (negotiated && self.outbound_context.created_funding_transaction()) ||
7759
+ (negotiating && self.outbound_context.received_accept_channel()) {
7760
+ true
7761
+ } else {
7762
+ false
7763
+ }
7764
+ }
7765
+
7741
7766
/// Indicates that the signer may have some signatures for us, so we should retry if we're
7742
7767
/// blocked.
7743
7768
#[cfg(async_signing)]
0 commit comments