@@ -3005,7 +3005,7 @@ macro_rules! locked_close_channel {
30053005
30063006/// Returns (boolean indicating if we should remove the Channel object from memory, a mapped error)
30073007macro_rules! convert_chan_phase_err {
3008- ($self: ident, $peer_state: expr, $err: expr, $channel : expr, $channel_id: expr, MANUAL_CHANNEL_UPDATE, $channel_update: expr) => {
3008+ ($self: ident, $peer_state: expr, $err: expr, $context : expr, $channel_id: expr, MANUAL_CHANNEL_UPDATE, $channel_update: expr) => {
30093009 match $err {
30103010 ChannelError::Warn(msg) => {
30113011 (false, MsgHandleErrInternal::from_chan_no_close(ChannelError::Warn(msg), *$channel_id))
@@ -3014,35 +3014,29 @@ macro_rules! convert_chan_phase_err {
30143014 (false, MsgHandleErrInternal::from_chan_no_close(ChannelError::Ignore(msg), *$channel_id))
30153015 },
30163016 ChannelError::Close((msg, reason)) => {
3017- let logger = WithChannelContext::from(&$self.logger, &$channel. context, None);
3017+ let logger = WithChannelContext::from(&$self.logger, &$context, None);
30183018 log_error!(logger, "Closing channel {} due to close-required error: {}", $channel_id, msg);
3019- let mut shutdown_res = $channel. context.force_shutdown(true, reason);
3020- locked_close_channel!($self, $peer_state, &$channel. context, &mut shutdown_res);
3019+ let mut shutdown_res = $context.force_shutdown(true, reason);
3020+ locked_close_channel!($self, $peer_state, $ context, &mut shutdown_res);
30213021 let err =
30223022 MsgHandleErrInternal::from_finish_shutdown(msg, *$channel_id, shutdown_res, $channel_update);
30233023 (true, err)
30243024 },
30253025 }
30263026 };
30273027 ($self: ident, $peer_state: expr, $err: expr, $channel: expr, $channel_id: expr, FUNDED_CHANNEL) => {
3028- convert_chan_phase_err!($self, $peer_state, $err, $channel, $channel_id, MANUAL_CHANNEL_UPDATE, { $self.get_channel_update_for_broadcast($channel).ok() })
3028+ convert_chan_phase_err!($self, $peer_state, $err, $channel.context , $channel_id, MANUAL_CHANNEL_UPDATE, { $self.get_channel_update_for_broadcast(& $channel).ok() })
30293029 };
3030- ($self: ident, $peer_state: expr, $err: expr, $channel : expr, $channel_id: expr, UNFUNDED_CHANNEL) => {
3031- convert_chan_phase_err!($self, $peer_state, $err, $channel , $channel_id, MANUAL_CHANNEL_UPDATE, None)
3030+ ($self: ident, $peer_state: expr, $err: expr, $context : expr, $channel_id: expr, UNFUNDED_CHANNEL) => {
3031+ convert_chan_phase_err!($self, $peer_state, $err, $context , $channel_id, MANUAL_CHANNEL_UPDATE, None)
30323032 };
30333033 ($self: ident, $peer_state: expr, $err: expr, $channel_phase: expr, $channel_id: expr) => {
3034- match $channel_phase {
3035- ChannelPhase::Funded (channel) => {
3034+ match $channel_phase.as_funded_mut() {
3035+ Some (channel) => {
30363036 convert_chan_phase_err!($self, $peer_state, $err, channel, $channel_id, FUNDED_CHANNEL)
30373037 },
3038- ChannelPhase::UnfundedOutboundV1(channel) => {
3039- convert_chan_phase_err!($self, $peer_state, $err, channel, $channel_id, UNFUNDED_CHANNEL)
3040- },
3041- ChannelPhase::UnfundedInboundV1(channel) => {
3042- convert_chan_phase_err!($self, $peer_state, $err, channel, $channel_id, UNFUNDED_CHANNEL)
3043- },
3044- ChannelPhase::UnfundedV2(channel) => {
3045- convert_chan_phase_err!($self, $peer_state, $err, channel, $channel_id, UNFUNDED_CHANNEL)
3038+ None => {
3039+ convert_chan_phase_err!($self, $peer_state, $err, $channel_phase.context_mut(), $channel_id, UNFUNDED_CHANNEL)
30463040 },
30473041 }
30483042 };
@@ -8066,15 +8060,15 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
80668060 let logger = WithChannelContext::from(&self.logger, &inbound_chan.context, None);
80678061 match inbound_chan.funding_created(msg, best_block, &self.signer_provider, &&logger) {
80688062 Ok(res) => res,
8069- Err((inbound_chan, err)) => {
8063+ Err((mut inbound_chan, err)) => {
80708064 // We've already removed this inbound channel from the map in `PeerState`
80718065 // above so at this point we just need to clean up any lingering entries
80728066 // concerning this channel as it is safe to do so.
80738067 debug_assert!(matches!(err, ChannelError::Close(_)));
80748068 // Really we should be returning the channel_id the peer expects based
80758069 // on their funding info here, but they're horribly confused anyway, so
80768070 // there's not a lot we can do to save them.
8077- return Err(convert_chan_phase_err!(self, peer_state, err, &mut ChannelPhase::UnfundedInboundV1( inbound_chan) , &msg.temporary_channel_id).1);
8071+ return Err(convert_chan_phase_err!(self, peer_state, err, inbound_chan.context , &msg.temporary_channel_id, UNFUNDED_CHANNEL ).1);
80788072 },
80798073 }
80808074 },
@@ -8096,7 +8090,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
80968090 // Thus, we must first unset the funding outpoint on the channel.
80978091 let err = ChannelError::close($err.to_owned());
80988092 chan.unset_funding_info(msg.temporary_channel_id);
8099- return Err(convert_chan_phase_err!(self, peer_state, err, chan, &funded_channel_id, UNFUNDED_CHANNEL).1);
8093+ return Err(convert_chan_phase_err!(self, peer_state, err, chan.context , &funded_channel_id, UNFUNDED_CHANNEL).1);
81008094 } } }
81018095
81028096 match peer_state.channel_by_id.entry(funded_channel_id) {
@@ -8185,16 +8179,16 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
81858179 // found an (unreachable) panic when the monitor update contained
81868180 // within `shutdown_finish` was applied.
81878181 chan.unset_funding_info(msg.channel_id);
8188- return Err(convert_chan_phase_err!(self, peer_state, e, &mut ChannelPhase::Funded( chan) , &msg.channel_id).1);
8182+ return Err(convert_chan_phase_err!(self, peer_state, e, chan, &msg.channel_id, FUNDED_CHANNEL ).1);
81898183 }
81908184 },
8191- Err((chan, e)) => {
8185+ Err((mut chan, e)) => {
81928186 debug_assert!(matches!(e, ChannelError::Close(_)),
81938187 "We don't have a channel anymore, so the error better have expected close");
81948188 // We've already removed this outbound channel from the map in
81958189 // `PeerState` above so at this point we just need to clean up any
81968190 // lingering entries concerning this channel as it is safe to do so.
8197- return Err(convert_chan_phase_err!(self, peer_state, e, &mut ChannelPhase::UnfundedOutboundV1( chan) , &msg.channel_id).1);
8191+ return Err(convert_chan_phase_err!(self, peer_state, e, chan.context , &msg.channel_id, UNFUNDED_CHANNEL ).1);
81988192 }
81998193 }
82008194 } else {
0 commit comments