@@ -6807,6 +6807,9 @@ impl<SP: Deref> FundedChannel<SP> where
6807
6807
6808
6808
if msg.next_local_commitment_number >= INITIAL_COMMITMENT_NUMBER || msg.next_remote_commitment_number >= INITIAL_COMMITMENT_NUMBER ||
6809
6809
msg.next_local_commitment_number == 0 && msg.next_funding_txid.is_none() {
6810
+ // Note: This also covers the following case in the V2 channel establishment specification:
6811
+ // if `next_funding_txid` is not set, and `next_commitment_number` is zero:
6812
+ // MUST immediately fail the channel and broadcast any relevant latest commitment transaction.
6810
6813
return Err(ChannelError::close("Peer sent an invalid channel_reestablish to force close in a non-standard way".to_owned()));
6811
6814
}
6812
6815
@@ -6948,14 +6951,30 @@ impl<SP: Deref> FundedChannel<SP> where
6948
6951
// if it has already received commitment_signed and it should sign first, as specified in the tx_signatures requirements:
6949
6952
if session.has_received_commitment_signed() && session.holder_sends_tx_signatures_first() {
6950
6953
// MUST send its tx_signatures for that funding transaction.
6951
- (commitment_update, session.holder_tx_signatures().clone(), None)
6954
+ if self.context.channel_state.is_monitor_update_in_progress() {
6955
+ log_debug!(logger, "Not sending tx_signatures: a monitor update is in progress. Setting monitor_pending_tx_signatures.");
6956
+ self.context.monitor_pending_tx_signatures = session.holder_tx_signatures().clone();
6957
+ // We can still send the initial commitment transaction if a monitor update is pending.
6958
+ (commitment_update, None, None)
6959
+ } else {
6960
+ (commitment_update, session.holder_tx_signatures().clone(), None)
6961
+ }
6952
6962
} else {
6953
6963
(commitment_update, None, None)
6954
6964
}
6955
6965
} else {
6956
6966
// if it has already received tx_signatures for that funding transaction:
6957
6967
// MUST send its tx_signatures for that funding transaction.
6958
- (None, session.holder_tx_signatures().clone(), None)
6968
+ if self.context.channel_state.is_monitor_update_in_progress() {
6969
+ log_debug!(logger, "Not sending tx_signatures: a monitor update is in progress. Setting monitor_pending_tx_signatures.");
6970
+ self.context.monitor_pending_tx_signatures = session.holder_tx_signatures().clone();
6971
+ (None, None, None)
6972
+ } else {
6973
+ // If `holder_tx_signatures` is `None` here, the `tx_signatures` message will be sent
6974
+ // when the holder provides their witnesses as this will queue a `tx_signatures` if the
6975
+ // holder must send one.
6976
+ (None, session.holder_tx_signatures().clone(), None)
6977
+ }
6959
6978
}
6960
6979
} else {
6961
6980
// MUST send tx_abort to let the sending node know that they can forget this funding transaction.
@@ -6965,15 +6984,6 @@ impl<SP: Deref> FundedChannel<SP> where
6965
6984
return Err(ChannelError::close("Counterparty set `next_funding_txid` at incorrect state".into()));
6966
6985
}
6967
6986
} else {
6968
- // if `next_funding_txid` is not set, and `next_commitment_number` is zero:
6969
- if msg.next_local_commitment_number == 0 {
6970
- // MUST immediately fail the channel and broadcast any relevant latest commitment transaction.
6971
- return Err(ChannelError::close(format!(
6972
- "Peer attempted to reestablish channel expecting a future local commitment transaction: {} (received) vs {} (expected)",
6973
- msg.next_remote_commitment_number,
6974
- our_commitment_transaction
6975
- )));
6976
- }
6977
6987
(None, None, None)
6978
6988
};
6979
6989
0 commit comments