@@ -6236,25 +6236,27 @@ where
62366236
62376237		let funded_channel_id = chan.context.channel_id();
62386238
6239+ 		macro_rules! fail_chan { ($err: expr) => { {
6240+ 			// Note that at this point we've filled in the funding outpoint on our
6241+ 			// channel, but its actually in conflict with another channel. Thus, if
6242+ 			// we call `convert_chan_phase_err` immediately (thus calling
6243+ 			// `update_maps_on_chan_removal`), we'll remove the existing channel
6244+ 			// from `id_to_peer`. Thus, we must first unset the funding outpoint on
6245+ 			// the channel.
6246+ 			let err = ChannelError::Close($err.to_owned());
6247+ 			chan.unset_funding_info(msg.temporary_channel_id);
6248+ 			return Err(convert_chan_phase_err!(self, err, &mut ChannelPhase::Funded(chan), &funded_channel_id).1);
6249+ 		} } }
6250+ 
62396251		match peer_state.channel_by_id.entry(funded_channel_id) {
62406252			hash_map::Entry::Occupied(_) => {
6241- 				let err = ChannelError::Close("Already had channel with the new channel_id".to_owned());
6242- 				// Note that at this point we've filled in the funding outpoint on our
6243- 				// channel, but its actually in conflict with another channel. Thus, if
6244- 				// we call `convert_chan_phase_err` immediately (thus calling
6245- 				// `update_maps_on_chan_removal`), we'll remove the existing channel
6246- 				// from `id_to_peer`. Thus, we must first unset the funding outpoint on
6247- 				// the channel.
6248- 				chan.unset_funding_info(msg.temporary_channel_id);
6249- 				return Err(convert_chan_phase_err!(self, err, &mut ChannelPhase::Funded(chan), &funded_channel_id).1);
6253+ 				fail_chan!(err);
62506254			},
62516255			hash_map::Entry::Vacant(e) => {
62526256				let mut outpoint_to_peer_lock = self.outpoint_to_peer.lock().unwrap();
62536257				match outpoint_to_peer_lock.entry(monitor.get_funding_txo().0) {
62546258					hash_map::Entry::Occupied(_) => {
6255- 						return Err(MsgHandleErrInternal::send_err_msg_no_close(
6256- 							"The funding_created message had the same funding_txid as an existing channel - funding is not possible".to_owned(),
6257- 							chan.context.channel_id()))
6259+ 						fail_chan!("The funding_created message had the same funding_txid as an existing channel - funding is not possible");
62586260					},
62596261					hash_map::Entry::Vacant(i_e) => {
62606262						let monitor_res = self.chain_monitor.watch_channel(monitor.get_funding_txo().0, monitor);
@@ -6283,15 +6285,7 @@ where
62836285						} else {
62846286							let logger = WithChannelContext::from(&self.logger, &chan.context);
62856287							log_error!(logger, "Persisting initial ChannelMonitor failed, implying the funding outpoint was duplicated");
6286- 							let err = ChannelError::Close("Duplicate funding outpoint".to_owned());
6287- 							// Note that at this point we've filled in the funding outpoint on our
6288- 							// channel, but its actually in conflict with another channel. Thus, if
6289- 							// we call `convert_chan_phase_err` immediately (thus calling
6290- 							// `update_maps_on_chan_removal`), we'll remove the existing channel
6291- 							// from `id_to_peer`. Thus, we must first unset the funding outpoint on
6292- 							// the channel.
6293- 							chan.unset_funding_info(msg.temporary_channel_id);
6294- 							return Err(convert_chan_phase_err!(self, err, &mut ChannelPhase::Funded(chan), &funded_channel_id).1);
6288+ 							fail_chan!("Duplicate funding outpoint");
62956289						}
62966290					}
62976291				}
0 commit comments