@@ -1828,55 +1828,43 @@ macro_rules! convert_unfunded_chan_err {
1828
1828
}
1829
1829
1830
1830
/// Returns (boolean indicating if we should remove the Channel object from memory, a mapped error)
1831
- macro_rules! convert_funded_chan_err {
1832
- ($self: ident, $err: expr, $channel: expr, $channel_id: expr) => {
1831
+ macro_rules! convert_chan_phase_err {
1832
+ ($self: ident, $err: expr, $channel: expr, $channel_id: expr, MANUAL_CHANNEL_UPDATE, $channel_update: expr ) => {
1833
1833
match $err {
1834
1834
ChannelError::Warn(msg) => {
1835
- (false, MsgHandleErrInternal::from_chan_no_close(ChannelError::Warn(msg), $channel_id.clone() ))
1835
+ (false, MsgHandleErrInternal::from_chan_no_close(ChannelError::Warn(msg), * $channel_id))
1836
1836
},
1837
1837
ChannelError::Ignore(msg) => {
1838
- (false, MsgHandleErrInternal::from_chan_no_close(ChannelError::Ignore(msg), $channel_id.clone() ))
1838
+ (false, MsgHandleErrInternal::from_chan_no_close(ChannelError::Ignore(msg), * $channel_id))
1839
1839
},
1840
1840
ChannelError::Close(msg) => {
1841
1841
log_error!($self.logger, "Closing channel {} due to close-required error: {}", log_bytes!($channel_id[..]), msg);
1842
1842
update_maps_on_chan_removal!($self, $channel.context);
1843
1843
let shutdown_res = $channel.context.force_shutdown(true);
1844
+ let user_id = $channel.context.get_user_id();
1845
+ let channel_capacity_satoshis = $channel.context.get_value_satoshis();
1844
1846
1845
- (true, MsgHandleErrInternal::from_finish_shutdown(msg, *$channel_id, $channel.context.get_user_id() ,
1846
- shutdown_res, $self.get_channel_update_for_broadcast(&$channel).ok(), $channel.context.get_value_satoshis() ))
1847
+ (true, MsgHandleErrInternal::from_finish_shutdown(msg, *$channel_id, user_id ,
1848
+ shutdown_res, $channel_update, channel_capacity_satoshis ))
1847
1849
},
1848
1850
}
1849
1851
};
1850
- }
1851
-
1852
- /// Returns (boolean indicating if we should remove the Channel object from memory, a mapped error)
1853
- macro_rules! convert_chan_phase_err {
1852
+ ($self: ident, $err: expr, $channel: expr, $channel_id: expr, FUNDED_CHANNEL) => {
1853
+ convert_chan_phase_err!($self, $err, $channel, $channel_id, MANUAL_CHANNEL_UPDATE, { $self.get_channel_update_for_broadcast($channel).ok() })
1854
+ };
1855
+ ($self: ident, $err: expr, $channel: expr, $channel_id: expr, UNFUNDED_CHANNEL) => {
1856
+ convert_chan_phase_err!($self, $err, $channel, $channel_id, MANUAL_CHANNEL_UPDATE, None)
1857
+ };
1854
1858
($self: ident, $err: expr, $channel_phase: expr, $channel_id: expr) => {
1855
- match $err {
1856
- ChannelError::Warn(msg ) => {
1857
- (false, MsgHandleErrInternal::from_chan_no_close(ChannelError::Warn(msg), * $channel_id) )
1859
+ match $channel_phase {
1860
+ ChannelPhase::Funded(channel ) => {
1861
+ convert_chan_phase_err!($self, $err, channel, $channel_id, FUNDED_CHANNEL )
1858
1862
},
1859
- ChannelError::Ignore(msg ) => {
1860
- (false, MsgHandleErrInternal::from_chan_no_close(ChannelError::Ignore(msg), * $channel_id) )
1863
+ ChannelPhase::UnfundedOutboundV1(channel ) => {
1864
+ convert_chan_phase_err!($self, $err, channel, $channel_id, UNFUNDED_CHANNEL )
1861
1865
},
1862
- ChannelError::Close(msg) => {
1863
- log_error!($self.logger, "Closing channel {} due to close-required error: {}", log_bytes!($channel_id[..]), msg);
1864
- let context = $channel_phase.context_mut();
1865
- update_maps_on_chan_removal!($self, context);
1866
- let shutdown_res = context.force_shutdown(true);
1867
- let user_id = context.get_user_id();
1868
- let channel_capacity_satoshis = context.get_value_satoshis();
1869
-
1870
- match $channel_phase {
1871
- ChannelPhase::Funded(chan) => {
1872
- (true, MsgHandleErrInternal::from_finish_shutdown(msg, *$channel_id, user_id,
1873
- shutdown_res, $self.get_channel_update_for_broadcast(&chan).ok(), channel_capacity_satoshis))
1874
- },
1875
- _ => {
1876
- (true, MsgHandleErrInternal::from_finish_shutdown(msg, *$channel_id, user_id,
1877
- shutdown_res, None, channel_capacity_satoshis))
1878
- }
1879
- }
1866
+ ChannelPhase::UnfundedInboundV1(channel) => {
1867
+ convert_chan_phase_err!($self, $err, channel, $channel_id, UNFUNDED_CHANNEL)
1880
1868
},
1881
1869
}
1882
1870
};
@@ -4609,7 +4597,7 @@ where
4609
4597
if chan_needs_persist == NotifyOption::DoPersist { should_persist = NotifyOption::DoPersist; }
4610
4598
4611
4599
if let Err(e) = chan.timer_check_closing_negotiation_progress() {
4612
- let (needs_close, err) = convert_funded_chan_err !(self, e, chan, chan_id);
4600
+ let (needs_close, err) = convert_chan_phase_err !(self, e, chan, chan_id, FUNDED_CHANNEL );
4613
4601
handle_errors.push((Err(err), counterparty_node_id));
4614
4602
if needs_close { return false; }
4615
4603
}
@@ -6708,7 +6696,7 @@ where
6708
6696
},
6709
6697
Err(e) => {
6710
6698
has_update = true;
6711
- let (close_channel, res) = convert_funded_chan_err !(self, e, chan, channel_id);
6699
+ let (close_channel, res) = convert_chan_phase_err !(self, e, chan, channel_id, FUNDED_CHANNEL );
6712
6700
handle_errors.push((chan.context.get_counterparty_node_id(), Err(res)));
6713
6701
!close_channel
6714
6702
}
0 commit comments