Skip to content

Commit ca2d5e0

Browse files
committed
Use bool for monitor_pending_tx_signatures over Option<TxSignatures>
We directly get the holder `TxSignatures` when necessary.
1 parent 417230a commit ca2d5e0

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

lightning/src/ln/channel.rs

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2354,7 +2354,7 @@ where
23542354
monitor_pending_failures: Vec<(HTLCSource, PaymentHash, HTLCFailReason)>,
23552355
monitor_pending_finalized_fulfills: Vec<HTLCSource>,
23562356
monitor_pending_update_adds: Vec<msgs::UpdateAddHTLC>,
2357-
monitor_pending_tx_signatures: Option<msgs::TxSignatures>,
2357+
monitor_pending_tx_signatures: bool,
23582358

23592359
/// If we went to send a revoke_and_ack but our signer was unable to give us a signature,
23602360
/// we should retry at some point in the future when the signer indicates it may have a
@@ -3297,7 +3297,7 @@ where
32973297
monitor_pending_failures: Vec::new(),
32983298
monitor_pending_finalized_fulfills: Vec::new(),
32993299
monitor_pending_update_adds: Vec::new(),
3300-
monitor_pending_tx_signatures: None,
3300+
monitor_pending_tx_signatures: false,
33013301

33023302
signer_pending_revoke_and_ack: false,
33033303
signer_pending_commitment_update: false,
@@ -3543,7 +3543,7 @@ where
35433543
monitor_pending_failures: Vec::new(),
35443544
monitor_pending_finalized_fulfills: Vec::new(),
35453545
monitor_pending_update_adds: Vec::new(),
3546-
monitor_pending_tx_signatures: None,
3546+
monitor_pending_tx_signatures: false,
35473547

35483548
signer_pending_revoke_and_ack: false,
35493549
signer_pending_commitment_update: false,
@@ -6687,12 +6687,12 @@ where
66876687

66886688
self.monitor_updating_paused(false, false, false, Vec::new(), Vec::new(), Vec::new());
66896689

6690-
if let Some(tx_signatures) = self.interactive_tx_signing_session.as_mut().and_then(
6690+
if let Some(_) = self.interactive_tx_signing_session.as_mut().and_then(
66916691
|session| session.received_commitment_signed()
66926692
) {
66936693
// We're up first for submitting our tx_signatures, but our monitor has not persisted yet
66946694
// so they'll be sent as soon as that's done.
6695-
self.context.monitor_pending_tx_signatures = Some(tx_signatures);
6695+
self.context.monitor_pending_tx_signatures = true;
66966696
}
66976697
// Only build the unsigned transaction for signing if there are any holder inputs to actually sign
66986698
let funding_tx_opt = self.interactive_tx_signing_session.as_ref().and_then(|session|
@@ -6785,7 +6785,7 @@ where
67856785
.expect("Signing session must exist for negotiated pending splice")
67866786
.received_commitment_signed();
67876787
self.monitor_updating_paused(false, false, false, Vec::new(), Vec::new(), Vec::new());
6788-
self.context.monitor_pending_tx_signatures = tx_signatures;
6788+
self.context.monitor_pending_tx_signatures = tx_signatures.is_some();
67896789

67906790
Ok(self.push_ret_blockable_mon_update(monitor_update))
67916791
}
@@ -7655,7 +7655,7 @@ where
76557655

76567656
if is_monitor_update_in_progress {
76577657
log_debug!(logger, "Not sending tx_signatures: a monitor update is in progress. Setting monitor_pending_tx_signatures.");
7658-
self.context.monitor_pending_tx_signatures = Some(holder_tx_signatures);
7658+
self.context.monitor_pending_tx_signatures = true;
76597659
return Ok(None);
76607660
}
76617661
return Ok(Some(holder_tx_signatures));
@@ -7733,7 +7733,7 @@ where
77337733
// and sets it as pending.
77347734
if holder_tx_signatures_opt.is_some() && self.is_awaiting_initial_mon_persist() {
77357735
log_debug!(logger, "Not sending tx_signatures: a monitor update is in progress. Setting monitor_pending_tx_signatures.");
7736-
self.context.monitor_pending_tx_signatures = holder_tx_signatures_opt;
7736+
self.context.monitor_pending_tx_signatures = true;
77377737
return Ok((None, None));
77387738
}
77397739

@@ -7992,14 +7992,14 @@ where
79927992
// For channels established with V2 establishment we won't send a `tx_signatures` when we're in
79937993
// MonitorUpdateInProgress (and we assume the user will never directly broadcast the funding
79947994
// transaction and waits for us to do it).
7995-
let tx_signatures = self.context.monitor_pending_tx_signatures.take();
7996-
if tx_signatures.is_some() {
7995+
let tx_signatures = if self.context.monitor_pending_tx_signatures {
79977996
if self.context.channel_state.is_their_tx_signatures_sent() {
79987997
self.context.channel_state = ChannelState::AwaitingChannelReady(AwaitingChannelReadyFlags::new());
79997998
} else {
80007999
self.context.channel_state.set_our_tx_signatures_ready();
80018000
}
8002-
}
8001+
self.interactive_tx_signing_session.as_ref().and_then(|session| session.holder_tx_signatures().clone())
8002+
} else { None };
80038003

80048004
if self.context.channel_state.is_peer_disconnected() {
80058005
self.context.monitor_pending_revoke_and_ack = false;
@@ -8495,11 +8495,9 @@ where
84958495
if self.context.channel_state.is_monitor_update_in_progress() {
84968496
// The `monitor_pending_tx_signatures` field should have already been set in `commitment_signed_initial_v2`
84978497
// if we were up first for signing and had a monitor update in progress, but check again just in case.
8498-
debug_assert!(self.context.monitor_pending_tx_signatures.is_some(), "monitor_pending_tx_signatures should already be set");
8498+
debug_assert!(self.context.monitor_pending_tx_signatures, "monitor_pending_tx_signatures should already be set");
84998499
log_debug!(logger, "Not sending tx_signatures: a monitor update is in progress. Setting monitor_pending_tx_signatures.");
8500-
if self.context.monitor_pending_tx_signatures.is_none() {
8501-
self.context.monitor_pending_tx_signatures = session.holder_tx_signatures().clone();
8502-
}
8500+
self.context.monitor_pending_tx_signatures = true;
85038501
None
85048502
} else {
85058503
// If `holder_tx_signatures` is `None` here, the `tx_signatures` message will be sent
@@ -13265,7 +13263,7 @@ where
1326513263
monitor_pending_failures,
1326613264
monitor_pending_finalized_fulfills: monitor_pending_finalized_fulfills.unwrap(),
1326713265
monitor_pending_update_adds: monitor_pending_update_adds.unwrap_or_default(),
13268-
monitor_pending_tx_signatures: None,
13266+
monitor_pending_tx_signatures: false,
1326913267

1327013268
signer_pending_revoke_and_ack: false,
1327113269
signer_pending_commitment_update: false,

0 commit comments

Comments
 (0)