Skip to content

Commit a72cb0c

Browse files
committed
f match next_funding_txid logic to spec
1 parent 54b722c commit a72cb0c

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
@@ -7042,18 +7042,18 @@ impl<SP: Deref> FundedChannel<SP> where
70427042
update_fee: None,
70437043
})
70447044
} else { None };
7045-
// if it has not received tx_signatures for that funding transaction AND
7046-
// if it has already received commitment_signed AND it should sign first, as specified in the tx_signatures requirements:
7047-
// MUST send its tx_signatures for that funding transaction.
7048-
// else if it HAS received commitment_signed AND has received tx_signatures for that funding transaction:
7049-
// MUST send its tx_signatures for that funding transaction.
7050-
let tx_signatures = if session.has_received_commitment_signed() && ((
7051-
!session.counterparty_sent_tx_signatures() &&
7052-
session.holder_sends_tx_signatures_first()
7053-
) || session.counterparty_sent_tx_signatures()) {
7054-
// This should have already been set in `commitment_signed_initial_v2`, but check again
7055-
// just in case.
7045+
let tx_signatures = if (
7046+
// if it has not received tx_signatures for that funding transaction AND
7047+
// if it has already received commitment_signed AND it should sign first, as specified in the tx_signatures requirements:
7048+
// MUST send its tx_signatures for that funding transaction.
7049+
!session.counterparty_sent_tx_signatures() && session.has_received_commitment_signed() && session.holder_sends_tx_signatures_first()
7050+
// else if it has already received tx_signatures for that funding transaction:
7051+
// MUST send its tx_signatures for that funding transaction.
7052+
) || session.counterparty_sent_tx_signatures() {
70567053
if self.context.channel_state.is_monitor_update_in_progress() {
7054+
// The `monitor_pending_tx_signatures` field should have already been set in `commitment_signed_initial_v2`
7055+
// if we were up first for signing and had a monitor update in progress, but check again just in case.
7056+
debug_assert!(self.context.monitor_pending_tx_signatures.is_some(), "monitor_pending_tx_signatures should already be set");
70577057
log_debug!(logger, "Not sending tx_signatures: a monitor update is in progress. Setting monitor_pending_tx_signatures.");
70587058
if self.context.monitor_pending_tx_signatures.is_none() {
70597059
self.context.monitor_pending_tx_signatures = session.holder_tx_signatures().clone();
@@ -7073,7 +7073,8 @@ impl<SP: Deref> FundedChannel<SP> where
70737073
};
70747074
(commitment_update, tx_signatures, None)
70757075
} else {
7076-
// MUST send tx_abort to let the sending node know that they can forget this funding transaction.
7076+
// The `next_funding_txid` does not match the latest interactive funding transaction so we
7077+
// MUST send tx_abort to let the remote know that they can forget this funding transaction.
70777078
(None, None, Some(msgs::TxAbort { channel_id: self.context.channel_id(), data: vec![] }))
70787079
}
70797080
} else {

0 commit comments

Comments
 (0)