@@ -6236,25 +6236,27 @@ where
6236
6236
6237
6237
let funded_channel_id = chan.context.channel_id();
6238
6238
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
+
6239
6251
match peer_state.channel_by_id.entry(funded_channel_id) {
6240
6252
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);
6250
6254
},
6251
6255
hash_map::Entry::Vacant(e) => {
6252
6256
let mut outpoint_to_peer_lock = self.outpoint_to_peer.lock().unwrap();
6253
6257
match outpoint_to_peer_lock.entry(monitor.get_funding_txo().0) {
6254
6258
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");
6258
6260
},
6259
6261
hash_map::Entry::Vacant(i_e) => {
6260
6262
let monitor_res = self.chain_monitor.watch_channel(monitor.get_funding_txo().0, monitor);
@@ -6283,15 +6285,7 @@ where
6283
6285
} else {
6284
6286
let logger = WithChannelContext::from(&self.logger, &chan.context);
6285
6287
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");
6295
6289
}
6296
6290
}
6297
6291
}
0 commit comments