@@ -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
@@ -5531,7 +5535,7 @@ impl<SP: Deref> FundedChannel<SP> where
5531
5535
}
5532
5536
5533
5537
if let Some(scid_alias) = msg.short_channel_id_alias {
5534
- if Some(scid_alias) != self.context .short_channel_id {
5538
+ if Some(scid_alias) != self.funding .short_channel_id {
5535
5539
// The scid alias provided can be used to route payments *from* our counterparty,
5536
5540
// i.e. can be used for inbound payments and provided in invoices, but is not used
5537
5541
// when routing outbound payments.
@@ -8207,7 +8211,7 @@ impl<SP: Deref> FundedChannel<SP> where
8207
8211
8208
8212
self.funding.funding_tx_confirmation_height = height;
8209
8213
self.funding.funding_tx_confirmed_in = Some(*block_hash);
8210
- self.context .short_channel_id = match scid_from_parts(height as u64, index_in_block as u64, txo_idx as u64) {
8214
+ self.funding .short_channel_id = match scid_from_parts(height as u64, index_in_block as u64, txo_idx as u64) {
8211
8215
Ok(scid) => Some(scid),
8212
8216
Err(_) => panic!("Block was bogus - either height was > 16 million, had > 16 million transactions, or had > 65k outputs"),
8213
8217
}
@@ -8387,7 +8391,7 @@ impl<SP: Deref> FundedChannel<SP> where
8387
8391
return Err(ChannelError::Ignore("Cannot get a ChannelAnnouncement if the channel is not currently usable".to_owned()));
8388
8392
}
8389
8393
8390
- let short_channel_id = self.context .get_short_channel_id()
8394
+ let short_channel_id = self.funding .get_short_channel_id()
8391
8395
.ok_or(ChannelError::Ignore("Cannot get a ChannelAnnouncement if the channel has not been confirmed yet".to_owned()))?;
8392
8396
let node_id = NodeId::from_pubkey(&node_signer.get_node_id(Recipient::Node)
8393
8397
.map_err(|_| ChannelError::Ignore("Failed to retrieve own public key".to_owned()))?);
@@ -8459,7 +8463,7 @@ impl<SP: Deref> FundedChannel<SP> where
8459
8463
},
8460
8464
Ok(v) => v
8461
8465
};
8462
- let short_channel_id = match self.context .get_short_channel_id() {
8466
+ let short_channel_id = match self.funding .get_short_channel_id() {
8463
8467
Some(scid) => scid,
8464
8468
None => return None,
8465
8469
};
@@ -10701,7 +10705,7 @@ impl<SP: Deref> Writeable for FundedChannel<SP> where SP::Target: SignerProvider
10701
10705
10702
10706
self.funding.funding_tx_confirmed_in.write(writer)?;
10703
10707
self.funding.funding_tx_confirmation_height.write(writer)?;
10704
- self.context .short_channel_id.write(writer)?;
10708
+ self.funding .short_channel_id.write(writer)?;
10705
10709
10706
10710
self.context.counterparty_dust_limit_satoshis.write(writer)?;
10707
10711
self.context.holder_dust_limit_satoshis.write(writer)?;
@@ -11337,6 +11341,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, &'c Channel
11337
11341
funding_transaction,
11338
11342
funding_tx_confirmed_in,
11339
11343
funding_tx_confirmation_height,
11344
+ short_channel_id,
11340
11345
},
11341
11346
pending_funding: pending_funding.unwrap(),
11342
11347
context: ChannelContext {
@@ -11400,7 +11405,6 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, &'c Channel
11400
11405
closing_fee_limits: None,
11401
11406
target_closing_feerate_sats_per_kw,
11402
11407
11403
- short_channel_id,
11404
11408
channel_creation_height,
11405
11409
11406
11410
counterparty_dust_limit_satoshis,
0 commit comments