Skip to content

Commit a9e1a3a

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

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
@@ -2317,7 +2317,7 @@ where
23172317
monitor_pending_failures: Vec<(HTLCSource, PaymentHash, HTLCFailReason)>,
23182318
monitor_pending_finalized_fulfills: Vec<HTLCSource>,
23192319
monitor_pending_update_adds: Vec<msgs::UpdateAddHTLC>,
2320-
monitor_pending_tx_signatures: Option<msgs::TxSignatures>,
2320+
monitor_pending_tx_signatures: bool,
23212321

23222322
/// If we went to send a revoke_and_ack but our signer was unable to give us a signature,
23232323
/// we should retry at some point in the future when the signer indicates it may have a
@@ -3275,7 +3275,7 @@ where
32753275
monitor_pending_failures: Vec::new(),
32763276
monitor_pending_finalized_fulfills: Vec::new(),
32773277
monitor_pending_update_adds: Vec::new(),
3278-
monitor_pending_tx_signatures: None,
3278+
monitor_pending_tx_signatures: false,
32793279

32803280
signer_pending_revoke_and_ack: false,
32813281
signer_pending_commitment_update: false,
@@ -3521,7 +3521,7 @@ where
35213521
monitor_pending_failures: Vec::new(),
35223522
monitor_pending_finalized_fulfills: Vec::new(),
35233523
monitor_pending_update_adds: Vec::new(),
3524-
monitor_pending_tx_signatures: None,
3524+
monitor_pending_tx_signatures: false,
35253525

35263526
signer_pending_revoke_and_ack: false,
35273527
signer_pending_commitment_update: false,
@@ -6654,12 +6654,12 @@ where
66546654

66556655
self.monitor_updating_paused(false, false, false, Vec::new(), Vec::new(), Vec::new());
66566656

6657-
if let Some(tx_signatures) = self.interactive_tx_signing_session.as_mut().and_then(
6657+
if let Some(_) = self.interactive_tx_signing_session.as_mut().and_then(
66586658
|session| session.received_commitment_signed()
66596659
) {
66606660
// We're up first for submitting our tx_signatures, but our monitor has not persisted yet
66616661
// so they'll be sent as soon as that's done.
6662-
self.context.monitor_pending_tx_signatures = Some(tx_signatures);
6662+
self.context.monitor_pending_tx_signatures = true;
66636663
}
66646664
// Only build the unsigned transaction for signing if there are any holder inputs to actually sign
66656665
let funding_tx_opt = self.interactive_tx_signing_session.as_ref().and_then(|session|
@@ -6752,7 +6752,7 @@ where
67526752
.expect("Signing session must exist for negotiated pending splice")
67536753
.received_commitment_signed();
67546754
self.monitor_updating_paused(false, false, false, Vec::new(), Vec::new(), Vec::new());
6755-
self.context.monitor_pending_tx_signatures = tx_signatures;
6755+
self.context.monitor_pending_tx_signatures = tx_signatures.is_some();
67566756

67576757
Ok(self.push_ret_blockable_mon_update(monitor_update))
67586758
}
@@ -7606,7 +7606,7 @@ where
76067606
{
76077607
if self.is_awaiting_initial_mon_persist() {
76087608
log_debug!(logger, "Not sending tx_signatures: a monitor update is in progress. Setting monitor_pending_tx_signatures.");
7609-
self.context.monitor_pending_tx_signatures = Some(holder_tx_signatures);
7609+
self.context.monitor_pending_tx_signatures = true;
76107610
return Ok(None);
76117611
}
76127612
return Ok(Some(holder_tx_signatures));
@@ -7685,7 +7685,7 @@ where
76857685
// and sets it as pending.
76867686
if holder_tx_signatures_opt.is_some() && self.is_awaiting_initial_mon_persist() {
76877687
log_debug!(logger, "Not sending tx_signatures: a monitor update is in progress. Setting monitor_pending_tx_signatures.");
7688-
self.context.monitor_pending_tx_signatures = holder_tx_signatures_opt;
7688+
self.context.monitor_pending_tx_signatures = true;
76897689
return Ok((None, None));
76907690
}
76917691

@@ -7944,14 +7944,14 @@ where
79447944
// For channels established with V2 establishment we won't send a `tx_signatures` when we're in
79457945
// MonitorUpdateInProgress (and we assume the user will never directly broadcast the funding
79467946
// transaction and waits for us to do it).
7947-
let tx_signatures = self.context.monitor_pending_tx_signatures.take();
7948-
if tx_signatures.is_some() {
7947+
let tx_signatures = if self.context.monitor_pending_tx_signatures {
79497948
if self.context.channel_state.is_their_tx_signatures_sent() {
79507949
self.context.channel_state = ChannelState::AwaitingChannelReady(AwaitingChannelReadyFlags::new());
79517950
} else {
79527951
self.context.channel_state.set_our_tx_signatures_ready();
79537952
}
7954-
}
7953+
self.interactive_tx_signing_session.as_ref().and_then(|session| session.holder_tx_signatures().clone())
7954+
} else { None };
79557955

79567956
if self.context.channel_state.is_peer_disconnected() {
79577957
self.context.monitor_pending_revoke_and_ack = false;
@@ -8453,11 +8453,9 @@ where
84538453
if self.context.channel_state.is_monitor_update_in_progress() {
84548454
// The `monitor_pending_tx_signatures` field should have already been set in `commitment_signed_initial_v2`
84558455
// if we were up first for signing and had a monitor update in progress, but check again just in case.
8456-
debug_assert!(self.context.monitor_pending_tx_signatures.is_some(), "monitor_pending_tx_signatures should already be set");
8456+
debug_assert!(self.context.monitor_pending_tx_signatures, "monitor_pending_tx_signatures should already be set");
84578457
log_debug!(logger, "Not sending tx_signatures: a monitor update is in progress. Setting monitor_pending_tx_signatures.");
8458-
if self.context.monitor_pending_tx_signatures.is_none() {
8459-
self.context.monitor_pending_tx_signatures = session.holder_tx_signatures().clone();
8460-
}
8458+
self.context.monitor_pending_tx_signatures = true;
84618459
None
84628460
} else {
84638461
// If `holder_tx_signatures` is `None` here, the `tx_signatures` message will be sent
@@ -13208,7 +13206,7 @@ where
1320813206
monitor_pending_failures,
1320913207
monitor_pending_finalized_fulfills: monitor_pending_finalized_fulfills.unwrap(),
1321013208
monitor_pending_update_adds: monitor_pending_update_adds.unwrap_or_default(),
13211-
monitor_pending_tx_signatures: None,
13209+
monitor_pending_tx_signatures: false,
1321213210

1321313211
signer_pending_revoke_and_ack: false,
1321413212
signer_pending_commitment_update: false,

0 commit comments

Comments
 (0)