@@ -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))]
@@ -1830,6 +1835,13 @@ impl FundingScope {
1830
1835
1831
1836
height.checked_sub(self.funding_tx_confirmation_height).map_or(0, |c| c + 1)
1832
1837
}
1838
+
1839
+ /// Gets the channel's `short_channel_id`.
1840
+ ///
1841
+ /// Will return `None` if the funding hasn't been confirmed yet.
1842
+ pub fn get_short_channel_id(&self) -> Option<u64> {
1843
+ self.short_channel_id
1844
+ }
1833
1845
}
1834
1846
1835
1847
/// Info about a pending splice, used in the pre-splice channel
@@ -1989,7 +2001,6 @@ pub(super) struct ChannelContext<SP: Deref> where SP::Target: SignerProvider {
1989
2001
/// milliseconds, so any accidental force-closes here should be exceedingly rare.
1990
2002
expecting_peer_commitment_signed: bool,
1991
2003
1992
- short_channel_id: Option<u64>,
1993
2004
/// Either the height at which this channel was created or the height at which it was last
1994
2005
/// serialized if it was serialized by versions prior to 0.0.103.
1995
2006
/// We use this to close if funding is never broadcasted.
@@ -2800,6 +2811,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
2800
2811
funding_transaction: None,
2801
2812
funding_tx_confirmed_in: None,
2802
2813
funding_tx_confirmation_height: 0,
2814
+ short_channel_id: None,
2803
2815
};
2804
2816
let channel_context = ChannelContext {
2805
2817
user_id,
@@ -2863,7 +2875,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
2863
2875
closing_fee_limits: None,
2864
2876
target_closing_feerate_sats_per_kw: None,
2865
2877
2866
- short_channel_id: None,
2867
2878
channel_creation_height: current_chain_height,
2868
2879
2869
2880
feerate_per_kw: open_channel_fields.commitment_feerate_sat_per_1000_weight,
@@ -3036,6 +3047,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
3036
3047
funding_transaction: None,
3037
3048
funding_tx_confirmed_in: None,
3038
3049
funding_tx_confirmation_height: 0,
3050
+ short_channel_id: None,
3039
3051
};
3040
3052
let channel_context = Self {
3041
3053
user_id,
@@ -3097,7 +3109,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
3097
3109
closing_fee_limits: None,
3098
3110
target_closing_feerate_sats_per_kw: None,
3099
3111
3100
- short_channel_id: None,
3101
3112
channel_creation_height: current_chain_height,
3102
3113
3103
3114
feerate_per_kw: commitment_feerate,
@@ -3307,13 +3318,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
3307
3318
self.user_id
3308
3319
}
3309
3320
3310
- /// Gets the channel's `short_channel_id`.
3311
- ///
3312
- /// Will return `None` if the channel hasn't been confirmed yet.
3313
- pub fn get_short_channel_id(&self) -> Option<u64> {
3314
- self.short_channel_id
3315
- }
3316
-
3317
3321
/// Allowed in any state (including after shutdown)
3318
3322
pub fn latest_inbound_scid_alias(&self) -> Option<u64> {
3319
3323
self.latest_inbound_scid_alias
@@ -5526,7 +5530,7 @@ impl<SP: Deref> FundedChannel<SP> where
5526
5530
}
5527
5531
5528
5532
if let Some(scid_alias) = msg.short_channel_id_alias {
5529
- if Some(scid_alias) != self.context .short_channel_id {
5533
+ if Some(scid_alias) != self.funding .short_channel_id {
5530
5534
// The scid alias provided can be used to route payments *from* our counterparty,
5531
5535
// i.e. can be used for inbound payments and provided in invoices, but is not used
5532
5536
// when routing outbound payments.
@@ -8202,7 +8206,7 @@ impl<SP: Deref> FundedChannel<SP> where
8202
8206
8203
8207
self.funding.funding_tx_confirmation_height = height;
8204
8208
self.funding.funding_tx_confirmed_in = Some(*block_hash);
8205
- self.context .short_channel_id = match scid_from_parts(height as u64, index_in_block as u64, txo_idx as u64) {
8209
+ self.funding .short_channel_id = match scid_from_parts(height as u64, index_in_block as u64, txo_idx as u64) {
8206
8210
Ok(scid) => Some(scid),
8207
8211
Err(_) => panic!("Block was bogus - either height was > 16 million, had > 16 million transactions, or had > 65k outputs"),
8208
8212
}
@@ -8382,7 +8386,7 @@ impl<SP: Deref> FundedChannel<SP> where
8382
8386
return Err(ChannelError::Ignore("Cannot get a ChannelAnnouncement if the channel is not currently usable".to_owned()));
8383
8387
}
8384
8388
8385
- let short_channel_id = self.context .get_short_channel_id()
8389
+ let short_channel_id = self.funding .get_short_channel_id()
8386
8390
.ok_or(ChannelError::Ignore("Cannot get a ChannelAnnouncement if the channel has not been confirmed yet".to_owned()))?;
8387
8391
let node_id = NodeId::from_pubkey(&node_signer.get_node_id(Recipient::Node)
8388
8392
.map_err(|_| ChannelError::Ignore("Failed to retrieve own public key".to_owned()))?);
@@ -8454,7 +8458,7 @@ impl<SP: Deref> FundedChannel<SP> where
8454
8458
},
8455
8459
Ok(v) => v
8456
8460
};
8457
- let short_channel_id = match self.context .get_short_channel_id() {
8461
+ let short_channel_id = match self.funding .get_short_channel_id() {
8458
8462
Some(scid) => scid,
8459
8463
None => return None,
8460
8464
};
@@ -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