@@ -54,9 +54,10 @@ use crate::ln::channel_state::{
54
54
OutboundHTLCDetails, OutboundHTLCStateDetails,
55
55
};
56
56
use crate::ln::channelmanager::{
57
- self, FundingConfirmedMessage, HTLCFailureMsg, HTLCSource, OpenChannelMessage,
58
- PaymentClaimDetails, PendingHTLCInfo, PendingHTLCStatus, RAACommitmentOrder, SentHTLCId,
59
- BREAKDOWN_TIMEOUT, MAX_LOCAL_BREAKDOWN_TIMEOUT, MIN_CLTV_EXPIRY_DELTA,
57
+ self, ChannelReadyOrder, FundingConfirmedMessage, HTLCFailureMsg, HTLCSource,
58
+ OpenChannelMessage, PaymentClaimDetails, PendingHTLCInfo, PendingHTLCStatus,
59
+ RAACommitmentOrder, SentHTLCId, BREAKDOWN_TIMEOUT, MAX_LOCAL_BREAKDOWN_TIMEOUT,
60
+ MIN_CLTV_EXPIRY_DELTA,
60
61
};
61
62
use crate::ln::funding::FundingTxInput;
62
63
#[cfg(splicing)]
@@ -1181,13 +1182,14 @@ pub enum UpdateFulfillCommitFetch {
1181
1182
pub(super) struct MonitorRestoreUpdates {
1182
1183
pub raa: Option<msgs::RevokeAndACK>,
1183
1184
pub commitment_update: Option<msgs::CommitmentUpdate>,
1184
- pub order : RAACommitmentOrder,
1185
+ pub commitment_order : RAACommitmentOrder,
1185
1186
pub accepted_htlcs: Vec<(PendingHTLCInfo, u64)>,
1186
1187
pub failed_htlcs: Vec<(HTLCSource, PaymentHash, HTLCFailReason)>,
1187
1188
pub finalized_claimed_htlcs: Vec<(HTLCSource, Option<AttributionData>)>,
1188
1189
pub pending_update_adds: Vec<msgs::UpdateAddHTLC>,
1189
1190
pub funding_broadcastable: Option<Transaction>,
1190
1191
pub channel_ready: Option<msgs::ChannelReady>,
1192
+ pub channel_ready_order: ChannelReadyOrder,
1191
1193
pub announcement_sigs: Option<msgs::AnnouncementSignatures>,
1192
1194
pub tx_signatures: Option<msgs::TxSignatures>,
1193
1195
}
@@ -1210,9 +1212,10 @@ pub(super) struct SignerResumeUpdates {
1210
1212
/// The return value of `channel_reestablish`
1211
1213
pub(super) struct ReestablishResponses {
1212
1214
pub channel_ready: Option<msgs::ChannelReady>,
1215
+ pub channel_ready_order: ChannelReadyOrder,
1213
1216
pub raa: Option<msgs::RevokeAndACK>,
1214
1217
pub commitment_update: Option<msgs::CommitmentUpdate>,
1215
- pub order : RAACommitmentOrder,
1218
+ pub commitment_order : RAACommitmentOrder,
1216
1219
pub announcement_sigs: Option<msgs::AnnouncementSignatures>,
1217
1220
pub shutdown_msg: Option<msgs::Shutdown>,
1218
1221
pub tx_signatures: Option<msgs::TxSignatures>,
@@ -8705,6 +8708,17 @@ where
8705
8708
}
8706
8709
}
8707
8710
8711
+ // An active interactive signing session or an awaiting channel_ready state implies that a
8712
+ // commitment_signed retransmission is an initial one for funding negotiation. Thus, the
8713
+ // signatures should be sent before channel_ready.
8714
+ let channel_ready_order = if self.interactive_tx_signing_session.is_some() {
8715
+ ChannelReadyOrder::SignaturesFirst
8716
+ } else if matches!(self.context.channel_state, ChannelState::AwaitingChannelReady(_)) {
8717
+ ChannelReadyOrder::SignaturesFirst
8718
+ } else {
8719
+ ChannelReadyOrder::ChannelReadyFirst
8720
+ };
8721
+
8708
8722
// We will never broadcast the funding transaction when we're in MonitorUpdateInProgress
8709
8723
// (and we assume the user never directly broadcasts the funding transaction and waits for
8710
8724
// us to do it). Thus, we can only ever hit monitor_pending_channel_ready when we're
@@ -8733,9 +8747,10 @@ where
8733
8747
self.context.monitor_pending_revoke_and_ack = false;
8734
8748
self.context.monitor_pending_commitment_signed = false;
8735
8749
return MonitorRestoreUpdates {
8736
- raa: None, commitment_update: None, order : RAACommitmentOrder::RevokeAndACKFirst,
8750
+ raa: None, commitment_update: None, commitment_order : RAACommitmentOrder::RevokeAndACKFirst,
8737
8751
accepted_htlcs, failed_htlcs, finalized_claimed_htlcs, pending_update_adds,
8738
- funding_broadcastable, channel_ready, announcement_sigs, tx_signatures: None
8752
+ funding_broadcastable, channel_ready, announcement_sigs, tx_signatures: None,
8753
+ channel_ready_order,
8739
8754
};
8740
8755
}
8741
8756
@@ -8758,14 +8773,15 @@ where
8758
8773
8759
8774
self.context.monitor_pending_revoke_and_ack = false;
8760
8775
self.context.monitor_pending_commitment_signed = false;
8761
- let order = self.context.resend_order.clone();
8776
+ let commitment_order = self.context.resend_order.clone();
8762
8777
log_debug!(logger, "Restored monitor updating in channel {} resulting in {}{} commitment update and {} RAA, with {} first",
8763
8778
&self.context.channel_id(), if funding_broadcastable.is_some() { "a funding broadcastable, " } else { "" },
8764
8779
if commitment_update.is_some() { "a" } else { "no" }, if raa.is_some() { "an" } else { "no" },
8765
- match order { RAACommitmentOrder::CommitmentFirst => "commitment", RAACommitmentOrder::RevokeAndACKFirst => "RAA"});
8780
+ match commitment_order { RAACommitmentOrder::CommitmentFirst => "commitment", RAACommitmentOrder::RevokeAndACKFirst => "RAA"});
8766
8781
MonitorRestoreUpdates {
8767
- raa, commitment_update, order, accepted_htlcs, failed_htlcs, finalized_claimed_htlcs,
8768
- pending_update_adds, funding_broadcastable, channel_ready, announcement_sigs, tx_signatures: None
8782
+ raa, commitment_update, commitment_order, accepted_htlcs, failed_htlcs, finalized_claimed_htlcs,
8783
+ pending_update_adds, funding_broadcastable, channel_ready, announcement_sigs, tx_signatures: None,
8784
+ channel_ready_order,
8769
8785
}
8770
8786
}
8771
8787
@@ -9168,8 +9184,9 @@ where
9168
9184
// Short circuit the whole handler as there is nothing we can resend them
9169
9185
return Ok(ReestablishResponses {
9170
9186
channel_ready: None,
9187
+ channel_ready_order: ChannelReadyOrder::ChannelReadyFirst,
9171
9188
raa: None, commitment_update: None,
9172
- order : RAACommitmentOrder::CommitmentFirst,
9189
+ commitment_order : RAACommitmentOrder::CommitmentFirst,
9173
9190
shutdown_msg, announcement_sigs,
9174
9191
tx_signatures: None,
9175
9192
tx_abort: None,
@@ -9179,8 +9196,9 @@ where
9179
9196
// We have OurChannelReady set!
9180
9197
return Ok(ReestablishResponses {
9181
9198
channel_ready: self.get_channel_ready(logger),
9199
+ channel_ready_order: ChannelReadyOrder::ChannelReadyFirst,
9182
9200
raa: None, commitment_update: None,
9183
- order : RAACommitmentOrder::CommitmentFirst,
9201
+ commitment_order : RAACommitmentOrder::CommitmentFirst,
9184
9202
shutdown_msg, announcement_sigs,
9185
9203
tx_signatures: None,
9186
9204
tx_abort: None,
@@ -9306,10 +9324,13 @@ where
9306
9324
};
9307
9325
9308
9326
Ok(ReestablishResponses {
9309
- channel_ready, shutdown_msg, announcement_sigs,
9327
+ channel_ready,
9328
+ channel_ready_order: ChannelReadyOrder::SignaturesFirst,
9329
+ shutdown_msg,
9330
+ announcement_sigs,
9310
9331
raa: required_revoke,
9311
9332
commitment_update,
9312
- order : self.context.resend_order.clone(),
9333
+ commitment_order : self.context.resend_order.clone(),
9313
9334
tx_signatures,
9314
9335
tx_abort,
9315
9336
})
@@ -9323,9 +9344,11 @@ where
9323
9344
if self.context.channel_state.is_monitor_update_in_progress() {
9324
9345
self.context.monitor_pending_commitment_signed = true;
9325
9346
Ok(ReestablishResponses {
9326
- channel_ready, shutdown_msg, announcement_sigs,
9347
+ channel_ready,
9348
+ channel_ready_order: ChannelReadyOrder::ChannelReadyFirst,
9349
+ shutdown_msg, announcement_sigs,
9327
9350
commitment_update: None, raa: None,
9328
- order : self.context.resend_order.clone(),
9351
+ commitment_order : self.context.resend_order.clone(),
9329
9352
tx_signatures: None,
9330
9353
tx_abort: None,
9331
9354
})
@@ -9347,9 +9370,11 @@ where
9347
9370
required_revoke
9348
9371
};
9349
9372
Ok(ReestablishResponses {
9350
- channel_ready, shutdown_msg, announcement_sigs,
9373
+ channel_ready,
9374
+ channel_ready_order: ChannelReadyOrder::ChannelReadyFirst,
9375
+ shutdown_msg, announcement_sigs,
9351
9376
raa, commitment_update,
9352
- order : self.context.resend_order.clone(),
9377
+ commitment_order : self.context.resend_order.clone(),
9353
9378
tx_signatures: None,
9354
9379
tx_abort: None,
9355
9380
})
0 commit comments