struct MsgHandleErrInternal {
err: msgs::LightningError,
- chan_id: Option<[u8; 32]>,
+ chan_id: Option<[u8; 32]>, // If Some a channel of ours has been closed
shutdown_finish: Option<(ShutdownResult, Option<msgs::ChannelUpdate>)>,
}
impl MsgHandleErrInternal {
msg: channel_update
});
}
+ if let Ok(mut pending_events_lock) = self.pending_events.lock() {
+ pending_events_lock.push(events::Event::ChannelClosed {
+ channel_id: *channel_id,
+ reason: ClosureReason::HolderForceClosed
+ });
+ }
}
break Ok(());
},
});
}
+ if let Ok(mut pending_events_lock) = self.pending_events.lock() {
+ pending_events_lock.push(events::Event::ChannelClosed {
+ channel_id: *channel_id,
+ reason: ClosureReason::HolderForceClosed
+ });
+ }
+
log_info!(self.logger, "Broadcasting {}", log_tx!(tx));
self.tx_broadcaster.broadcast_transaction(&tx);
false
let mut funding_txo_set = HashSet::with_capacity(cmp::min(channel_count as usize, 128));
let mut by_id = HashMap::with_capacity(cmp::min(channel_count as usize, 128));
let mut short_to_id = HashMap::with_capacity(cmp::min(channel_count as usize, 128));
+ let mut channel_closures = Vec::new();
for _ in 0..channel_count {
let mut channel: Channel<Signer> = Channel::read(reader, &args.keys_manager)?;
let funding_txo = channel.get_funding_txo().ok_or(DecodeError::InvalidValue)?;
let (_, mut new_failed_htlcs) = channel.force_shutdown(true);
failed_htlcs.append(&mut new_failed_htlcs);
monitor.broadcast_latest_holder_commitment_txn(&args.tx_broadcaster, &args.logger);
+ channel_closures.push(events::Event::ChannelClosed {
+ channel_id: channel.channel_id(),
+ reason: ClosureReason::OutdatedChanMan
+ });
} else {
if let Some(short_channel_id) = channel.get_short_channel_id() {
short_to_id.insert(short_channel_id, channel.channel_id());
let mut secp_ctx = Secp256k1::new();
secp_ctx.seeded_randomize(&args.keys_manager.get_secure_random_bytes());
+ if !channel_closures.is_empty() {
+ pending_events_read.append(&mut channel_closures);
+ }
+
let channel_manager = ChannelManager {
genesis_hash,
fee_estimator: args.fee_estimator,
/// The reason which the channel was closed. See individual variants more details.
pub enum ClosureReason {
/// Closure generated from receiving a peer error message.
+ ///
+ /// Our counterparty may have broadcasted their latest commitment state, and we have
+ /// as well
CounterpartyForceClosed {
/// The error which the peer sent us.
///
/// The string should be sanitized before it is used (e.g emitted to logs
- /// or printed to stdout). Otherwise, a well crafted error message may trigger
- /// a security in the terminal emulator or the logging subsystem.
+ /// or printed to stdout). Otherwise, a well crafted error message may exploit
+ /// a security vulnerability in the terminal emulator or the logging subsystem.
peer_msg: String,
},
/// Closure generated from [`ChannelManager::force_close_channel`], called by the user.
err: String,
},
/// The `PeerManager` informed us that we've disconnected from the peer and that it is
- /// unlikely we'll be able to connect to the peer, most likely because we have incompatible
- /// features and the peer, or we, require features which we, or the peer, do not support.
+ /// unlikely we'll be able to connect to the peer.
DisconnectedPeer,
+ /// Closure generated from [`ChannelManager::read`] if the ChannelMonitor is newer than
+ /// the ChannelManager deserialized.
+ OutdatedChanMan
}
impl_writeable_tlv_based_enum_upgradable!(ClosureReason,
(4, CooperativeClosure) => {},
(8, ProcessingError) => { (1, err, required) },
(10, DisconnectedPeer) => {},
+ (12, OutdatedChanMan) => {},
);
/// An Event which you should probably take some action in response to.