X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fln%2Fchannel.rs;h=35aeb3e5540f7abf022b9015918571237726d493;hb=4fb5708eec5a0683039c7877a0b3d452e21735c9;hp=8cb5e9e1734bc6e18aa2b3304fa8532ab545b47a;hpb=4bd4f02fa7f60a5e90e5c016773afaec51f99746;p=rust-lightning diff --git a/lightning/src/ln/channel.rs b/lightning/src/ln/channel.rs index 8cb5e9e1..35aeb3e5 100644 --- a/lightning/src/ln/channel.rs +++ b/lightning/src/ln/channel.rs @@ -3835,6 +3835,17 @@ impl Channel { } } + /// Gets the `Shutdown` message we should send our peer on reconnect, if any. + pub fn get_outbound_shutdown(&self) -> Option { + if self.context.channel_state & (ChannelState::LocalShutdownSent as u32) != 0 { + assert!(self.context.shutdown_scriptpubkey.is_some()); + Some(msgs::Shutdown { + channel_id: self.context.channel_id, + scriptpubkey: self.get_closing_scriptpubkey(), + }) + } else { None } + } + /// May panic if some calls other than message-handling calls (which will all Err immediately) /// have been called between remove_uncommitted_htlcs_and_mark_paused and this call. /// @@ -3901,13 +3912,7 @@ impl Channel { self.context.channel_state &= !(ChannelState::PeerDisconnected as u32); self.context.sent_message_awaiting_response = None; - let shutdown_msg = if self.context.channel_state & (ChannelState::LocalShutdownSent as u32) != 0 { - assert!(self.context.shutdown_scriptpubkey.is_some()); - Some(msgs::Shutdown { - channel_id: self.context.channel_id, - scriptpubkey: self.get_closing_scriptpubkey(), - }) - } else { None }; + let shutdown_msg = self.get_outbound_shutdown(); let announcement_sigs = self.get_announcement_sigs(node_signer, genesis_block_hash, user_config, best_block.height(), logger);