@@ -1688,6 +1688,7 @@ pub(super) struct FundingScope {
16881688 /// The hash of the block in which the funding transaction was included.
16891689 funding_tx_confirmed_in: Option<BlockHash>,
16901690 funding_tx_confirmation_height: u32,
1691+ short_channel_id: Option<u64>,
16911692}
16921693
16931694impl Writeable for FundingScope {
@@ -1700,6 +1701,7 @@ impl Writeable for FundingScope {
17001701 (9, self.funding_transaction, option),
17011702 (11, self.funding_tx_confirmed_in, option),
17021703 (13, self.funding_tx_confirmation_height, required),
1704+ (15, self.short_channel_id, option),
17031705 });
17041706 Ok(())
17051707 }
@@ -1714,6 +1716,7 @@ impl Readable for FundingScope {
17141716 let mut funding_transaction = None;
17151717 let mut funding_tx_confirmed_in = None;
17161718 let mut funding_tx_confirmation_height = RequiredWrapper(None);
1719+ let mut short_channel_id = None;
17171720
17181721 read_tlv_fields!(reader, {
17191722 (1, value_to_self_msat, required),
@@ -1723,6 +1726,7 @@ impl Readable for FundingScope {
17231726 (9, funding_transaction, option),
17241727 (11, funding_tx_confirmed_in, option),
17251728 (13, funding_tx_confirmation_height, required),
1729+ (15, short_channel_id, option),
17261730 });
17271731
17281732 Ok(Self {
@@ -1737,6 +1741,7 @@ impl Readable for FundingScope {
17371741 funding_transaction,
17381742 funding_tx_confirmed_in,
17391743 funding_tx_confirmation_height: funding_tx_confirmation_height.0.unwrap(),
1744+ short_channel_id,
17401745 #[cfg(any(test, fuzzing))]
17411746 next_local_commitment_tx_fee_info_cached: Mutex::new(None),
17421747 #[cfg(any(test, fuzzing))]
@@ -1835,6 +1840,13 @@ impl FundingScope {
18351840
18361841 height.checked_sub(self.funding_tx_confirmation_height).map_or(0, |c| c + 1)
18371842 }
1843+
1844+ /// Gets the channel's `short_channel_id`.
1845+ ///
1846+ /// Will return `None` if the funding hasn't been confirmed yet.
1847+ pub fn get_short_channel_id(&self) -> Option<u64> {
1848+ self.short_channel_id
1849+ }
18381850}
18391851
18401852/// Info about a pending splice, used in the pre-splice channel
@@ -1994,7 +2006,6 @@ pub(super) struct ChannelContext<SP: Deref> where SP::Target: SignerProvider {
19942006 /// milliseconds, so any accidental force-closes here should be exceedingly rare.
19952007 expecting_peer_commitment_signed: bool,
19962008
1997- short_channel_id: Option<u64>,
19982009 /// Either the height at which this channel was created or the height at which it was last
19992010 /// serialized if it was serialized by versions prior to 0.0.103.
20002011 /// We use this to close if funding is never broadcasted.
@@ -2805,6 +2816,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
28052816 funding_transaction: None,
28062817 funding_tx_confirmed_in: None,
28072818 funding_tx_confirmation_height: 0,
2819+ short_channel_id: None,
28082820 };
28092821 let channel_context = ChannelContext {
28102822 user_id,
@@ -2868,7 +2880,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
28682880 closing_fee_limits: None,
28692881 target_closing_feerate_sats_per_kw: None,
28702882
2871- short_channel_id: None,
28722883 channel_creation_height: current_chain_height,
28732884
28742885 feerate_per_kw: open_channel_fields.commitment_feerate_sat_per_1000_weight,
@@ -3041,6 +3052,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
30413052 funding_transaction: None,
30423053 funding_tx_confirmed_in: None,
30433054 funding_tx_confirmation_height: 0,
3055+ short_channel_id: None,
30443056 };
30453057 let channel_context = Self {
30463058 user_id,
@@ -3102,7 +3114,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
31023114 closing_fee_limits: None,
31033115 target_closing_feerate_sats_per_kw: None,
31043116
3105- short_channel_id: None,
31063117 channel_creation_height: current_chain_height,
31073118
31083119 feerate_per_kw: commitment_feerate,
@@ -3312,13 +3323,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
33123323 self.user_id
33133324 }
33143325
3315- /// Gets the channel's `short_channel_id`.
3316- ///
3317- /// Will return `None` if the channel hasn't been confirmed yet.
3318- pub fn get_short_channel_id(&self) -> Option<u64> {
3319- self.short_channel_id
3320- }
3321-
33223326 /// Allowed in any state (including after shutdown)
33233327 pub fn latest_inbound_scid_alias(&self) -> Option<u64> {
33243328 self.latest_inbound_scid_alias
@@ -4862,7 +4866,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
48624866 return Err(ChannelError::Ignore("Cannot get a ChannelAnnouncement if the channel is not currently usable".to_owned()));
48634867 }
48644868
4865- let short_channel_id = self .get_short_channel_id()
4869+ let short_channel_id = funding .get_short_channel_id()
48664870 .ok_or(ChannelError::Ignore("Cannot get a ChannelAnnouncement if the channel has not been confirmed yet".to_owned()))?;
48674871 let node_id = NodeId::from_pubkey(&node_signer.get_node_id(Recipient::Node)
48684872 .map_err(|_| ChannelError::Ignore("Failed to retrieve own public key".to_owned()))?);
@@ -4934,7 +4938,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
49344938 },
49354939 Ok(v) => v
49364940 };
4937- let short_channel_id = match self .get_short_channel_id() {
4941+ let short_channel_id = match funding .get_short_channel_id() {
49384942 Some(scid) => scid,
49394943 None => return None,
49404944 };
@@ -5634,7 +5638,7 @@ impl<SP: Deref> FundedChannel<SP> where
56345638 }
56355639
56365640 if let Some(scid_alias) = msg.short_channel_id_alias {
5637- if Some(scid_alias) != self.context .short_channel_id {
5641+ if Some(scid_alias) != self.funding .short_channel_id {
56385642 // The scid alias provided can be used to route payments *from* our counterparty,
56395643 // i.e. can be used for inbound payments and provided in invoices, but is not used
56405644 // when routing outbound payments.
@@ -8314,7 +8318,7 @@ impl<SP: Deref> FundedChannel<SP> where
83148318
83158319 self.funding.funding_tx_confirmation_height = height;
83168320 self.funding.funding_tx_confirmed_in = Some(*block_hash);
8317- self.context .short_channel_id = match scid_from_parts(height as u64, index_in_block as u64, txo_idx as u64) {
8321+ self.funding .short_channel_id = match scid_from_parts(height as u64, index_in_block as u64, txo_idx as u64) {
83188322 Ok(scid) => Some(scid),
83198323 Err(_) => panic!("Block was bogus - either height was > 16 million, had > 16 million transactions, or had > 65k outputs"),
83208324 };
@@ -10730,7 +10734,7 @@ impl<SP: Deref> Writeable for FundedChannel<SP> where SP::Target: SignerProvider
1073010734
1073110735 self.funding.funding_tx_confirmed_in.write(writer)?;
1073210736 self.funding.funding_tx_confirmation_height.write(writer)?;
10733- self.context .short_channel_id.write(writer)?;
10737+ self.funding .short_channel_id.write(writer)?;
1073410738
1073510739 self.context.counterparty_dust_limit_satoshis.write(writer)?;
1073610740 self.context.holder_dust_limit_satoshis.write(writer)?;
@@ -11366,6 +11370,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, &'c Channel
1136611370 funding_transaction,
1136711371 funding_tx_confirmed_in,
1136811372 funding_tx_confirmation_height,
11373+ short_channel_id,
1136911374 },
1137011375 pending_funding: pending_funding.unwrap(),
1137111376 context: ChannelContext {
@@ -11429,7 +11434,6 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, &'c Channel
1142911434 closing_fee_limits: None,
1143011435 target_closing_feerate_sats_per_kw,
1143111436
11432- short_channel_id,
1143311437 channel_creation_height,
1143411438
1143511439 counterparty_dust_limit_satoshis,
0 commit comments