@@ -1819,6 +1819,7 @@ pub(super) struct FundingScope {
18191819 /// The hash of the block in which the funding transaction was included.
18201820 funding_tx_confirmed_in: Option<BlockHash>,
18211821 funding_tx_confirmation_height: u32,
1822+ short_channel_id: Option<u64>,
18221823}
18231824
18241825impl Writeable for FundingScope {
@@ -1831,6 +1832,7 @@ impl Writeable for FundingScope {
18311832 (9, self.funding_transaction, option),
18321833 (11, self.funding_tx_confirmed_in, option),
18331834 (13, self.funding_tx_confirmation_height, required),
1835+ (15, self.short_channel_id, option),
18341836 });
18351837 Ok(())
18361838 }
@@ -1845,6 +1847,7 @@ impl Readable for FundingScope {
18451847 let mut funding_transaction = None;
18461848 let mut funding_tx_confirmed_in = None;
18471849 let mut funding_tx_confirmation_height = RequiredWrapper(None);
1850+ let mut short_channel_id = None;
18481851
18491852 read_tlv_fields!(reader, {
18501853 (1, value_to_self_msat, required),
@@ -1854,6 +1857,7 @@ impl Readable for FundingScope {
18541857 (9, funding_transaction, option),
18551858 (11, funding_tx_confirmed_in, option),
18561859 (13, funding_tx_confirmation_height, required),
1860+ (15, short_channel_id, option),
18571861 });
18581862
18591863 Ok(Self {
@@ -1868,6 +1872,7 @@ impl Readable for FundingScope {
18681872 funding_transaction,
18691873 funding_tx_confirmed_in,
18701874 funding_tx_confirmation_height: funding_tx_confirmation_height.0.unwrap(),
1875+ short_channel_id,
18711876 #[cfg(any(test, fuzzing))]
18721877 next_local_commitment_tx_fee_info_cached: Mutex::new(None),
18731878 #[cfg(any(test, fuzzing))]
@@ -1961,6 +1966,13 @@ impl FundingScope {
19611966
19621967 height.checked_sub(self.funding_tx_confirmation_height).map_or(0, |c| c + 1)
19631968 }
1969+
1970+ /// Gets the channel's `short_channel_id`.
1971+ ///
1972+ /// Will return `None` if the funding hasn't been confirmed yet.
1973+ pub fn get_short_channel_id(&self) -> Option<u64> {
1974+ self.short_channel_id
1975+ }
19641976}
19651977
19661978/// Info about a pending splice, used in the pre-splice channel
@@ -2120,7 +2132,6 @@ pub(super) struct ChannelContext<SP: Deref> where SP::Target: SignerProvider {
21202132 /// milliseconds, so any accidental force-closes here should be exceedingly rare.
21212133 expecting_peer_commitment_signed: bool,
21222134
2123- short_channel_id: Option<u64>,
21242135 /// Either the height at which this channel was created or the height at which it was last
21252136 /// serialized if it was serialized by versions prior to 0.0.103.
21262137 /// We use this to close if funding is never broadcasted.
@@ -2935,6 +2946,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
29352946 funding_transaction: None,
29362947 funding_tx_confirmed_in: None,
29372948 funding_tx_confirmation_height: 0,
2949+ short_channel_id: None,
29382950 };
29392951 let channel_context = ChannelContext {
29402952 user_id,
@@ -2998,7 +3010,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
29983010 closing_fee_limits: None,
29993011 target_closing_feerate_sats_per_kw: None,
30003012
3001- short_channel_id: None,
30023013 channel_creation_height: current_chain_height,
30033014
30043015 feerate_per_kw: open_channel_fields.commitment_feerate_sat_per_1000_weight,
@@ -3169,6 +3180,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
31693180 funding_transaction: None,
31703181 funding_tx_confirmed_in: None,
31713182 funding_tx_confirmation_height: 0,
3183+ short_channel_id: None,
31723184 };
31733185 let channel_context = Self {
31743186 user_id,
@@ -3230,7 +3242,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
32303242 closing_fee_limits: None,
32313243 target_closing_feerate_sats_per_kw: None,
32323244
3233- short_channel_id: None,
32343245 channel_creation_height: current_chain_height,
32353246
32363247 feerate_per_kw: commitment_feerate,
@@ -3449,13 +3460,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
34493460 self.user_id
34503461 }
34513462
3452- /// Gets the channel's `short_channel_id`.
3453- ///
3454- /// Will return `None` if the channel hasn't been confirmed yet.
3455- pub fn get_short_channel_id(&self) -> Option<u64> {
3456- self.short_channel_id
3457- }
3458-
34593463 /// Allowed in any state (including after shutdown)
34603464 pub fn latest_inbound_scid_alias(&self) -> Option<u64> {
34613465 self.latest_inbound_scid_alias
@@ -5684,7 +5688,7 @@ impl<SP: Deref> FundedChannel<SP> where
56845688 }
56855689
56865690 if let Some(scid_alias) = msg.short_channel_id_alias {
5687- if Some(scid_alias) != self.context .short_channel_id {
5691+ if Some(scid_alias) != self.funding .short_channel_id {
56885692 // The scid alias provided can be used to route payments *from* our counterparty,
56895693 // i.e. can be used for inbound payments and provided in invoices, but is not used
56905694 // when routing outbound payments.
@@ -8463,7 +8467,7 @@ impl<SP: Deref> FundedChannel<SP> where
84638467
84648468 self.funding.funding_tx_confirmation_height = height;
84658469 self.funding.funding_tx_confirmed_in = Some(*block_hash);
8466- self.context .short_channel_id = match scid_from_parts(height as u64, index_in_block as u64, txo_idx as u64) {
8470+ self.funding .short_channel_id = match scid_from_parts(height as u64, index_in_block as u64, txo_idx as u64) {
84678471 Ok(scid) => Some(scid),
84688472 Err(_) => panic!("Block was bogus - either height was > 16 million, had > 16 million transactions, or had > 65k outputs"),
84698473 }
@@ -8643,7 +8647,7 @@ impl<SP: Deref> FundedChannel<SP> where
86438647 return Err(ChannelError::Ignore("Cannot get a ChannelAnnouncement if the channel is not currently usable".to_owned()));
86448648 }
86458649
8646- let short_channel_id = self.context .get_short_channel_id()
8650+ let short_channel_id = self.funding .get_short_channel_id()
86478651 .ok_or(ChannelError::Ignore("Cannot get a ChannelAnnouncement if the channel has not been confirmed yet".to_owned()))?;
86488652 let node_id = NodeId::from_pubkey(&node_signer.get_node_id(Recipient::Node)
86498653 .map_err(|_| ChannelError::Ignore("Failed to retrieve own public key".to_owned()))?);
@@ -8715,7 +8719,7 @@ impl<SP: Deref> FundedChannel<SP> where
87158719 },
87168720 Ok(v) => v
87178721 };
8718- let short_channel_id = match self.context .get_short_channel_id() {
8722+ let short_channel_id = match self.funding .get_short_channel_id() {
87198723 Some(scid) => scid,
87208724 None => return None,
87218725 };
@@ -10982,7 +10986,7 @@ impl<SP: Deref> Writeable for FundedChannel<SP> where SP::Target: SignerProvider
1098210986
1098310987 self.funding.funding_tx_confirmed_in.write(writer)?;
1098410988 self.funding.funding_tx_confirmation_height.write(writer)?;
10985- self.context .short_channel_id.write(writer)?;
10989+ self.funding .short_channel_id.write(writer)?;
1098610990
1098710991 self.context.counterparty_dust_limit_satoshis.write(writer)?;
1098810992 self.context.holder_dust_limit_satoshis.write(writer)?;
@@ -11639,6 +11643,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, &'c Channel
1163911643 funding_transaction,
1164011644 funding_tx_confirmed_in,
1164111645 funding_tx_confirmation_height,
11646+ short_channel_id,
1164211647 },
1164311648 pending_funding: pending_funding.unwrap(),
1164411649 context: ChannelContext {
@@ -11702,7 +11707,6 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, &'c Channel
1170211707 closing_fee_limits: None,
1170311708 target_closing_feerate_sats_per_kw,
1170411709
11705- short_channel_id,
1170611710 channel_creation_height,
1170711711
1170811712 counterparty_dust_limit_satoshis,
0 commit comments