@@ -1960,6 +1960,8 @@ pub(super) struct FundingScope {
1960
1960
/// The transaction which funds this channel. Note that for manually-funded channels (i.e.,
1961
1961
/// [`ChannelContext::is_manual_broadcast`] is true) this will be a dummy empty transaction.
1962
1962
funding_transaction: Option<Transaction>,
1963
+ /// The hash of the block in which the funding transaction was included.
1964
+ funding_tx_confirmed_in: Option<BlockHash>,
1963
1965
}
1964
1966
1965
1967
impl Writeable for FundingScope {
@@ -1970,6 +1972,7 @@ impl Writeable for FundingScope {
1970
1972
(5, self.holder_selected_channel_reserve_satoshis, required),
1971
1973
(7, self.channel_transaction_parameters, (required: ReadableArgs, None)),
1972
1974
(9, self.funding_transaction, option),
1975
+ (11, self.funding_tx_confirmed_in, option),
1973
1976
});
1974
1977
Ok(())
1975
1978
}
@@ -1983,13 +1986,15 @@ impl Readable for FundingScope {
1983
1986
let mut holder_selected_channel_reserve_satoshis = RequiredWrapper(None);
1984
1987
let mut channel_transaction_parameters = RequiredWrapper(None);
1985
1988
let mut funding_transaction = None;
1989
+ let mut funding_tx_confirmed_in = None;
1986
1990
1987
1991
read_tlv_fields!(reader, {
1988
1992
(1, value_to_self_msat, required),
1989
1993
(3, counterparty_selected_channel_reserve_satoshis, option),
1990
1994
(5, holder_selected_channel_reserve_satoshis, required),
1991
1995
(7, channel_transaction_parameters, (required: ReadableArgs, None)),
1992
1996
(9, funding_transaction, option),
1997
+ (11, funding_tx_confirmed_in, option),
1993
1998
});
1994
1999
1995
2000
Ok(Self {
@@ -2002,6 +2007,7 @@ impl Readable for FundingScope {
2002
2007
counterparty_max_commitment_tx_output: Mutex::new((0, 0)),
2003
2008
channel_transaction_parameters: channel_transaction_parameters.0.unwrap(),
2004
2009
funding_transaction,
2010
+ funding_tx_confirmed_in,
2005
2011
#[cfg(any(test, fuzzing))]
2006
2012
next_local_commitment_tx_fee_info_cached: Mutex::new(None),
2007
2013
#[cfg(any(test, fuzzing))]
@@ -2239,8 +2245,6 @@ where
2239
2245
/// milliseconds, so any accidental force-closes here should be exceedingly rare.
2240
2246
expecting_peer_commitment_signed: bool,
2241
2247
2242
- /// The hash of the block in which the funding transaction was included.
2243
- funding_tx_confirmed_in: Option<BlockHash>,
2244
2248
funding_tx_confirmation_height: u32,
2245
2249
short_channel_id: Option<u64>,
2246
2250
/// Either the height at which this channel was created or the height at which it was last
@@ -3088,6 +3092,7 @@ where
3088
3092
channel_value_satoshis,
3089
3093
},
3090
3094
funding_transaction: None,
3095
+ funding_tx_confirmed_in: None,
3091
3096
};
3092
3097
let channel_context = ChannelContext {
3093
3098
user_id,
@@ -3151,7 +3156,6 @@ where
3151
3156
closing_fee_limits: None,
3152
3157
target_closing_feerate_sats_per_kw: None,
3153
3158
3154
- funding_tx_confirmed_in: None,
3155
3159
funding_tx_confirmation_height: 0,
3156
3160
short_channel_id: None,
3157
3161
channel_creation_height: current_chain_height,
@@ -3329,6 +3333,7 @@ where
3329
3333
channel_value_satoshis,
3330
3334
},
3331
3335
funding_transaction: None,
3336
+ funding_tx_confirmed_in: None,
3332
3337
};
3333
3338
let channel_context = Self {
3334
3339
user_id,
@@ -3390,7 +3395,6 @@ where
3390
3395
closing_fee_limits: None,
3391
3396
target_closing_feerate_sats_per_kw: None,
3392
3397
3393
- funding_tx_confirmed_in: None,
3394
3398
funding_tx_confirmation_height: 0,
3395
3399
short_channel_id: None,
3396
3400
channel_creation_height: current_chain_height,
@@ -3798,11 +3802,6 @@ where
3798
3802
Ok(())
3799
3803
}
3800
3804
3801
- /// Returns the block hash in which our funding transaction was confirmed.
3802
- pub fn get_funding_tx_confirmed_in(&self) -> Option<BlockHash> {
3803
- self.funding_tx_confirmed_in
3804
- }
3805
-
3806
3805
/// Returns the current number of confirmations on the funding transaction.
3807
3806
pub fn get_funding_tx_confirmations(&self, height: u32) -> u32 {
3808
3807
if self.funding_tx_confirmation_height == 0 {
@@ -8899,7 +8898,7 @@ where
8899
8898
}
8900
8899
}
8901
8900
self.context.funding_tx_confirmation_height = height;
8902
- self.context .funding_tx_confirmed_in = Some(*block_hash);
8901
+ self.funding .funding_tx_confirmed_in = Some(*block_hash);
8903
8902
self.context.short_channel_id = match scid_from_parts(height as u64, index_in_block as u64, txo_idx as u64) {
8904
8903
Ok(scid) => Some(scid),
8905
8904
Err(_) => panic!("Block was bogus - either height was > 16 million, had > 16 million transactions, or had > 65k outputs"),
@@ -9015,12 +9014,12 @@ where
9015
9014
// 0-conf channel, but not doing so may lead to the
9016
9015
// `ChannelManager::short_to_chan_info` map being inconsistent, so we currently have
9017
9016
// to.
9018
- if funding_tx_confirmations == 0 && self.context .funding_tx_confirmed_in.is_some() {
9017
+ if funding_tx_confirmations == 0 && self.funding .funding_tx_confirmed_in.is_some() {
9019
9018
let err_reason = format!("Funding transaction was un-confirmed. Locked at {} confs, now have {} confs.",
9020
9019
self.context.minimum_depth.unwrap(), funding_tx_confirmations);
9021
9020
return Err(ClosureReason::ProcessingError { err: err_reason });
9022
9021
}
9023
- } else if !self.funding.is_outbound() && self.context .funding_tx_confirmed_in.is_none() &&
9022
+ } else if !self.funding.is_outbound() && self.funding .funding_tx_confirmed_in.is_none() &&
9024
9023
height >= self.context.channel_creation_height + FUNDING_CONF_DEADLINE_BLOCKS {
9025
9024
log_info!(logger, "Closing channel {} due to funding timeout", &self.context.channel_id);
9026
9025
// If funding_tx_confirmed_in is unset, the channel must not be active
@@ -10200,6 +10199,11 @@ where
10200
10199
false
10201
10200
}
10202
10201
}
10202
+
10203
+ /// Returns the block hash in which our funding transaction was confirmed.
10204
+ pub fn get_funding_tx_confirmed_in(&self) -> Option<BlockHash> {
10205
+ self.funding.funding_tx_confirmed_in
10206
+ }
10203
10207
}
10204
10208
10205
10209
/// A not-yet-funded outbound (from holder) channel using V1 channel establishment.
@@ -11501,7 +11505,7 @@ where
11501
11505
// consider the stale state on reload.
11502
11506
0u8.write(writer)?;
11503
11507
11504
- self.context .funding_tx_confirmed_in.write(writer)?;
11508
+ self.funding .funding_tx_confirmed_in.write(writer)?;
11505
11509
self.context.funding_tx_confirmation_height.write(writer)?;
11506
11510
self.context.short_channel_id.write(writer)?;
11507
11511
@@ -12160,6 +12164,7 @@ where
12160
12164
12161
12165
channel_transaction_parameters: channel_parameters,
12162
12166
funding_transaction,
12167
+ funding_tx_confirmed_in,
12163
12168
},
12164
12169
pending_funding: pending_funding.unwrap(),
12165
12170
context: ChannelContext {
@@ -12223,7 +12228,6 @@ where
12223
12228
closing_fee_limits: None,
12224
12229
target_closing_feerate_sats_per_kw,
12225
12230
12226
- funding_tx_confirmed_in,
12227
12231
funding_tx_confirmation_height,
12228
12232
short_channel_id,
12229
12233
channel_creation_height,
0 commit comments