// We track whether we already emitted a `ChannelReady` event.
channel_ready_event_emitted: bool,
+ /// Some if we initiated to shut down the channel.
+ local_initiated_shutdown: Option<()>,
+
/// The unique identifier used to re-derive the private key material for the channel through
/// [`SignerProvider::derive_channel_signer`].
channel_keys_id: [u8; 32],
}
}
+ let closure_reason = if self.initiated_shutdown() {
+ ClosureReason::LocallyInitiatedCooperativeClosure
+ } else {
+ ClosureReason::CounterpartyInitiatedCooperativeClosure
+ };
+
assert!(self.context.shutdown_scriptpubkey.is_some());
if let Some((last_fee, sig)) = self.context.last_sent_closing_fee {
if last_fee == msg.fee_satoshis {
let shutdown_result = ShutdownResult {
- closure_reason: ClosureReason::CooperativeClosure,
+ closure_reason,
monitor_update: None,
dropped_outbound_htlcs: Vec::new(),
unbroadcasted_batch_funding_txid: self.context.unbroadcasted_batch_funding_txid(),
.map_err(|_| ChannelError::Close("External signer refused to sign closing transaction".to_owned()))?;
let (signed_tx, shutdown_result) = if $new_fee == msg.fee_satoshis {
let shutdown_result = ShutdownResult {
- closure_reason: ClosureReason::CooperativeClosure,
+ closure_reason,
monitor_update: None,
dropped_outbound_htlcs: Vec::new(),
unbroadcasted_batch_funding_txid: self.context.unbroadcasted_batch_funding_txid(),
self.context.channel_state.is_local_shutdown_sent()
}
+ /// Returns true if we initiated to shut down the channel.
+ pub fn initiated_shutdown(&self) -> bool {
+ self.context.local_initiated_shutdown.is_some()
+ }
+
/// Returns true if this channel is fully shut down. True here implies that no further actions
/// may/will be taken on this channel, and thus this object should be freed. Any future changes
/// will be handled appropriately by the chain monitor.
// From here on out, we may not fail!
self.context.target_closing_feerate_sats_per_kw = target_feerate_sats_per_kw;
self.context.channel_state.set_local_shutdown_sent();
+ self.context.local_initiated_shutdown = Some(());
self.context.update_time_counter += 1;
let monitor_update = if update_shutdown_script {
channel_keys_id,
blocked_monitor_updates: Vec::new(),
+ local_initiated_shutdown: None,
},
unfunded_context: UnfundedChannelContext { unfunded_channel_age_ticks: 0 }
})
channel_type,
channel_keys_id,
+ local_initiated_shutdown: None,
+
blocked_monitor_updates: Vec::new(),
},
unfunded_context: UnfundedChannelContext { unfunded_channel_age_ticks: 0 }
(39, pending_outbound_blinding_points, optional_vec),
(41, holding_cell_blinding_points, optional_vec),
(43, malformed_htlcs, optional_vec), // Added in 0.0.119
+ (45, self.context.local_initiated_shutdown, option), // Added in 0.0.122
});
Ok(())
let mut is_batch_funding: Option<()> = None;
+ let mut local_initiated_shutdown: Option<()> = None;
+
let mut pending_outbound_blinding_points_opt: Option<Vec<Option<PublicKey>>> = None;
let mut holding_cell_blinding_points_opt: Option<Vec<Option<PublicKey>>> = None;
(39, pending_outbound_blinding_points_opt, optional_vec),
(41, holding_cell_blinding_points_opt, optional_vec),
(43, malformed_htlcs, optional_vec), // Added in 0.0.119
+ (45, local_initiated_shutdown, option),
});
let (channel_keys_id, holder_signer) = if let Some(channel_keys_id) = channel_keys_id {
channel_type: channel_type.unwrap(),
channel_keys_id,
+ local_initiated_shutdown,
+
blocked_monitor_updates: blocked_monitor_updates.unwrap(),
}
})