Skip to content

Commit 4432d15

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 5bdf99e commit 4432d15

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

lightning/src/ln/channel.rs

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8870,7 +8870,18 @@ where
88708870
}
88718871
self.context.channel_state.clear_local_stfu_sent();
88728872
self.context.channel_state.clear_remote_stfu_sent();
8873-
self.context.channel_state.clear_quiescent();
8873+
if self
8874+
.context
8875+
.interactive_tx_signing_session
8876+
.as_ref()
8877+
.map(|signing_session| {
8878+
signing_session.has_received_tx_signatures()
8879+
&& signing_session.holder_tx_signatures().is_some()
8880+
})
8881+
.unwrap_or(true)
8882+
{
8883+
self.context.channel_state.clear_quiescent();
8884+
}
88748885
}
88758886

88768887
self.context.channel_state.set_peer_disconnected();
@@ -11323,6 +11334,11 @@ where
1132311334
.as_ref()
1132411335
.filter(|session| !session.has_received_tx_signatures())
1132511336
.map(|signing_session| {
11337+
debug_assert_eq!(
11338+
self.pending_splice.is_some(),
11339+
self.context.channel_state.is_quiescent()
11340+
);
11341+
1132611342
// - MUST include the `next_funding` TLV.
1132711343
// - MUST set `next_funding_txid` to the txid of that interactive transaction.
1132811344
let mut next_funding = msgs::NextFunding {
@@ -13902,7 +13918,18 @@ where
1390213918
}
1390313919
channel_state.clear_local_stfu_sent();
1390413920
channel_state.clear_remote_stfu_sent();
13905-
channel_state.clear_quiescent();
13921+
if self
13922+
.context
13923+
.interactive_tx_signing_session
13924+
.as_ref()
13925+
.map(|signing_session| {
13926+
signing_session.has_received_tx_signatures()
13927+
&& signing_session.holder_tx_signatures().is_some()
13928+
})
13929+
.unwrap_or(true)
13930+
{
13931+
channel_state.clear_quiescent();
13932+
}
1390613933
},
1390713934
ChannelState::FundingNegotiated(_)
1390813935
if self.context.interactive_tx_signing_session.is_some() => {},

0 commit comments

Comments
 (0)