Skip to content

Commit 7bd460a

Browse files
committed
Remain quiescent on disconnect until tx_signatures exchange
As per the spec requirement, this was already enforced throughout the happy case when a disconnection does not happen. If a disconnect would happen, we always naively cleared the flag without checking whether we did indeed exchange `tx_signatures`.
1 parent f5b7288 commit 7bd460a

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

lightning/src/ln/channel.rs

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8882,7 +8882,18 @@ where
88828882
}
88838883
self.context.channel_state.clear_local_stfu_sent();
88848884
self.context.channel_state.clear_remote_stfu_sent();
8885-
self.context.channel_state.clear_quiescent();
8885+
if self
8886+
.context
8887+
.interactive_tx_signing_session
8888+
.as_ref()
8889+
.map(|signing_session| {
8890+
signing_session.has_received_tx_signatures()
8891+
&& signing_session.holder_tx_signatures().is_some()
8892+
})
8893+
.unwrap_or(true)
8894+
{
8895+
self.context.channel_state.clear_quiescent();
8896+
}
88868897
}
88878898

88888899
self.context.channel_state.set_peer_disconnected();
@@ -11322,6 +11333,10 @@ where
1132211333
.as_ref()
1132311334
.filter(|session| !session.has_received_tx_signatures())
1132411335
.map(|signing_session| {
11336+
if self.pending_splice.is_some() {
11337+
debug_assert!(self.context.channel_state.is_quiescent());
11338+
}
11339+
1132511340
let mut next_funding = msgs::NextFunding {
1132611341
txid: signing_session.unsigned_tx().compute_txid(),
1132711342
retransmit_flags: 0,
@@ -13913,7 +13928,18 @@ where
1391313928
}
1391413929
channel_state.clear_local_stfu_sent();
1391513930
channel_state.clear_remote_stfu_sent();
13916-
channel_state.clear_quiescent();
13931+
if self
13932+
.context
13933+
.interactive_tx_signing_session
13934+
.as_ref()
13935+
.map(|signing_session| {
13936+
signing_session.has_received_tx_signatures()
13937+
&& signing_session.holder_tx_signatures().is_some()
13938+
})
13939+
.unwrap_or(true)
13940+
{
13941+
channel_state.clear_quiescent();
13942+
}
1391713943
},
1391813944
ChannelState::FundingNegotiated(_)
1391913945
if self.context.interactive_tx_signing_session.is_some() => {},

0 commit comments

Comments
 (0)