@@ -1951,6 +1951,7 @@ pub(super) struct FundingScope {
1951
1951
/// The hash of the block in which the funding transaction was included.
1952
1952
funding_tx_confirmed_in: Option<BlockHash>,
1953
1953
funding_tx_confirmation_height: u32,
1954
+ short_channel_id: Option<u64>,
1954
1955
}
1955
1956
1956
1957
impl Writeable for FundingScope {
@@ -1963,6 +1964,7 @@ impl Writeable for FundingScope {
1963
1964
(9, self.funding_transaction, option),
1964
1965
(11, self.funding_tx_confirmed_in, option),
1965
1966
(13, self.funding_tx_confirmation_height, required),
1967
+ (15, self.short_channel_id, option),
1966
1968
});
1967
1969
Ok(())
1968
1970
}
@@ -1978,6 +1980,7 @@ impl Readable for FundingScope {
1978
1980
let mut funding_transaction = None;
1979
1981
let mut funding_tx_confirmed_in = None;
1980
1982
let mut funding_tx_confirmation_height = RequiredWrapper(None);
1983
+ let mut short_channel_id = None;
1981
1984
1982
1985
read_tlv_fields!(reader, {
1983
1986
(1, value_to_self_msat, required),
@@ -1987,6 +1990,7 @@ impl Readable for FundingScope {
1987
1990
(9, funding_transaction, option),
1988
1991
(11, funding_tx_confirmed_in, option),
1989
1992
(13, funding_tx_confirmation_height, required),
1993
+ (15, short_channel_id, option),
1990
1994
});
1991
1995
1992
1996
Ok(Self {
@@ -2001,6 +2005,7 @@ impl Readable for FundingScope {
2001
2005
funding_transaction,
2002
2006
funding_tx_confirmed_in,
2003
2007
funding_tx_confirmation_height: funding_tx_confirmation_height.0.unwrap(),
2008
+ short_channel_id,
2004
2009
#[cfg(any(test, fuzzing))]
2005
2010
next_local_commitment_tx_fee_info_cached: Mutex::new(None),
2006
2011
#[cfg(any(test, fuzzing))]
@@ -2097,6 +2102,13 @@ impl FundingScope {
2097
2102
2098
2103
height.checked_sub(self.funding_tx_confirmation_height).map_or(0, |c| c + 1)
2099
2104
}
2105
+
2106
+ /// Gets the channel's `short_channel_id`.
2107
+ ///
2108
+ /// Will return `None` if the funding hasn't been confirmed yet.
2109
+ pub fn get_short_channel_id(&self) -> Option<u64> {
2110
+ self.short_channel_id
2111
+ }
2100
2112
}
2101
2113
2102
2114
/// Info about a pending splice, used in the pre-splice channel
@@ -2258,7 +2270,6 @@ where
2258
2270
/// milliseconds, so any accidental force-closes here should be exceedingly rare.
2259
2271
expecting_peer_commitment_signed: bool,
2260
2272
2261
- short_channel_id: Option<u64>,
2262
2273
/// Either the height at which this channel was created or the height at which it was last
2263
2274
/// serialized if it was serialized by versions prior to 0.0.103.
2264
2275
/// We use this to close if funding is never broadcasted.
@@ -3102,6 +3113,7 @@ where
3102
3113
funding_transaction: None,
3103
3114
funding_tx_confirmed_in: None,
3104
3115
funding_tx_confirmation_height: 0,
3116
+ short_channel_id: None,
3105
3117
};
3106
3118
let channel_context = ChannelContext {
3107
3119
user_id,
@@ -3165,7 +3177,6 @@ where
3165
3177
closing_fee_limits: None,
3166
3178
target_closing_feerate_sats_per_kw: None,
3167
3179
3168
- short_channel_id: None,
3169
3180
channel_creation_height: current_chain_height,
3170
3181
3171
3182
feerate_per_kw: open_channel_fields.commitment_feerate_sat_per_1000_weight,
@@ -3343,6 +3354,7 @@ where
3343
3354
funding_transaction: None,
3344
3355
funding_tx_confirmed_in: None,
3345
3356
funding_tx_confirmation_height: 0,
3357
+ short_channel_id: None,
3346
3358
};
3347
3359
let channel_context = Self {
3348
3360
user_id,
@@ -3404,7 +3416,6 @@ where
3404
3416
closing_fee_limits: None,
3405
3417
target_closing_feerate_sats_per_kw: None,
3406
3418
3407
- short_channel_id: None,
3408
3419
channel_creation_height: current_chain_height,
3409
3420
3410
3421
feerate_per_kw: commitment_feerate,
@@ -3629,13 +3640,6 @@ where
3629
3640
self.user_id
3630
3641
}
3631
3642
3632
- /// Gets the channel's `short_channel_id`.
3633
- ///
3634
- /// Will return `None` if the channel hasn't been confirmed yet.
3635
- pub fn get_short_channel_id(&self) -> Option<u64> {
3636
- self.short_channel_id
3637
- }
3638
-
3639
3643
/// Allowed in any state (including after shutdown)
3640
3644
pub fn latest_inbound_scid_alias(&self) -> Option<u64> {
3641
3645
self.latest_inbound_scid_alias
@@ -6168,7 +6172,7 @@ where
6168
6172
}
6169
6173
6170
6174
if let Some(scid_alias) = msg.short_channel_id_alias {
6171
- if Some(scid_alias) != self.context .short_channel_id {
6175
+ if Some(scid_alias) != self.funding .short_channel_id {
6172
6176
// The scid alias provided can be used to route payments *from* our counterparty,
6173
6177
// i.e. can be used for inbound payments and provided in invoices, but is not used
6174
6178
// when routing outbound payments.
@@ -8860,7 +8864,7 @@ where
8860
8864
8861
8865
self.funding.funding_tx_confirmation_height = height;
8862
8866
self.funding.funding_tx_confirmed_in = Some(*block_hash);
8863
- self.context .short_channel_id = match scid_from_parts(height as u64, index_in_block as u64, txo_idx as u64) {
8867
+ self.funding .short_channel_id = match scid_from_parts(height as u64, index_in_block as u64, txo_idx as u64) {
8864
8868
Ok(scid) => Some(scid),
8865
8869
Err(_) => panic!("Block was bogus - either height was > 16 million, had > 16 million transactions, or had > 65k outputs"),
8866
8870
}
@@ -9044,7 +9048,7 @@ where
9044
9048
return Err(ChannelError::Ignore("Cannot get a ChannelAnnouncement if the channel is not currently usable".to_owned()));
9045
9049
}
9046
9050
9047
- let short_channel_id = self.context .get_short_channel_id()
9051
+ let short_channel_id = self.funding .get_short_channel_id()
9048
9052
.ok_or(ChannelError::Ignore("Cannot get a ChannelAnnouncement if the channel has not been confirmed yet".to_owned()))?;
9049
9053
let node_id = NodeId::from_pubkey(&node_signer.get_node_id(Recipient::Node)
9050
9054
.map_err(|_| ChannelError::Ignore("Failed to retrieve own public key".to_owned()))?);
@@ -9117,7 +9121,7 @@ where
9117
9121
},
9118
9122
Ok(v) => v
9119
9123
};
9120
- let short_channel_id = match self.context .get_short_channel_id() {
9124
+ let short_channel_id = match self.funding .get_short_channel_id() {
9121
9125
Some(scid) => scid,
9122
9126
None => return None,
9123
9127
};
@@ -11459,7 +11463,7 @@ where
11459
11463
11460
11464
self.funding.funding_tx_confirmed_in.write(writer)?;
11461
11465
self.funding.funding_tx_confirmation_height.write(writer)?;
11462
- self.context .short_channel_id.write(writer)?;
11466
+ self.funding .short_channel_id.write(writer)?;
11463
11467
11464
11468
self.context.counterparty_dust_limit_satoshis.write(writer)?;
11465
11469
self.context.holder_dust_limit_satoshis.write(writer)?;
@@ -12118,6 +12122,7 @@ where
12118
12122
funding_transaction,
12119
12123
funding_tx_confirmed_in,
12120
12124
funding_tx_confirmation_height,
12125
+ short_channel_id,
12121
12126
},
12122
12127
pending_funding: pending_funding.unwrap(),
12123
12128
context: ChannelContext {
@@ -12181,7 +12186,6 @@ where
12181
12186
closing_fee_limits: None,
12182
12187
target_closing_feerate_sats_per_kw,
12183
12188
12184
- short_channel_id,
12185
12189
channel_creation_height,
12186
12190
12187
12191
counterparty_dust_limit_satoshis,
0 commit comments