@@ -1963,6 +1963,7 @@ pub(super) struct FundingScope {
19631963 /// The hash of the block in which the funding transaction was included.
19641964 funding_tx_confirmed_in: Option<BlockHash>,
19651965 funding_tx_confirmation_height: u32,
1966+ short_channel_id: Option<u64>,
19661967}
19671968
19681969impl Writeable for FundingScope {
@@ -1975,6 +1976,7 @@ impl Writeable for FundingScope {
19751976 (9, self.funding_transaction, option),
19761977 (11, self.funding_tx_confirmed_in, option),
19771978 (13, self.funding_tx_confirmation_height, required),
1979+ (15, self.short_channel_id, option),
19781980 });
19791981 Ok(())
19801982 }
@@ -1990,6 +1992,7 @@ impl Readable for FundingScope {
19901992 let mut funding_transaction = None;
19911993 let mut funding_tx_confirmed_in = None;
19921994 let mut funding_tx_confirmation_height = RequiredWrapper(None);
1995+ let mut short_channel_id = None;
19931996
19941997 read_tlv_fields!(reader, {
19951998 (1, value_to_self_msat, required),
@@ -1999,6 +2002,7 @@ impl Readable for FundingScope {
19992002 (9, funding_transaction, option),
20002003 (11, funding_tx_confirmed_in, option),
20012004 (13, funding_tx_confirmation_height, required),
2005+ (15, short_channel_id, option),
20022006 });
20032007
20042008 Ok(Self {
@@ -2013,6 +2017,7 @@ impl Readable for FundingScope {
20132017 funding_transaction,
20142018 funding_tx_confirmed_in,
20152019 funding_tx_confirmation_height: funding_tx_confirmation_height.0.unwrap(),
2020+ short_channel_id,
20162021 #[cfg(any(test, fuzzing))]
20172022 next_local_commitment_tx_fee_info_cached: Mutex::new(None),
20182023 #[cfg(any(test, fuzzing))]
@@ -2109,6 +2114,13 @@ impl FundingScope {
21092114
21102115 height.checked_sub(self.funding_tx_confirmation_height).map_or(0, |c| c + 1)
21112116 }
2117+
2118+ /// Gets the channel's `short_channel_id`.
2119+ ///
2120+ /// Will return `None` if the funding hasn't been confirmed yet.
2121+ pub fn get_short_channel_id(&self) -> Option<u64> {
2122+ self.short_channel_id
2123+ }
21122124}
21132125
21142126/// Info about a pending splice, used in the pre-splice channel
@@ -2270,7 +2282,6 @@ where
22702282 /// milliseconds, so any accidental force-closes here should be exceedingly rare.
22712283 expecting_peer_commitment_signed: bool,
22722284
2273- short_channel_id: Option<u64>,
22742285 /// Either the height at which this channel was created or the height at which it was last
22752286 /// serialized if it was serialized by versions prior to 0.0.103.
22762287 /// We use this to close if funding is never broadcasted.
@@ -3118,6 +3129,7 @@ where
31183129 funding_transaction: None,
31193130 funding_tx_confirmed_in: None,
31203131 funding_tx_confirmation_height: 0,
3132+ short_channel_id: None,
31213133 };
31223134 let channel_context = ChannelContext {
31233135 user_id,
@@ -3181,7 +3193,6 @@ where
31813193 closing_fee_limits: None,
31823194 target_closing_feerate_sats_per_kw: None,
31833195
3184- short_channel_id: None,
31853196 channel_creation_height: current_chain_height,
31863197
31873198 feerate_per_kw: open_channel_fields.commitment_feerate_sat_per_1000_weight,
@@ -3359,6 +3370,7 @@ where
33593370 funding_transaction: None,
33603371 funding_tx_confirmed_in: None,
33613372 funding_tx_confirmation_height: 0,
3373+ short_channel_id: None,
33623374 };
33633375 let channel_context = Self {
33643376 user_id,
@@ -3420,7 +3432,6 @@ where
34203432 closing_fee_limits: None,
34213433 target_closing_feerate_sats_per_kw: None,
34223434
3423- short_channel_id: None,
34243435 channel_creation_height: current_chain_height,
34253436
34263437 feerate_per_kw: commitment_feerate,
@@ -3644,13 +3655,6 @@ where
36443655 self.user_id
36453656 }
36463657
3647- /// Gets the channel's `short_channel_id`.
3648- ///
3649- /// Will return `None` if the channel hasn't been confirmed yet.
3650- pub fn get_short_channel_id(&self) -> Option<u64> {
3651- self.short_channel_id
3652- }
3653-
36543658 /// Allowed in any state (including after shutdown)
36553659 pub fn latest_inbound_scid_alias(&self) -> Option<u64> {
36563660 self.latest_inbound_scid_alias
@@ -6192,7 +6196,7 @@ where
61926196 }
61936197
61946198 if let Some(scid_alias) = msg.short_channel_id_alias {
6195- if Some(scid_alias) != self.context .short_channel_id {
6199+ if Some(scid_alias) != self.funding .short_channel_id {
61966200 // The scid alias provided can be used to route payments *from* our counterparty,
61976201 // i.e. can be used for inbound payments and provided in invoices, but is not used
61986202 // when routing outbound payments.
@@ -8904,7 +8908,7 @@ where
89048908
89058909 self.funding.funding_tx_confirmation_height = height;
89068910 self.funding.funding_tx_confirmed_in = Some(*block_hash);
8907- self.context .short_channel_id = match scid_from_parts(height as u64, index_in_block as u64, txo_idx as u64) {
8911+ self.funding .short_channel_id = match scid_from_parts(height as u64, index_in_block as u64, txo_idx as u64) {
89088912 Ok(scid) => Some(scid),
89098913 Err(_) => panic!("Block was bogus - either height was > 16 million, had > 16 million transactions, or had > 65k outputs"),
89108914 }
@@ -9092,7 +9096,7 @@ where
90929096 return Err(ChannelError::Ignore("Cannot get a ChannelAnnouncement if the channel is not currently usable".to_owned()));
90939097 }
90949098
9095- let short_channel_id = self.context .get_short_channel_id()
9099+ let short_channel_id = self.funding .get_short_channel_id()
90969100 .ok_or(ChannelError::Ignore("Cannot get a ChannelAnnouncement if the channel has not been confirmed yet".to_owned()))?;
90979101 let node_id = NodeId::from_pubkey(&node_signer.get_node_id(Recipient::Node)
90989102 .map_err(|_| ChannelError::Ignore("Failed to retrieve own public key".to_owned()))?);
@@ -9165,7 +9169,7 @@ where
91659169 },
91669170 Ok(v) => v
91679171 };
9168- let short_channel_id = match self.context .get_short_channel_id() {
9172+ let short_channel_id = match self.funding .get_short_channel_id() {
91699173 Some(scid) => scid,
91709174 None => return None,
91719175 };
@@ -11512,7 +11516,7 @@ where
1151211516
1151311517 self.funding.funding_tx_confirmed_in.write(writer)?;
1151411518 self.funding.funding_tx_confirmation_height.write(writer)?;
11515- self.context .short_channel_id.write(writer)?;
11519+ self.funding .short_channel_id.write(writer)?;
1151611520
1151711521 self.context.counterparty_dust_limit_satoshis.write(writer)?;
1151811522 self.context.holder_dust_limit_satoshis.write(writer)?;
@@ -12171,6 +12175,7 @@ where
1217112175 funding_transaction,
1217212176 funding_tx_confirmed_in,
1217312177 funding_tx_confirmation_height,
12178+ short_channel_id,
1217412179 },
1217512180 pending_funding: pending_funding.unwrap(),
1217612181 context: ChannelContext {
@@ -12234,7 +12239,6 @@ where
1223412239 closing_fee_limits: None,
1223512240 target_closing_feerate_sats_per_kw,
1223612241
12237- short_channel_id,
1223812242 channel_creation_height,
1223912243
1224012244 counterparty_dust_limit_satoshis,
0 commit comments