Skip to content

Commit 30101b3

Browse files
committed
Allocate and assign the SCID alias after we're certain the channel will survive.
Wait until we're certain that channel creation will be created until we allocate and initialize the outbound SCID alias. This fixes some paths where we might leak an unused outbound SCID alias.
1 parent 8d00338 commit 30101b3

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lightning/src/ln/channelmanager.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -5383,13 +5383,11 @@ where
53835383

53845384
// Otherwise create the channel right now.
53855385
let user_channel_id = u128::from_be_bytes(random_bytes);
5386-
let outbound_scid_alias = self.create_and_insert_outbound_scid_alias();
53875386
let mut channel = match InboundV1Channel::new(&self.fee_estimator, &self.entropy_source, &self.signer_provider,
53885387
counterparty_node_id.clone(), &self.channel_type_features(), &peer_state.latest_features, msg, user_channel_id,
5389-
&self.default_configuration, best_block_height, &self.logger, outbound_scid_alias)
5388+
&self.default_configuration, best_block_height, &self.logger, /*outbound_scid_alias=*/0)
53905389
{
53915390
Err(e) => {
5392-
self.outbound_scid_aliases.lock().unwrap().remove(&outbound_scid_alias);
53935391
return Err(MsgHandleErrInternal::from_chan_no_close(e, msg.temporary_channel_id));
53945392
},
53955393
Ok(res) => res
@@ -5402,6 +5400,10 @@ where
54025400
if channel_type.requires_anchors_zero_fee_htlc_tx() {
54035401
return Err(MsgHandleErrInternal::send_err_msg_no_close("No channels with anchor outputs accepted".to_owned(), msg.temporary_channel_id.clone()));
54045402
}
5403+
5404+
let outbound_scid_alias = self.create_and_insert_outbound_scid_alias();
5405+
channel.context.set_outbound_scid_alias(outbound_scid_alias);
5406+
54055407
peer_state.pending_msg_events.push(events::MessageSendEvent::SendAcceptChannel {
54065408
node_id: counterparty_node_id.clone(),
54075409
msg: channel.accept_inbound_channel(user_channel_id),

0 commit comments

Comments
 (0)