Skip to content

Commit 58b5381

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

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
}
@@ -7826,7 +7826,7 @@ where
78267826

78277827
if is_monitor_update_in_progress {
78287828
log_debug!(logger, "Not sending tx_signatures: a monitor update is in progress. Setting monitor_pending_tx_signatures.");
7829-
self.context.monitor_pending_tx_signatures = Some(holder_tx_signatures);
7829+
self.context.monitor_pending_tx_signatures = true;
78307830
return Ok(None);
78317831
}
78327832
return Ok(Some(holder_tx_signatures));
@@ -7904,7 +7904,7 @@ where
79047904
// and sets it as pending.
79057905
if holder_tx_signatures_opt.is_some() && self.is_awaiting_initial_mon_persist() {
79067906
log_debug!(logger, "Not sending tx_signatures: a monitor update is in progress. Setting monitor_pending_tx_signatures.");
7907-
self.context.monitor_pending_tx_signatures = holder_tx_signatures_opt;
7907+
self.context.monitor_pending_tx_signatures = true;
79087908
return Ok((None, None));
79097909
}
79107910

@@ -8163,14 +8163,14 @@ where
81638163
// For channels established with V2 establishment we won't send a `tx_signatures` when we're in
81648164
// MonitorUpdateInProgress (and we assume the user will never directly broadcast the funding
81658165
// transaction and waits for us to do it).
8166-
let tx_signatures = self.context.monitor_pending_tx_signatures.take();
8167-
if tx_signatures.is_some() {
8166+
let tx_signatures = if self.context.monitor_pending_tx_signatures {
81688167
if self.context.channel_state.is_their_tx_signatures_sent() {
81698168
self.context.channel_state = ChannelState::AwaitingChannelReady(AwaitingChannelReadyFlags::new());
81708169
} else {
81718170
self.context.channel_state.set_our_tx_signatures_ready();
81728171
}
8173-
}
8172+
self.interactive_tx_signing_session.as_ref().and_then(|session| session.holder_tx_signatures().clone())
8173+
} else { None };
81748174

81758175
if self.context.channel_state.is_peer_disconnected() {
81768176
self.context.monitor_pending_revoke_and_ack = false;
@@ -8666,11 +8666,9 @@ where
86668666
if self.context.channel_state.is_monitor_update_in_progress() {
86678667
// The `monitor_pending_tx_signatures` field should have already been set in `commitment_signed_initial_v2`
86688668
// if we were up first for signing and had a monitor update in progress, but check again just in case.
8669-
debug_assert!(self.context.monitor_pending_tx_signatures.is_some(), "monitor_pending_tx_signatures should already be set");
8669+
debug_assert!(self.context.monitor_pending_tx_signatures, "monitor_pending_tx_signatures should already be set");
86708670
log_debug!(logger, "Not sending tx_signatures: a monitor update is in progress. Setting monitor_pending_tx_signatures.");
8671-
if self.context.monitor_pending_tx_signatures.is_none() {
8672-
self.context.monitor_pending_tx_signatures = session.holder_tx_signatures().clone();
8673-
}
8671+
self.context.monitor_pending_tx_signatures = true;
86748672
None
86758673
} else {
86768674
// If `holder_tx_signatures` is `None` here, the `tx_signatures` message will be sent
@@ -13430,7 +13428,7 @@ where
1343013428
monitor_pending_failures,
1343113429
monitor_pending_finalized_fulfills: monitor_pending_finalized_fulfills.unwrap(),
1343213430
monitor_pending_update_adds: monitor_pending_update_adds.unwrap_or_default(),
13433-
monitor_pending_tx_signatures: None,
13431+
monitor_pending_tx_signatures: false,
1343413432

1343513433
signer_pending_revoke_and_ack: false,
1343613434
signer_pending_commitment_update: false,

0 commit comments

Comments
 (0)