Skip to content

Commit a07eb85

Browse files
committed
Only sign funding transaction on monitor update resumption
The `handle_channel_resumption` path is reachable from both channel reestablish and monitor update completion. Since we only want to sign once we know the monitor update has completed, it's possible we could have unintentionally attempted to sign if we were still pending the monitor update but had a channel reestablish occur.
1 parent 9724d19 commit a07eb85

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9006,10 +9006,13 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
90069006
}
90079007
}
90089008

9009-
if let Some(signing_session) = &mut channel.interactive_tx_signing_session {
9010-
if signing_session.local_inputs_count() > 0
9011-
&& signing_session.holder_tx_signatures().is_none()
9012-
{
9009+
if let Some(signing_session) = (!channel.is_awaiting_monitor_update())
9010+
.then(|| ())
9011+
.and_then(|_| channel.interactive_tx_signing_session.as_mut())
9012+
.filter(|signing_session| signing_session.holder_tx_signatures().is_none())
9013+
{
9014+
let local_inputs_count = signing_session.local_inputs_count();
9015+
if local_inputs_count > 0 {
90139016
let mut pending_events = self.pending_events.lock().unwrap();
90149017
let unsigned_transaction = signing_session.unsigned_tx().build_unsigned_tx();
90159018
let event_action = (
@@ -9027,7 +9030,8 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
90279030
} else {
90289031
pending_events.push_back(event_action);
90299032
}
9030-
} else if signing_session.local_inputs_count() == 0 && signing_session.holder_tx_signatures().is_none() {
9033+
} else {
9034+
let txid = signing_session.unsigned_tx().compute_txid();
90319035
match channel.funding_transaction_signed(vec![]) {
90329036
Ok((Some(tx_signatures), funding_tx_opt)) => {
90339037
if let Some(funding_tx) = funding_tx_opt {

0 commit comments

Comments
 (0)