@@ -3005,7 +3005,7 @@ macro_rules! locked_close_channel {
3005
3005
3006
3006
/// Returns (boolean indicating if we should remove the Channel object from memory, a mapped error)
3007
3007
macro_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) => {
3009
3009
match $err {
3010
3010
ChannelError::Warn(msg) => {
3011
3011
(false, MsgHandleErrInternal::from_chan_no_close(ChannelError::Warn(msg), *$channel_id))
@@ -3014,35 +3014,29 @@ macro_rules! convert_chan_phase_err {
3014
3014
(false, MsgHandleErrInternal::from_chan_no_close(ChannelError::Ignore(msg), *$channel_id))
3015
3015
},
3016
3016
ChannelError::Close((msg, reason)) => {
3017
- let logger = WithChannelContext::from(&$self.logger, &$channel. context, None);
3017
+ let logger = WithChannelContext::from(&$self.logger, &$context, None);
3018
3018
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);
3021
3021
let err =
3022
3022
MsgHandleErrInternal::from_finish_shutdown(msg, *$channel_id, shutdown_res, $channel_update);
3023
3023
(true, err)
3024
3024
},
3025
3025
}
3026
3026
};
3027
3027
($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() })
3029
3029
};
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)
3032
3032
};
3033
3033
($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) => {
3036
3036
convert_chan_phase_err!($self, $peer_state, $err, channel, $channel_id, FUNDED_CHANNEL)
3037
3037
},
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)
3046
3040
},
3047
3041
}
3048
3042
};
@@ -8066,15 +8060,15 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
8066
8060
let logger = WithChannelContext::from(&self.logger, &inbound_chan.context, None);
8067
8061
match inbound_chan.funding_created(msg, best_block, &self.signer_provider, &&logger) {
8068
8062
Ok(res) => res,
8069
- Err((inbound_chan, err)) => {
8063
+ Err((mut inbound_chan, err)) => {
8070
8064
// We've already removed this inbound channel from the map in `PeerState`
8071
8065
// above so at this point we just need to clean up any lingering entries
8072
8066
// concerning this channel as it is safe to do so.
8073
8067
debug_assert!(matches!(err, ChannelError::Close(_)));
8074
8068
// Really we should be returning the channel_id the peer expects based
8075
8069
// on their funding info here, but they're horribly confused anyway, so
8076
8070
// 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);
8078
8072
},
8079
8073
}
8080
8074
},
@@ -8096,7 +8090,7 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
8096
8090
// Thus, we must first unset the funding outpoint on the channel.
8097
8091
let err = ChannelError::close($err.to_owned());
8098
8092
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);
8100
8094
} } }
8101
8095
8102
8096
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/
8185
8179
// found an (unreachable) panic when the monitor update contained
8186
8180
// within `shutdown_finish` was applied.
8187
8181
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);
8189
8183
}
8190
8184
},
8191
- Err((chan, e)) => {
8185
+ Err((mut chan, e)) => {
8192
8186
debug_assert!(matches!(e, ChannelError::Close(_)),
8193
8187
"We don't have a channel anymore, so the error better have expected close");
8194
8188
// We've already removed this outbound channel from the map in
8195
8189
// `PeerState` above so at this point we just need to clean up any
8196
8190
// 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);
8198
8192
}
8199
8193
}
8200
8194
} else {
0 commit comments