Skip to content

Commit b161cba

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

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
}
@@ -7751,7 +7751,7 @@ where
77517751

77527752
if is_monitor_update_in_progress {
77537753
log_debug!(logger, "Not sending tx_signatures: a monitor update is in progress. Setting monitor_pending_tx_signatures.");
7754-
self.context.monitor_pending_tx_signatures = Some(holder_tx_signatures);
7754+
self.context.monitor_pending_tx_signatures = true;
77557755
return Ok(None);
77567756
}
77577757
return Ok(Some(holder_tx_signatures));
@@ -7829,7 +7829,7 @@ where
78297829
// and sets it as pending.
78307830
if holder_tx_signatures_opt.is_some() && self.is_awaiting_initial_mon_persist() {
78317831
log_debug!(logger, "Not sending tx_signatures: a monitor update is in progress. Setting monitor_pending_tx_signatures.");
7832-
self.context.monitor_pending_tx_signatures = holder_tx_signatures_opt;
7832+
self.context.monitor_pending_tx_signatures = true;
78337833
return Ok((None, None));
78347834
}
78357835

@@ -8088,14 +8088,14 @@ where
80888088
// For channels established with V2 establishment we won't send a `tx_signatures` when we're in
80898089
// MonitorUpdateInProgress (and we assume the user will never directly broadcast the funding
80908090
// transaction and waits for us to do it).
8091-
let tx_signatures = self.context.monitor_pending_tx_signatures.take();
8092-
if tx_signatures.is_some() {
8091+
let tx_signatures = if self.context.monitor_pending_tx_signatures {
80938092
if self.context.channel_state.is_their_tx_signatures_sent() {
80948093
self.context.channel_state = ChannelState::AwaitingChannelReady(AwaitingChannelReadyFlags::new());
80958094
} else {
80968095
self.context.channel_state.set_our_tx_signatures_ready();
80978096
}
8098-
}
8097+
self.interactive_tx_signing_session.as_ref().and_then(|session| session.holder_tx_signatures().clone())
8098+
} else { None };
80998099

81008100
if self.context.channel_state.is_peer_disconnected() {
81018101
self.context.monitor_pending_revoke_and_ack = false;
@@ -8591,11 +8591,9 @@ where
85918591
if self.context.channel_state.is_monitor_update_in_progress() {
85928592
// The `monitor_pending_tx_signatures` field should have already been set in `commitment_signed_initial_v2`
85938593
// if we were up first for signing and had a monitor update in progress, but check again just in case.
8594-
debug_assert!(self.context.monitor_pending_tx_signatures.is_some(), "monitor_pending_tx_signatures should already be set");
8594+
debug_assert!(self.context.monitor_pending_tx_signatures, "monitor_pending_tx_signatures should already be set");
85958595
log_debug!(logger, "Not sending tx_signatures: a monitor update is in progress. Setting monitor_pending_tx_signatures.");
8596-
if self.context.monitor_pending_tx_signatures.is_none() {
8597-
self.context.monitor_pending_tx_signatures = session.holder_tx_signatures().clone();
8598-
}
8596+
self.context.monitor_pending_tx_signatures = true;
85998597
None
86008598
} else {
86018599
// If `holder_tx_signatures` is `None` here, the `tx_signatures` message will be sent
@@ -13355,7 +13353,7 @@ where
1335513353
monitor_pending_failures,
1335613354
monitor_pending_finalized_fulfills: monitor_pending_finalized_fulfills.unwrap(),
1335713355
monitor_pending_update_adds: monitor_pending_update_adds.unwrap_or_default(),
13358-
monitor_pending_tx_signatures: None,
13356+
monitor_pending_tx_signatures: false,
1335913357

1336013358
signer_pending_revoke_and_ack: false,
1336113359
signer_pending_commitment_update: false,

0 commit comments

Comments
 (0)