@@ -1824,6 +1824,7 @@ pub(super) struct FundingScope {
18241824 /// The hash of the block in which the funding transaction was included.
18251825 funding_tx_confirmed_in: Option<BlockHash>,
18261826 funding_tx_confirmation_height: u32,
1827+ short_channel_id: Option<u64>,
18271828}
18281829
18291830impl Writeable for FundingScope {
@@ -1836,6 +1837,7 @@ impl Writeable for FundingScope {
18361837 (9, self.funding_transaction, option),
18371838 (11, self.funding_tx_confirmed_in, option),
18381839 (13, self.funding_tx_confirmation_height, required),
1840+ (15, self.short_channel_id, option),
18391841 });
18401842 Ok(())
18411843 }
@@ -1850,6 +1852,7 @@ impl Readable for FundingScope {
18501852 let mut funding_transaction = None;
18511853 let mut funding_tx_confirmed_in = None;
18521854 let mut funding_tx_confirmation_height = RequiredWrapper(None);
1855+ let mut short_channel_id = None;
18531856
18541857 read_tlv_fields!(reader, {
18551858 (1, value_to_self_msat, required),
@@ -1859,6 +1862,7 @@ impl Readable for FundingScope {
18591862 (9, funding_transaction, option),
18601863 (11, funding_tx_confirmed_in, option),
18611864 (13, funding_tx_confirmation_height, required),
1865+ (15, short_channel_id, option),
18621866 });
18631867
18641868 Ok(Self {
@@ -1873,6 +1877,7 @@ impl Readable for FundingScope {
18731877 funding_transaction,
18741878 funding_tx_confirmed_in,
18751879 funding_tx_confirmation_height: funding_tx_confirmation_height.0.unwrap(),
1880+ short_channel_id,
18761881 #[cfg(any(test, fuzzing))]
18771882 next_local_commitment_tx_fee_info_cached: Mutex::new(None),
18781883 #[cfg(any(test, fuzzing))]
@@ -1966,6 +1971,13 @@ impl FundingScope {
19661971
19671972 height.checked_sub(self.funding_tx_confirmation_height).map_or(0, |c| c + 1)
19681973 }
1974+
1975+ /// Gets the channel's `short_channel_id`.
1976+ ///
1977+ /// Will return `None` if the funding hasn't been confirmed yet.
1978+ pub fn get_short_channel_id(&self) -> Option<u64> {
1979+ self.short_channel_id
1980+ }
19691981}
19701982
19711983/// Info about a pending splice, used in the pre-splice channel
@@ -2125,7 +2137,6 @@ pub(super) struct ChannelContext<SP: Deref> where SP::Target: SignerProvider {
21252137 /// milliseconds, so any accidental force-closes here should be exceedingly rare.
21262138 expecting_peer_commitment_signed: bool,
21272139
2128- short_channel_id: Option<u64>,
21292140 /// Either the height at which this channel was created or the height at which it was last
21302141 /// serialized if it was serialized by versions prior to 0.0.103.
21312142 /// We use this to close if funding is never broadcasted.
@@ -2940,6 +2951,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
29402951 funding_transaction: None,
29412952 funding_tx_confirmed_in: None,
29422953 funding_tx_confirmation_height: 0,
2954+ short_channel_id: None,
29432955 };
29442956 let channel_context = ChannelContext {
29452957 user_id,
@@ -3003,7 +3015,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
30033015 closing_fee_limits: None,
30043016 target_closing_feerate_sats_per_kw: None,
30053017
3006- short_channel_id: None,
30073018 channel_creation_height: current_chain_height,
30083019
30093020 feerate_per_kw: open_channel_fields.commitment_feerate_sat_per_1000_weight,
@@ -3180,6 +3191,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
31803191 funding_transaction: None,
31813192 funding_tx_confirmed_in: None,
31823193 funding_tx_confirmation_height: 0,
3194+ short_channel_id: None,
31833195 };
31843196 let channel_context = Self {
31853197 user_id,
@@ -3241,7 +3253,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
32413253 closing_fee_limits: None,
32423254 target_closing_feerate_sats_per_kw: None,
32433255
3244- short_channel_id: None,
32453256 channel_creation_height: current_chain_height,
32463257
32473258 feerate_per_kw: commitment_feerate,
@@ -3460,13 +3471,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
34603471 self.user_id
34613472 }
34623473
3463- /// Gets the channel's `short_channel_id`.
3464- ///
3465- /// Will return `None` if the channel hasn't been confirmed yet.
3466- pub fn get_short_channel_id(&self) -> Option<u64> {
3467- self.short_channel_id
3468- }
3469-
34703474 /// Allowed in any state (including after shutdown)
34713475 pub fn latest_inbound_scid_alias(&self) -> Option<u64> {
34723476 self.latest_inbound_scid_alias
@@ -5941,7 +5945,7 @@ impl<SP: Deref> FundedChannel<SP> where
59415945 }
59425946
59435947 if let Some(scid_alias) = msg.short_channel_id_alias {
5944- if Some(scid_alias) != self.context .short_channel_id {
5948+ if Some(scid_alias) != self.funding .short_channel_id {
59455949 // The scid alias provided can be used to route payments *from* our counterparty,
59465950 // i.e. can be used for inbound payments and provided in invoices, but is not used
59475951 // when routing outbound payments.
@@ -8582,7 +8586,7 @@ impl<SP: Deref> FundedChannel<SP> where
85828586
85838587 self.funding.funding_tx_confirmation_height = height;
85848588 self.funding.funding_tx_confirmed_in = Some(*block_hash);
8585- self.context .short_channel_id = match scid_from_parts(height as u64, index_in_block as u64, txo_idx as u64) {
8589+ self.funding .short_channel_id = match scid_from_parts(height as u64, index_in_block as u64, txo_idx as u64) {
85868590 Ok(scid) => Some(scid),
85878591 Err(_) => panic!("Block was bogus - either height was > 16 million, had > 16 million transactions, or had > 65k outputs"),
85888592 }
@@ -8762,7 +8766,7 @@ impl<SP: Deref> FundedChannel<SP> where
87628766 return Err(ChannelError::Ignore("Cannot get a ChannelAnnouncement if the channel is not currently usable".to_owned()));
87638767 }
87648768
8765- let short_channel_id = self.context .get_short_channel_id()
8769+ let short_channel_id = self.funding .get_short_channel_id()
87668770 .ok_or(ChannelError::Ignore("Cannot get a ChannelAnnouncement if the channel has not been confirmed yet".to_owned()))?;
87678771 let node_id = NodeId::from_pubkey(&node_signer.get_node_id(Recipient::Node)
87688772 .map_err(|_| ChannelError::Ignore("Failed to retrieve own public key".to_owned()))?);
@@ -8834,7 +8838,7 @@ impl<SP: Deref> FundedChannel<SP> where
88348838 },
88358839 Ok(v) => v
88368840 };
8837- let short_channel_id = match self.context .get_short_channel_id() {
8841+ let short_channel_id = match self.funding .get_short_channel_id() {
88388842 Some(scid) => scid,
88398843 None => return None,
88408844 };
@@ -11109,7 +11113,7 @@ impl<SP: Deref> Writeable for FundedChannel<SP> where SP::Target: SignerProvider
1110911113
1111011114 self.funding.funding_tx_confirmed_in.write(writer)?;
1111111115 self.funding.funding_tx_confirmation_height.write(writer)?;
11112- self.context .short_channel_id.write(writer)?;
11116+ self.funding .short_channel_id.write(writer)?;
1111311117
1111411118 self.context.counterparty_dust_limit_satoshis.write(writer)?;
1111511119 self.context.holder_dust_limit_satoshis.write(writer)?;
@@ -11766,6 +11770,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, &'c Channel
1176611770 funding_transaction,
1176711771 funding_tx_confirmed_in,
1176811772 funding_tx_confirmation_height,
11773+ short_channel_id,
1176911774 },
1177011775 pending_funding: pending_funding.unwrap(),
1177111776 context: ChannelContext {
@@ -11829,7 +11834,6 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, &'c Channel
1182911834 closing_fee_limits: None,
1183011835 target_closing_feerate_sats_per_kw,
1183111836
11832- short_channel_id,
1183311837 channel_creation_height,
1183411838
1183511839 counterparty_dust_limit_satoshis,
0 commit comments