@@ -1688,6 +1688,7 @@ pub(super) struct FundingScope {
1688
1688
/// The hash of the block in which the funding transaction was included.
1689
1689
funding_tx_confirmed_in: Option<BlockHash>,
1690
1690
funding_tx_confirmation_height: u32,
1691
+ short_channel_id: Option<u64>,
1691
1692
}
1692
1693
1693
1694
impl Writeable for FundingScope {
@@ -1700,6 +1701,7 @@ impl Writeable for FundingScope {
1700
1701
(9, self.funding_transaction, option),
1701
1702
(11, self.funding_tx_confirmed_in, option),
1702
1703
(13, self.funding_tx_confirmation_height, required),
1704
+ (15, self.short_channel_id, option),
1703
1705
});
1704
1706
Ok(())
1705
1707
}
@@ -1714,6 +1716,7 @@ impl Readable for FundingScope {
1714
1716
let mut funding_transaction = None;
1715
1717
let mut funding_tx_confirmed_in = None;
1716
1718
let mut funding_tx_confirmation_height = RequiredWrapper(None);
1719
+ let mut short_channel_id = None;
1717
1720
1718
1721
read_tlv_fields!(reader, {
1719
1722
(1, value_to_self_msat, required),
@@ -1723,6 +1726,7 @@ impl Readable for FundingScope {
1723
1726
(9, funding_transaction, option),
1724
1727
(11, funding_tx_confirmed_in, option),
1725
1728
(13, funding_tx_confirmation_height, required),
1729
+ (15, short_channel_id, option),
1726
1730
});
1727
1731
1728
1732
Ok(Self {
@@ -1737,6 +1741,7 @@ impl Readable for FundingScope {
1737
1741
funding_transaction,
1738
1742
funding_tx_confirmed_in,
1739
1743
funding_tx_confirmation_height: funding_tx_confirmation_height.0.unwrap(),
1744
+ short_channel_id,
1740
1745
#[cfg(any(test, fuzzing))]
1741
1746
next_local_commitment_tx_fee_info_cached: Mutex::new(None),
1742
1747
#[cfg(any(test, fuzzing))]
@@ -1835,6 +1840,13 @@ impl FundingScope {
1835
1840
1836
1841
height.checked_sub(self.funding_tx_confirmation_height).map_or(0, |c| c + 1)
1837
1842
}
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
+ }
1838
1850
}
1839
1851
1840
1852
/// 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 {
1994
2006
/// milliseconds, so any accidental force-closes here should be exceedingly rare.
1995
2007
expecting_peer_commitment_signed: bool,
1996
2008
1997
- short_channel_id: Option<u64>,
1998
2009
/// Either the height at which this channel was created or the height at which it was last
1999
2010
/// serialized if it was serialized by versions prior to 0.0.103.
2000
2011
/// We use this to close if funding is never broadcasted.
@@ -2805,6 +2816,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
2805
2816
funding_transaction: None,
2806
2817
funding_tx_confirmed_in: None,
2807
2818
funding_tx_confirmation_height: 0,
2819
+ short_channel_id: None,
2808
2820
};
2809
2821
let channel_context = ChannelContext {
2810
2822
user_id,
@@ -2868,7 +2880,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
2868
2880
closing_fee_limits: None,
2869
2881
target_closing_feerate_sats_per_kw: None,
2870
2882
2871
- short_channel_id: None,
2872
2883
channel_creation_height: current_chain_height,
2873
2884
2874
2885
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 {
3041
3052
funding_transaction: None,
3042
3053
funding_tx_confirmed_in: None,
3043
3054
funding_tx_confirmation_height: 0,
3055
+ short_channel_id: None,
3044
3056
};
3045
3057
let channel_context = Self {
3046
3058
user_id,
@@ -3102,7 +3114,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
3102
3114
closing_fee_limits: None,
3103
3115
target_closing_feerate_sats_per_kw: None,
3104
3116
3105
- short_channel_id: None,
3106
3117
channel_creation_height: current_chain_height,
3107
3118
3108
3119
feerate_per_kw: commitment_feerate,
@@ -3312,13 +3323,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
3312
3323
self.user_id
3313
3324
}
3314
3325
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
-
3322
3326
/// Allowed in any state (including after shutdown)
3323
3327
pub fn latest_inbound_scid_alias(&self) -> Option<u64> {
3324
3328
self.latest_inbound_scid_alias
@@ -4862,7 +4866,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
4862
4866
return Err(ChannelError::Ignore("Cannot get a ChannelAnnouncement if the channel is not currently usable".to_owned()));
4863
4867
}
4864
4868
4865
- let short_channel_id = self .get_short_channel_id()
4869
+ let short_channel_id = funding .get_short_channel_id()
4866
4870
.ok_or(ChannelError::Ignore("Cannot get a ChannelAnnouncement if the channel has not been confirmed yet".to_owned()))?;
4867
4871
let node_id = NodeId::from_pubkey(&node_signer.get_node_id(Recipient::Node)
4868
4872
.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 {
4934
4938
},
4935
4939
Ok(v) => v
4936
4940
};
4937
- let short_channel_id = match self .get_short_channel_id() {
4941
+ let short_channel_id = match funding .get_short_channel_id() {
4938
4942
Some(scid) => scid,
4939
4943
None => return None,
4940
4944
};
@@ -5634,7 +5638,7 @@ impl<SP: Deref> FundedChannel<SP> where
5634
5638
}
5635
5639
5636
5640
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 {
5638
5642
// The scid alias provided can be used to route payments *from* our counterparty,
5639
5643
// i.e. can be used for inbound payments and provided in invoices, but is not used
5640
5644
// when routing outbound payments.
@@ -8314,7 +8318,7 @@ impl<SP: Deref> FundedChannel<SP> where
8314
8318
8315
8319
self.funding.funding_tx_confirmation_height = height;
8316
8320
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) {
8318
8322
Ok(scid) => Some(scid),
8319
8323
Err(_) => panic!("Block was bogus - either height was > 16 million, had > 16 million transactions, or had > 65k outputs"),
8320
8324
};
@@ -10730,7 +10734,7 @@ impl<SP: Deref> Writeable for FundedChannel<SP> where SP::Target: SignerProvider
10730
10734
10731
10735
self.funding.funding_tx_confirmed_in.write(writer)?;
10732
10736
self.funding.funding_tx_confirmation_height.write(writer)?;
10733
- self.context .short_channel_id.write(writer)?;
10737
+ self.funding .short_channel_id.write(writer)?;
10734
10738
10735
10739
self.context.counterparty_dust_limit_satoshis.write(writer)?;
10736
10740
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
11366
11370
funding_transaction,
11367
11371
funding_tx_confirmed_in,
11368
11372
funding_tx_confirmation_height,
11373
+ short_channel_id,
11369
11374
},
11370
11375
pending_funding: pending_funding.unwrap(),
11371
11376
context: ChannelContext {
@@ -11429,7 +11434,6 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, &'c Channel
11429
11434
closing_fee_limits: None,
11430
11435
target_closing_feerate_sats_per_kw,
11431
11436
11432
- short_channel_id,
11433
11437
channel_creation_height,
11434
11438
11435
11439
counterparty_dust_limit_satoshis,
0 commit comments