@@ -1685,6 +1685,8 @@ pub(super) struct FundingScope {
1685
1685
/// The transaction which funds this channel. Note that for manually-funded channels (i.e.,
1686
1686
/// [`ChannelContext::is_manual_broadcast`] is true) this will be a dummy empty transaction.
1687
1687
funding_transaction: Option<Transaction>,
1688
+ /// The hash of the block in which the funding transaction was included.
1689
+ funding_tx_confirmed_in: Option<BlockHash>,
1688
1690
}
1689
1691
1690
1692
impl Writeable for FundingScope {
@@ -1695,6 +1697,7 @@ impl Writeable for FundingScope {
1695
1697
(5, self.holder_selected_channel_reserve_satoshis, required),
1696
1698
(7, self.channel_transaction_parameters, (required: ReadableArgs, None)),
1697
1699
(9, self.funding_transaction, option),
1700
+ (11, self.funding_tx_confirmed_in, option),
1698
1701
});
1699
1702
Ok(())
1700
1703
}
@@ -1707,13 +1710,15 @@ impl Readable for FundingScope {
1707
1710
let mut holder_selected_channel_reserve_satoshis = RequiredWrapper(None);
1708
1711
let mut channel_transaction_parameters = RequiredWrapper(None);
1709
1712
let mut funding_transaction = None;
1713
+ let mut funding_tx_confirmed_in = None;
1710
1714
1711
1715
read_tlv_fields!(reader, {
1712
1716
(1, value_to_self_msat, required),
1713
1717
(3, counterparty_selected_channel_reserve_satoshis, option),
1714
1718
(5, holder_selected_channel_reserve_satoshis, required),
1715
1719
(7, channel_transaction_parameters, (required: ReadableArgs, None)),
1716
1720
(9, funding_transaction, option),
1721
+ (11, funding_tx_confirmed_in, option),
1717
1722
});
1718
1723
1719
1724
Ok(Self {
@@ -1726,6 +1731,7 @@ impl Readable for FundingScope {
1726
1731
counterparty_max_commitment_tx_output: Mutex::new((0, 0)),
1727
1732
channel_transaction_parameters: channel_transaction_parameters.0.unwrap(),
1728
1733
funding_transaction,
1734
+ funding_tx_confirmed_in,
1729
1735
#[cfg(any(test, fuzzing))]
1730
1736
next_local_commitment_tx_fee_info_cached: Mutex::new(None),
1731
1737
#[cfg(any(test, fuzzing))]
@@ -1799,6 +1805,11 @@ impl FundingScope {
1799
1805
pub fn get_channel_type(&self) -> &ChannelTypeFeatures {
1800
1806
&self.channel_transaction_parameters.channel_type_features
1801
1807
}
1808
+
1809
+ /// Returns the block hash in which our funding transaction was confirmed.
1810
+ pub fn get_funding_tx_confirmed_in(&self) -> Option<BlockHash> {
1811
+ self.funding_tx_confirmed_in
1812
+ }
1802
1813
}
1803
1814
1804
1815
/// Info about a pending splice, used in the pre-splice channel
@@ -1958,8 +1969,6 @@ pub(super) struct ChannelContext<SP: Deref> where SP::Target: SignerProvider {
1958
1969
/// milliseconds, so any accidental force-closes here should be exceedingly rare.
1959
1970
expecting_peer_commitment_signed: bool,
1960
1971
1961
- /// The hash of the block in which the funding transaction was included.
1962
- funding_tx_confirmed_in: Option<BlockHash>,
1963
1972
funding_tx_confirmation_height: u32,
1964
1973
short_channel_id: Option<u64>,
1965
1974
/// Either the height at which this channel was created or the height at which it was last
@@ -2770,6 +2779,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
2770
2779
channel_value_satoshis,
2771
2780
},
2772
2781
funding_transaction: None,
2782
+ funding_tx_confirmed_in: None,
2773
2783
};
2774
2784
let channel_context = ChannelContext {
2775
2785
user_id,
@@ -2833,7 +2843,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
2833
2843
closing_fee_limits: None,
2834
2844
target_closing_feerate_sats_per_kw: None,
2835
2845
2836
- funding_tx_confirmed_in: None,
2837
2846
funding_tx_confirmation_height: 0,
2838
2847
short_channel_id: None,
2839
2848
channel_creation_height: current_chain_height,
@@ -3006,6 +3015,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
3006
3015
channel_value_satoshis,
3007
3016
},
3008
3017
funding_transaction: None,
3018
+ funding_tx_confirmed_in: None,
3009
3019
};
3010
3020
let channel_context = Self {
3011
3021
user_id,
@@ -3067,7 +3077,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
3067
3077
closing_fee_limits: None,
3068
3078
target_closing_feerate_sats_per_kw: None,
3069
3079
3070
- funding_tx_confirmed_in: None,
3071
3080
funding_tx_confirmation_height: 0,
3072
3081
short_channel_id: None,
3073
3082
channel_creation_height: current_chain_height,
@@ -3460,11 +3469,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
3460
3469
Ok(())
3461
3470
}
3462
3471
3463
- /// Returns the block hash in which our funding transaction was confirmed.
3464
- pub fn get_funding_tx_confirmed_in(&self) -> Option<BlockHash> {
3465
- self.funding_tx_confirmed_in
3466
- }
3467
-
3468
3472
/// Returns the current number of confirmations on the funding transaction.
3469
3473
pub fn get_funding_tx_confirmations(&self, height: u32) -> u32 {
3470
3474
if self.funding_tx_confirmation_height == 0 {
@@ -8197,7 +8201,7 @@ impl<SP: Deref> FundedChannel<SP> where
8197
8201
}
8198
8202
}
8199
8203
self.context.funding_tx_confirmation_height = height;
8200
- self.context .funding_tx_confirmed_in = Some(*block_hash);
8204
+ self.funding .funding_tx_confirmed_in = Some(*block_hash);
8201
8205
self.context.short_channel_id = match scid_from_parts(height as u64, index_in_block as u64, txo_idx as u64) {
8202
8206
Ok(scid) => Some(scid),
8203
8207
Err(_) => panic!("Block was bogus - either height was > 16 million, had > 16 million transactions, or had > 65k outputs"),
@@ -8307,12 +8311,12 @@ impl<SP: Deref> FundedChannel<SP> where
8307
8311
// 0-conf channel, but not doing so may lead to the
8308
8312
// `ChannelManager::short_to_chan_info` map being inconsistent, so we currently have
8309
8313
// to.
8310
- if funding_tx_confirmations == 0 && self.context .funding_tx_confirmed_in.is_some() {
8314
+ if funding_tx_confirmations == 0 && self.funding .funding_tx_confirmed_in.is_some() {
8311
8315
let err_reason = format!("Funding transaction was un-confirmed. Locked at {} confs, now have {} confs.",
8312
8316
self.context.minimum_depth.unwrap(), funding_tx_confirmations);
8313
8317
return Err(ClosureReason::ProcessingError { err: err_reason });
8314
8318
}
8315
- } else if !self.funding.is_outbound() && self.context .funding_tx_confirmed_in.is_none() &&
8319
+ } else if !self.funding.is_outbound() && self.funding .funding_tx_confirmed_in.is_none() &&
8316
8320
height >= self.context.channel_creation_height + FUNDING_CONF_DEADLINE_BLOCKS {
8317
8321
log_info!(logger, "Closing channel {} due to funding timeout", &self.context.channel_id);
8318
8322
// If funding_tx_confirmed_in is unset, the channel must not be active
@@ -10690,7 +10694,7 @@ impl<SP: Deref> Writeable for FundedChannel<SP> where SP::Target: SignerProvider
10690
10694
// consider the stale state on reload.
10691
10695
0u8.write(writer)?;
10692
10696
10693
- self.context .funding_tx_confirmed_in.write(writer)?;
10697
+ self.funding .funding_tx_confirmed_in.write(writer)?;
10694
10698
self.context.funding_tx_confirmation_height.write(writer)?;
10695
10699
self.context.short_channel_id.write(writer)?;
10696
10700
@@ -11326,6 +11330,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, &'c Channel
11326
11330
11327
11331
channel_transaction_parameters: channel_parameters,
11328
11332
funding_transaction,
11333
+ funding_tx_confirmed_in,
11329
11334
},
11330
11335
pending_funding: pending_funding.unwrap(),
11331
11336
context: ChannelContext {
@@ -11389,7 +11394,6 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, &'c Channel
11389
11394
closing_fee_limits: None,
11390
11395
target_closing_feerate_sats_per_kw,
11391
11396
11392
- funding_tx_confirmed_in,
11393
11397
funding_tx_confirmation_height,
11394
11398
short_channel_id,
11395
11399
channel_creation_height,
0 commit comments