@@ -7034,49 +7034,51 @@ impl<SP: Deref> FundedChannel<SP> where
7034
7034
// if next_funding_txid matches the latest interactive funding transaction:
7035
7035
if session.unsigned_tx().compute_txid() == next_funding_txid {
7036
7036
debug_assert_eq!(session.unsigned_tx().compute_txid(), self.maybe_get_next_funding_txid().unwrap());
7037
- // if it has not received tx_signatures for that funding transaction:
7038
- if !session.counterparty_sent_tx_signatures() {
7037
+
7038
+ let commitment_update = if !session.counterparty_sent_tx_signatures() && msg.next_local_commitment_number == 0 {
7039
+ // if it has not received tx_signatures for that funding transaction AND
7039
7040
// if next_commitment_number is zero:
7040
- let commitment_update = if msg.next_local_commitment_number == 0 {
7041
- // MUST retransmit its commitment_signed for that funding transaction.
7042
- let commitment_signed = self.context.get_initial_commitment_signed(&self.funding, logger)?;
7043
- Some(msgs::CommitmentUpdate {
7044
- commitment_signed,
7045
- update_add_htlcs: vec![],
7046
- update_fulfill_htlcs: vec![],
7047
- update_fail_htlcs: vec![],
7048
- update_fail_malformed_htlcs: vec![],
7049
- update_fee: None,
7050
- })
7051
- } else { None };
7052
- // if it has already received commitment_signed and it should sign first, as specified in the tx_signatures requirements:
7053
- if session.has_received_commitment_signed() && session.holder_sends_tx_signatures_first() {
7054
- // MUST send its tx_signatures for that funding transaction.
7055
- if self.context.channel_state.is_monitor_update_in_progress() {
7056
- log_debug!(logger, "Not sending tx_signatures: a monitor update is in progress. Setting monitor_pending_tx_signatures.");
7057
- self.context.monitor_pending_tx_signatures = session.holder_tx_signatures().clone();
7058
- // We can still send the initial commitment transaction if a monitor update is pending.
7059
- (commitment_update, None, None)
7060
- } else {
7061
- (commitment_update, session.holder_tx_signatures().clone(), None)
7062
- }
7063
- } else {
7064
- (commitment_update, None, None)
7065
- }
7066
- } else {
7067
- // if it has already received tx_signatures for that funding transaction:
7068
- // MUST send its tx_signatures for that funding transaction.
7041
+ // MUST retransmit its commitment_signed for that funding transaction.
7042
+ let commitment_signed = self.context.get_initial_commitment_signed(&self.funding, logger)?;
7043
+ Some(msgs::CommitmentUpdate {
7044
+ commitment_signed,
7045
+ update_add_htlcs: vec![],
7046
+ update_fulfill_htlcs: vec![],
7047
+ update_fail_htlcs: vec![],
7048
+ update_fail_malformed_htlcs: vec![],
7049
+ update_fee: None,
7050
+ })
7051
+ } else { None };
7052
+ // if it has not received tx_signatures for that funding transaction AND
7053
+ // if it has already received commitment_signed AND it should sign first, as specified in the tx_signatures requirements:
7054
+ // MUST send its tx_signatures for that funding transaction.
7055
+ // else if it HAS received commitment_signed AND has received tx_signatures for that funding transaction:
7056
+ // MUST send its tx_signatures for that funding transaction.
7057
+ let tx_signatures = if session.has_received_commitment_signed() && ((
7058
+ !session.counterparty_sent_tx_signatures() &&
7059
+ session.holder_sends_tx_signatures_first()
7060
+ ) || session.counterparty_sent_tx_signatures()) {
7061
+ // This should have already been set in `commitment_signed_initial_v2`, but check again
7062
+ // just in case.
7069
7063
if self.context.channel_state.is_monitor_update_in_progress() {
7070
7064
log_debug!(logger, "Not sending tx_signatures: a monitor update is in progress. Setting monitor_pending_tx_signatures.");
7071
- self.context.monitor_pending_tx_signatures = session.holder_tx_signatures().clone();
7072
- (None, None, None)
7065
+ if self.context.monitor_pending_tx_signatures.is_none() {
7066
+ self.context.monitor_pending_tx_signatures = session.holder_tx_signatures().clone();
7067
+ }
7068
+ None
7073
7069
} else {
7074
7070
// If `holder_tx_signatures` is `None` here, the `tx_signatures` message will be sent
7075
7071
// when the holder provides their witnesses as this will queue a `tx_signatures` if the
7076
7072
// holder must send one.
7077
- (None, session.holder_tx_signatures().clone(), None )
7073
+ session.holder_tx_signatures().clone()
7078
7074
}
7079
- }
7075
+ } else {
7076
+ if !session.has_received_commitment_signed() {
7077
+ self.context.expecting_peer_commitment_signed = true;
7078
+ }
7079
+ None
7080
+ };
7081
+ (commitment_update, tx_signatures, None)
7080
7082
} else {
7081
7083
// MUST send tx_abort to let the sending node know that they can forget this funding transaction.
7082
7084
(None, None, Some(msgs::TxAbort { channel_id: self.context.channel_id(), data: vec![] }))
@@ -7085,6 +7087,7 @@ impl<SP: Deref> FundedChannel<SP> where
7085
7087
return Err(ChannelError::close("Counterparty set `next_funding_txid` at incorrect state".into()));
7086
7088
}
7087
7089
} else {
7090
+ // Don't send anything related to interactive signing if `next_funding_txid` is not set.
7088
7091
(None, None, None)
7089
7092
};
7090
7093
0 commit comments