@@ -1948,6 +1948,8 @@ pub(super) struct FundingScope {
1948
1948
/// The transaction which funds this channel. Note that for manually-funded channels (i.e.,
1949
1949
/// [`ChannelContext::is_manual_broadcast`] is true) this will be a dummy empty transaction.
1950
1950
funding_transaction: Option<Transaction>,
1951
+ /// The hash of the block in which the funding transaction was included.
1952
+ funding_tx_confirmed_in: Option<BlockHash>,
1951
1953
}
1952
1954
1953
1955
impl Writeable for FundingScope {
@@ -1958,6 +1960,7 @@ impl Writeable for FundingScope {
1958
1960
(5, self.holder_selected_channel_reserve_satoshis, required),
1959
1961
(7, self.channel_transaction_parameters, (required: ReadableArgs, None)),
1960
1962
(9, self.funding_transaction, option),
1963
+ (11, self.funding_tx_confirmed_in, option),
1961
1964
});
1962
1965
Ok(())
1963
1966
}
@@ -1971,13 +1974,15 @@ impl Readable for FundingScope {
1971
1974
let mut holder_selected_channel_reserve_satoshis = RequiredWrapper(None);
1972
1975
let mut channel_transaction_parameters = RequiredWrapper(None);
1973
1976
let mut funding_transaction = None;
1977
+ let mut funding_tx_confirmed_in = None;
1974
1978
1975
1979
read_tlv_fields!(reader, {
1976
1980
(1, value_to_self_msat, required),
1977
1981
(3, counterparty_selected_channel_reserve_satoshis, option),
1978
1982
(5, holder_selected_channel_reserve_satoshis, required),
1979
1983
(7, channel_transaction_parameters, (required: ReadableArgs, None)),
1980
1984
(9, funding_transaction, option),
1985
+ (11, funding_tx_confirmed_in, option),
1981
1986
});
1982
1987
1983
1988
Ok(Self {
@@ -1990,6 +1995,7 @@ impl Readable for FundingScope {
1990
1995
counterparty_max_commitment_tx_output: Mutex::new((0, 0)),
1991
1996
channel_transaction_parameters: channel_transaction_parameters.0.unwrap(),
1992
1997
funding_transaction,
1998
+ funding_tx_confirmed_in,
1993
1999
#[cfg(any(test, fuzzing))]
1994
2000
next_local_commitment_tx_fee_info_cached: Mutex::new(None),
1995
2001
#[cfg(any(test, fuzzing))]
@@ -2227,8 +2233,6 @@ where
2227
2233
/// milliseconds, so any accidental force-closes here should be exceedingly rare.
2228
2234
expecting_peer_commitment_signed: bool,
2229
2235
2230
- /// The hash of the block in which the funding transaction was included.
2231
- funding_tx_confirmed_in: Option<BlockHash>,
2232
2236
funding_tx_confirmation_height: u32,
2233
2237
short_channel_id: Option<u64>,
2234
2238
/// Either the height at which this channel was created or the height at which it was last
@@ -3072,6 +3076,7 @@ where
3072
3076
channel_value_satoshis,
3073
3077
},
3074
3078
funding_transaction: None,
3079
+ funding_tx_confirmed_in: None,
3075
3080
};
3076
3081
let channel_context = ChannelContext {
3077
3082
user_id,
@@ -3135,7 +3140,6 @@ where
3135
3140
closing_fee_limits: None,
3136
3141
target_closing_feerate_sats_per_kw: None,
3137
3142
3138
- funding_tx_confirmed_in: None,
3139
3143
funding_tx_confirmation_height: 0,
3140
3144
short_channel_id: None,
3141
3145
channel_creation_height: current_chain_height,
@@ -3313,6 +3317,7 @@ where
3313
3317
channel_value_satoshis,
3314
3318
},
3315
3319
funding_transaction: None,
3320
+ funding_tx_confirmed_in: None,
3316
3321
};
3317
3322
let channel_context = Self {
3318
3323
user_id,
@@ -3374,7 +3379,6 @@ where
3374
3379
closing_fee_limits: None,
3375
3380
target_closing_feerate_sats_per_kw: None,
3376
3381
3377
- funding_tx_confirmed_in: None,
3378
3382
funding_tx_confirmation_height: 0,
3379
3383
short_channel_id: None,
3380
3384
channel_creation_height: current_chain_height,
@@ -3784,11 +3788,6 @@ where
3784
3788
Ok(())
3785
3789
}
3786
3790
3787
- /// Returns the block hash in which our funding transaction was confirmed.
3788
- pub fn get_funding_tx_confirmed_in(&self) -> Option<BlockHash> {
3789
- self.funding_tx_confirmed_in
3790
- }
3791
-
3792
3791
/// Returns the current number of confirmations on the funding transaction.
3793
3792
pub fn get_funding_tx_confirmations(&self, height: u32) -> u32 {
3794
3793
if self.funding_tx_confirmation_height == 0 {
@@ -8855,7 +8854,7 @@ where
8855
8854
}
8856
8855
}
8857
8856
self.context.funding_tx_confirmation_height = height;
8858
- self.context .funding_tx_confirmed_in = Some(*block_hash);
8857
+ self.funding .funding_tx_confirmed_in = Some(*block_hash);
8859
8858
self.context.short_channel_id = match scid_from_parts(height as u64, index_in_block as u64, txo_idx as u64) {
8860
8859
Ok(scid) => Some(scid),
8861
8860
Err(_) => panic!("Block was bogus - either height was > 16 million, had > 16 million transactions, or had > 65k outputs"),
@@ -8967,12 +8966,12 @@ where
8967
8966
// 0-conf channel, but not doing so may lead to the
8968
8967
// `ChannelManager::short_to_chan_info` map being inconsistent, so we currently have
8969
8968
// to.
8970
- if funding_tx_confirmations == 0 && self.context .funding_tx_confirmed_in.is_some() {
8969
+ if funding_tx_confirmations == 0 && self.funding .funding_tx_confirmed_in.is_some() {
8971
8970
let err_reason = format!("Funding transaction was un-confirmed. Locked at {} confs, now have {} confs.",
8972
8971
self.context.minimum_depth.unwrap(), funding_tx_confirmations);
8973
8972
return Err(ClosureReason::ProcessingError { err: err_reason });
8974
8973
}
8975
- } else if !self.funding.is_outbound() && self.context .funding_tx_confirmed_in.is_none() &&
8974
+ } else if !self.funding.is_outbound() && self.funding .funding_tx_confirmed_in.is_none() &&
8976
8975
height >= self.context.channel_creation_height + FUNDING_CONF_DEADLINE_BLOCKS {
8977
8976
log_info!(logger, "Closing channel {} due to funding timeout", &self.context.channel_id);
8978
8977
// If funding_tx_confirmed_in is unset, the channel must not be active
@@ -10154,6 +10153,11 @@ where
10154
10153
false
10155
10154
}
10156
10155
}
10156
+
10157
+ /// Returns the block hash in which our funding transaction was confirmed.
10158
+ pub fn get_funding_tx_confirmed_in(&self) -> Option<BlockHash> {
10159
+ self.funding.funding_tx_confirmed_in
10160
+ }
10157
10161
}
10158
10162
10159
10163
/// A not-yet-funded outbound (from holder) channel using V1 channel establishment.
@@ -11448,7 +11452,7 @@ where
11448
11452
// consider the stale state on reload.
11449
11453
0u8.write(writer)?;
11450
11454
11451
- self.context .funding_tx_confirmed_in.write(writer)?;
11455
+ self.funding .funding_tx_confirmed_in.write(writer)?;
11452
11456
self.context.funding_tx_confirmation_height.write(writer)?;
11453
11457
self.context.short_channel_id.write(writer)?;
11454
11458
@@ -12107,6 +12111,7 @@ where
12107
12111
12108
12112
channel_transaction_parameters: channel_parameters,
12109
12113
funding_transaction,
12114
+ funding_tx_confirmed_in,
12110
12115
},
12111
12116
pending_funding: pending_funding.unwrap(),
12112
12117
context: ChannelContext {
@@ -12170,7 +12175,6 @@ where
12170
12175
closing_fee_limits: None,
12171
12176
target_closing_feerate_sats_per_kw,
12172
12177
12173
- funding_tx_confirmed_in,
12174
12178
funding_tx_confirmation_height,
12175
12179
short_channel_id,
12176
12180
channel_creation_height,
0 commit comments