Skip to content

Commit d9f832f

Browse files
committed
f match next_funding_txid logic to spec
1 parent 3799388 commit d9f832f

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

lightning/src/ln/channel.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7025,18 +7025,18 @@ impl<SP: Deref> FundedChannel<SP> where
70257025
update_fee: None,
70267026
})
70277027
} else { None };
7028-
// if it has not received tx_signatures for that funding transaction AND
7029-
// if it has already received commitment_signed AND it should sign first, as specified in the tx_signatures requirements:
7030-
// MUST send its tx_signatures for that funding transaction.
7031-
// else if it HAS received commitment_signed AND has received tx_signatures for that funding transaction:
7032-
// MUST send its tx_signatures for that funding transaction.
7033-
let tx_signatures = if session.has_received_commitment_signed() && ((
7034-
!session.counterparty_sent_tx_signatures() &&
7035-
session.holder_sends_tx_signatures_first()
7036-
) || session.counterparty_sent_tx_signatures()) {
7037-
// This should have already been set in `commitment_signed_initial_v2`, but check again
7038-
// just in case.
7028+
let tx_signatures = if (
7029+
// if it has not received tx_signatures for that funding transaction AND
7030+
// if it has already received commitment_signed AND it should sign first, as specified in the tx_signatures requirements:
7031+
// MUST send its tx_signatures for that funding transaction.
7032+
!session.counterparty_sent_tx_signatures() && session.has_received_commitment_signed() && session.holder_sends_tx_signatures_first()
7033+
// else if it has already received tx_signatures for that funding transaction:
7034+
// MUST send its tx_signatures for that funding transaction.
7035+
) || session.counterparty_sent_tx_signatures() {
70397036
if self.context.channel_state.is_monitor_update_in_progress() {
7037+
// The `monitor_pending_tx_signatures` field should have already been set in `commitment_signed_initial_v2`
7038+
// if we were up first for signing and had a monitor update in progress, but check again just in case.
7039+
debug_assert!(self.context.monitor_pending_tx_signatures.is_some(), "monitor_pending_tx_signatures should already be set");
70407040
log_debug!(logger, "Not sending tx_signatures: a monitor update is in progress. Setting monitor_pending_tx_signatures.");
70417041
if self.context.monitor_pending_tx_signatures.is_none() {
70427042
self.context.monitor_pending_tx_signatures = session.holder_tx_signatures().clone();
@@ -7056,7 +7056,8 @@ impl<SP: Deref> FundedChannel<SP> where
70567056
};
70577057
(commitment_update, tx_signatures, None)
70587058
} else {
7059-
// MUST send tx_abort to let the sending node know that they can forget this funding transaction.
7059+
// The `next_funding_txid` does not match the latest interactive funding transaction so we
7060+
// MUST send tx_abort to let the remote know that they can forget this funding transaction.
70607061
(None, None, Some(msgs::TxAbort { channel_id: self.context.channel_id(), data: vec![] }))
70617062
}
70627063
} else {

0 commit comments

Comments
 (0)