@@ -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 {
@@ -8305,7 +8309,7 @@ impl<SP: Deref> FundedChannel<SP> where
8305
8309
}
8306
8310
8307
8311
self.context.funding_tx_confirmation_height = height;
8308
- self.context .funding_tx_confirmed_in = Some(*block_hash);
8312
+ self.funding .funding_tx_confirmed_in = Some(*block_hash);
8309
8313
self.context.short_channel_id = match scid_from_parts(height as u64, index_in_block as u64, txo_idx as u64) {
8310
8314
Ok(scid) => Some(scid),
8311
8315
Err(_) => panic!("Block was bogus - either height was > 16 million, had > 16 million transactions, or had > 65k outputs"),
@@ -8422,12 +8426,12 @@ impl<SP: Deref> FundedChannel<SP> where
8422
8426
// 0-conf channel, but not doing so may lead to the
8423
8427
// `ChannelManager::short_to_chan_info` map being inconsistent, so we currently have
8424
8428
// to.
8425
- if funding_tx_confirmations == 0 && self.context .funding_tx_confirmed_in.is_some() {
8429
+ if funding_tx_confirmations == 0 && self.funding .funding_tx_confirmed_in.is_some() {
8426
8430
let err_reason = format!("Funding transaction was un-confirmed. Locked at {} confs, now have {} confs.",
8427
8431
self.context.minimum_depth.unwrap(), funding_tx_confirmations);
8428
8432
return Err(ClosureReason::ProcessingError { err: err_reason });
8429
8433
}
8430
- } else if !self.funding.is_outbound() && self.context .funding_tx_confirmed_in.is_none() &&
8434
+ } else if !self.funding.is_outbound() && self.funding .funding_tx_confirmed_in.is_none() &&
8431
8435
height >= self.context.channel_creation_height + FUNDING_CONF_DEADLINE_BLOCKS {
8432
8436
log_info!(logger, "Closing channel {} due to funding timeout", &self.context.channel_id);
8433
8437
// If funding_tx_confirmed_in is unset, the channel must not be active
@@ -10720,7 +10724,7 @@ impl<SP: Deref> Writeable for FundedChannel<SP> where SP::Target: SignerProvider
10720
10724
// consider the stale state on reload.
10721
10725
0u8.write(writer)?;
10722
10726
10723
- self.context .funding_tx_confirmed_in.write(writer)?;
10727
+ self.funding .funding_tx_confirmed_in.write(writer)?;
10724
10728
self.context.funding_tx_confirmation_height.write(writer)?;
10725
10729
self.context.short_channel_id.write(writer)?;
10726
10730
@@ -11356,6 +11360,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, &'c Channel
11356
11360
11357
11361
channel_transaction_parameters: channel_parameters,
11358
11362
funding_transaction,
11363
+ funding_tx_confirmed_in,
11359
11364
},
11360
11365
pending_funding: pending_funding.unwrap(),
11361
11366
context: ChannelContext {
@@ -11419,7 +11424,6 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, &'c Channel
11419
11424
closing_fee_limits: None,
11420
11425
target_closing_feerate_sats_per_kw,
11421
11426
11422
- funding_tx_confirmed_in,
11423
11427
funding_tx_confirmation_height,
11424
11428
short_channel_id,
11425
11429
channel_creation_height,
0 commit comments