Skip to content

Commit 1ab3286

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

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
@@ -2315,7 +2315,7 @@ where
23152315
monitor_pending_failures: Vec<(HTLCSource, PaymentHash, HTLCFailReason)>,
23162316
monitor_pending_finalized_fulfills: Vec<HTLCSource>,
23172317
monitor_pending_update_adds: Vec<msgs::UpdateAddHTLC>,
2318-
monitor_pending_tx_signatures: Option<msgs::TxSignatures>,
2318+
monitor_pending_tx_signatures: bool,
23192319

23202320
/// If we went to send a revoke_and_ack but our signer was unable to give us a signature,
23212321
/// we should retry at some point in the future when the signer indicates it may have a
@@ -3258,7 +3258,7 @@ where
32583258
monitor_pending_failures: Vec::new(),
32593259
monitor_pending_finalized_fulfills: Vec::new(),
32603260
monitor_pending_update_adds: Vec::new(),
3261-
monitor_pending_tx_signatures: None,
3261+
monitor_pending_tx_signatures: false,
32623262

32633263
signer_pending_revoke_and_ack: false,
32643264
signer_pending_commitment_update: false,
@@ -3504,7 +3504,7 @@ where
35043504
monitor_pending_failures: Vec::new(),
35053505
monitor_pending_finalized_fulfills: Vec::new(),
35063506
monitor_pending_update_adds: Vec::new(),
3507-
monitor_pending_tx_signatures: None,
3507+
monitor_pending_tx_signatures: false,
35083508

35093509
signer_pending_revoke_and_ack: false,
35103510
signer_pending_commitment_update: false,
@@ -6648,12 +6648,12 @@ where
66486648

66496649
self.monitor_updating_paused(false, false, false, Vec::new(), Vec::new(), Vec::new());
66506650

6651-
if let Some(tx_signatures) = self.interactive_tx_signing_session.as_mut().and_then(
6651+
if let Some(_) = self.interactive_tx_signing_session.as_mut().and_then(
66526652
|session| session.received_commitment_signed()
66536653
) {
66546654
// We're up first for submitting our tx_signatures, but our monitor has not persisted yet
66556655
// so they'll be sent as soon as that's done.
6656-
self.context.monitor_pending_tx_signatures = Some(tx_signatures);
6656+
self.context.monitor_pending_tx_signatures = true;
66576657
}
66586658
// Only build the unsigned transaction for signing if there are any holder inputs to actually sign
66596659
let funding_tx_opt = self.interactive_tx_signing_session.as_ref().and_then(|session|
@@ -6746,7 +6746,7 @@ where
67466746
.expect("Signing session must exist for negotiated pending splice")
67476747
.received_commitment_signed();
67486748
self.monitor_updating_paused(false, false, false, Vec::new(), Vec::new(), Vec::new());
6749-
self.context.monitor_pending_tx_signatures = tx_signatures;
6749+
self.context.monitor_pending_tx_signatures = tx_signatures.is_some();
67506750

67516751
Ok(self.push_ret_blockable_mon_update(monitor_update))
67526752
}
@@ -7664,7 +7664,7 @@ where
76647664

76657665
if is_monitor_update_in_progress {
76667666
log_debug!(logger, "Not sending tx_signatures: a monitor update is in progress. Setting monitor_pending_tx_signatures.");
7667-
self.context.monitor_pending_tx_signatures = Some(holder_tx_signatures);
7667+
self.context.monitor_pending_tx_signatures = true;
76687668
return Ok(None);
76697669
}
76707670
return Ok(Some(holder_tx_signatures));
@@ -7742,7 +7742,7 @@ where
77427742
// and sets it as pending.
77437743
if holder_tx_signatures_opt.is_some() && self.is_awaiting_initial_mon_persist() {
77447744
log_debug!(logger, "Not sending tx_signatures: a monitor update is in progress. Setting monitor_pending_tx_signatures.");
7745-
self.context.monitor_pending_tx_signatures = holder_tx_signatures_opt;
7745+
self.context.monitor_pending_tx_signatures = true;
77467746
return Ok((None, None));
77477747
}
77487748

@@ -8001,14 +8001,14 @@ where
80018001
// For channels established with V2 establishment we won't send a `tx_signatures` when we're in
80028002
// MonitorUpdateInProgress (and we assume the user will never directly broadcast the funding
80038003
// transaction and waits for us to do it).
8004-
let tx_signatures = self.context.monitor_pending_tx_signatures.take();
8005-
if tx_signatures.is_some() {
8004+
let tx_signatures = if self.context.monitor_pending_tx_signatures {
80068005
if self.context.channel_state.is_their_tx_signatures_sent() {
80078006
self.context.channel_state = ChannelState::AwaitingChannelReady(AwaitingChannelReadyFlags::new());
80088007
} else {
80098008
self.context.channel_state.set_our_tx_signatures_ready();
80108009
}
8011-
}
8010+
self.interactive_tx_signing_session.as_ref().and_then(|session| session.holder_tx_signatures().clone())
8011+
} else { None };
80128012

80138013
if self.context.channel_state.is_peer_disconnected() {
80148014
self.context.monitor_pending_revoke_and_ack = false;
@@ -8504,11 +8504,9 @@ where
85048504
if self.context.channel_state.is_monitor_update_in_progress() {
85058505
// The `monitor_pending_tx_signatures` field should have already been set in `commitment_signed_initial_v2`
85068506
// if we were up first for signing and had a monitor update in progress, but check again just in case.
8507-
debug_assert!(self.context.monitor_pending_tx_signatures.is_some(), "monitor_pending_tx_signatures should already be set");
8507+
debug_assert!(self.context.monitor_pending_tx_signatures, "monitor_pending_tx_signatures should already be set");
85088508
log_debug!(logger, "Not sending tx_signatures: a monitor update is in progress. Setting monitor_pending_tx_signatures.");
8509-
if self.context.monitor_pending_tx_signatures.is_none() {
8510-
self.context.monitor_pending_tx_signatures = session.holder_tx_signatures().clone();
8511-
}
8509+
self.context.monitor_pending_tx_signatures = true;
85128510
None
85138511
} else {
85148512
// If `holder_tx_signatures` is `None` here, the `tx_signatures` message will be sent
@@ -13268,7 +13266,7 @@ where
1326813266
monitor_pending_failures,
1326913267
monitor_pending_finalized_fulfills: monitor_pending_finalized_fulfills.unwrap(),
1327013268
monitor_pending_update_adds: monitor_pending_update_adds.unwrap_or_default(),
13271-
monitor_pending_tx_signatures: None,
13269+
monitor_pending_tx_signatures: false,
1327213270

1327313271
signer_pending_revoke_and_ack: false,
1327413272
signer_pending_commitment_update: false,

0 commit comments

Comments
 (0)