Skip to content

Commit 3a67c81

Browse files
committed
Drop unreachable shutdown code in Channel::get_shutdown
`Channel` is only a thing for funded channels. Thus, checking if a channel has not yet been funded is dead code and can simply be elided.
1 parent d2242f6 commit 3a67c81

File tree

1 file changed

+2
-17
lines changed

1 file changed

+2
-17
lines changed

lightning/src/ln/channel.rs

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5583,9 +5583,6 @@ impl<SP: Deref> Channel<SP> where
55835583

55845584
/// Begins the shutdown process, getting a message for the remote peer and returning all
55855585
/// holding cell HTLCs for payment failure.
5586-
///
5587-
/// May jump to the channel being fully shutdown (see [`Self::is_shutdown`]) in which case no
5588-
/// [`ChannelMonitorUpdate`] will be returned).
55895586
pub fn get_shutdown(&mut self, signer_provider: &SP, their_features: &InitFeatures,
55905587
target_feerate_sats_per_kw: Option<u32>, override_shutdown_script: Option<ShutdownScript>)
55915588
-> Result<(msgs::Shutdown, Option<ChannelMonitorUpdate>, Vec<(HTLCSource, PaymentHash)>), APIError>
@@ -5611,16 +5608,9 @@ impl<SP: Deref> Channel<SP> where
56115608
return Err(APIError::ChannelUnavailable{err: "Cannot begin shutdown while peer is disconnected or we're waiting on a monitor update, maybe force-close instead?".to_owned()});
56125609
}
56135610

5614-
// If we haven't funded the channel yet, we don't need to bother ensuring the shutdown
5615-
// script is set, we just force-close and call it a day.
5616-
let mut chan_closed = false;
5617-
if self.context.channel_state & !STATE_FLAGS < ChannelState::FundingSent as u32 {
5618-
chan_closed = true;
5619-
}
5620-
56215611
let update_shutdown_script = match self.context.shutdown_scriptpubkey {
56225612
Some(_) => false,
5623-
None if !chan_closed => {
5613+
None => {
56245614
// use override shutdown script if provided
56255615
let shutdown_scriptpubkey = match override_shutdown_script {
56265616
Some(script) => script,
@@ -5638,16 +5628,11 @@ impl<SP: Deref> Channel<SP> where
56385628
self.context.shutdown_scriptpubkey = Some(shutdown_scriptpubkey);
56395629
true
56405630
},
5641-
None => false,
56425631
};
56435632

56445633
// From here on out, we may not fail!
56455634
self.context.target_closing_feerate_sats_per_kw = target_feerate_sats_per_kw;
5646-
if self.context.channel_state & !STATE_FLAGS < ChannelState::FundingSent as u32 {
5647-
self.context.channel_state = ChannelState::ShutdownComplete as u32;
5648-
} else {
5649-
self.context.channel_state |= ChannelState::LocalShutdownSent as u32;
5650-
}
5635+
self.context.channel_state |= ChannelState::LocalShutdownSent as u32;
56515636
self.context.update_time_counter += 1;
56525637

56535638
let monitor_update = if update_shutdown_script {

0 commit comments

Comments
 (0)