@@ -1689,9 +1689,6 @@ pub(super) struct FundingScope {
1689
1689
funding_tx_confirmed_in: Option<BlockHash>,
1690
1690
funding_tx_confirmation_height: u32,
1691
1691
short_channel_id: Option<u64>,
1692
-
1693
- /// The number of confirmation required before sending `channel_ready` or `splice_locked`.
1694
- minimum_depth: Option<u32>,
1695
1692
}
1696
1693
1697
1694
impl Writeable for FundingScope {
@@ -1705,7 +1702,6 @@ impl Writeable for FundingScope {
1705
1702
(11, self.funding_tx_confirmed_in, option),
1706
1703
(13, self.funding_tx_confirmation_height, required),
1707
1704
(15, self.short_channel_id, option),
1708
- (17, self.minimum_depth, option),
1709
1705
});
1710
1706
Ok(())
1711
1707
}
@@ -1721,7 +1717,6 @@ impl Readable for FundingScope {
1721
1717
let mut funding_tx_confirmed_in = None;
1722
1718
let mut funding_tx_confirmation_height = RequiredWrapper(None);
1723
1719
let mut short_channel_id = None;
1724
- let mut minimum_depth = None;
1725
1720
1726
1721
read_tlv_fields!(reader, {
1727
1722
(1, value_to_self_msat, required),
@@ -1732,7 +1727,6 @@ impl Readable for FundingScope {
1732
1727
(11, funding_tx_confirmed_in, option),
1733
1728
(13, funding_tx_confirmation_height, required),
1734
1729
(15, short_channel_id, option),
1735
- (17, minimum_depth, option),
1736
1730
});
1737
1731
1738
1732
Ok(Self {
@@ -1748,7 +1742,6 @@ impl Readable for FundingScope {
1748
1742
funding_tx_confirmed_in,
1749
1743
funding_tx_confirmation_height: funding_tx_confirmation_height.0.unwrap(),
1750
1744
short_channel_id,
1751
- minimum_depth,
1752
1745
#[cfg(any(test, fuzzing))]
1753
1746
next_local_commitment_tx_fee_info_cached: Mutex::new(None),
1754
1747
#[cfg(any(test, fuzzing))]
@@ -1854,10 +1847,6 @@ impl FundingScope {
1854
1847
pub fn get_short_channel_id(&self) -> Option<u64> {
1855
1848
self.short_channel_id
1856
1849
}
1857
-
1858
- pub fn minimum_depth(&self) -> Option<u32> {
1859
- self.minimum_depth
1860
- }
1861
1850
}
1862
1851
1863
1852
/// Info about a pending splice, used in the pre-splice channel
@@ -2046,7 +2035,7 @@ pub(super) struct ChannelContext<SP: Deref> where SP::Target: SignerProvider {
2046
2035
#[cfg(not(any(test, feature="_test_utils")))]
2047
2036
counterparty_max_accepted_htlcs: u16,
2048
2037
holder_max_accepted_htlcs: u16,
2049
- negotiated_minimum_depth : Option<u32>,
2038
+ minimum_depth : Option<u32>,
2050
2039
2051
2040
counterparty_forwarding_info: Option<CounterpartyForwardingInfo>,
2052
2041
@@ -2828,7 +2817,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
2828
2817
funding_tx_confirmed_in: None,
2829
2818
funding_tx_confirmation_height: 0,
2830
2819
short_channel_id: None,
2831
- minimum_depth,
2832
2820
};
2833
2821
let channel_context = ChannelContext {
2834
2822
user_id,
@@ -2903,7 +2891,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
2903
2891
holder_htlc_minimum_msat: if config.channel_handshake_config.our_htlc_minimum_msat == 0 { 1 } else { config.channel_handshake_config.our_htlc_minimum_msat },
2904
2892
counterparty_max_accepted_htlcs: open_channel_fields.max_accepted_htlcs,
2905
2893
holder_max_accepted_htlcs: cmp::min(config.channel_handshake_config.our_max_accepted_htlcs, max_htlcs(&channel_type)),
2906
- negotiated_minimum_depth: minimum_depth,
2894
+ minimum_depth,
2907
2895
2908
2896
counterparty_forwarding_info: None,
2909
2897
@@ -3065,7 +3053,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
3065
3053
funding_tx_confirmed_in: None,
3066
3054
funding_tx_confirmation_height: 0,
3067
3055
short_channel_id: None,
3068
- minimum_depth: None, // Filled in in accept_channel
3069
3056
};
3070
3057
let channel_context = Self {
3071
3058
user_id,
@@ -3140,7 +3127,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
3140
3127
holder_htlc_minimum_msat: if config.channel_handshake_config.our_htlc_minimum_msat == 0 { 1 } else { config.channel_handshake_config.our_htlc_minimum_msat },
3141
3128
counterparty_max_accepted_htlcs: 0,
3142
3129
holder_max_accepted_htlcs: cmp::min(config.channel_handshake_config.our_max_accepted_htlcs, max_htlcs(&channel_type)),
3143
- negotiated_minimum_depth : None, // Filled in in accept_channel
3130
+ minimum_depth : None, // Filled in in accept_channel
3144
3131
3145
3132
counterparty_forwarding_info: None,
3146
3133
@@ -3326,6 +3313,10 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
3326
3313
self.temporary_channel_id
3327
3314
}
3328
3315
3316
+ pub fn minimum_depth(&self) -> Option<u32> {
3317
+ self.minimum_depth
3318
+ }
3319
+
3329
3320
/// Gets the "user_id" value passed into the construction of this channel. It has no special
3330
3321
/// meaning and exists only to allow users to have a persistent identifier of a channel.
3331
3322
pub fn get_user_id(&self) -> u128 {
@@ -3467,11 +3458,10 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
3467
3458
self.counterparty_max_accepted_htlcs = common_fields.max_accepted_htlcs;
3468
3459
3469
3460
if peer_limits.trust_own_funding_0conf {
3470
- funding .minimum_depth = Some(common_fields.minimum_depth);
3461
+ self .minimum_depth = Some(common_fields.minimum_depth);
3471
3462
} else {
3472
- funding .minimum_depth = Some(cmp::max(1, common_fields.minimum_depth));
3463
+ self .minimum_depth = Some(cmp::max(1, common_fields.minimum_depth));
3473
3464
}
3474
- self.negotiated_minimum_depth = funding.minimum_depth;
3475
3465
3476
3466
let counterparty_pubkeys = ChannelPublicKeys {
3477
3467
funding_pubkey: common_fields.funding_pubkey,
@@ -6771,7 +6761,7 @@ impl<SP: Deref> FundedChannel<SP> where
6771
6761
// the funding transaction confirmed before the monitor was persisted, or
6772
6762
// * a 0-conf channel and intended to send the channel_ready before any broadcast at all.
6773
6763
let channel_ready = if self.context.monitor_pending_channel_ready {
6774
- assert!(!self.funding.is_outbound() || self.funding .minimum_depth == Some(0),
6764
+ assert!(!self.funding.is_outbound() || self.context .minimum_depth == Some(0),
6775
6765
"Funding transaction broadcast by the local client before it should have - LDK didn't do it!");
6776
6766
self.context.monitor_pending_channel_ready = false;
6777
6767
self.get_channel_ready(logger)
@@ -8020,7 +8010,7 @@ impl<SP: Deref> FundedChannel<SP> where
8020
8010
) {
8021
8011
// If we're not a 0conf channel, we'll be waiting on a monitor update with only
8022
8012
// AwaitingChannelReady set, though our peer could have sent their channel_ready.
8023
- debug_assert!(self.funding .minimum_depth.unwrap_or(1) > 0);
8013
+ debug_assert!(self.context .minimum_depth.unwrap_or(1) > 0);
8024
8014
return true;
8025
8015
}
8026
8016
if self.holder_commitment_point.transaction_number() == INITIAL_COMMITMENT_NUMBER - 1 &&
@@ -8094,7 +8084,7 @@ impl<SP: Deref> FundedChannel<SP> where
8094
8084
// Called:
8095
8085
// * always when a new block/transactions are confirmed with the new height
8096
8086
// * when funding is signed with a height of 0
8097
- if self.funding.funding_tx_confirmation_height == 0 && self.funding .minimum_depth != Some(0) {
8087
+ if self.funding.funding_tx_confirmation_height == 0 && self.context .minimum_depth != Some(0) {
8098
8088
return None;
8099
8089
}
8100
8090
@@ -8103,7 +8093,7 @@ impl<SP: Deref> FundedChannel<SP> where
8103
8093
self.funding.funding_tx_confirmation_height = 0;
8104
8094
}
8105
8095
8106
- if funding_tx_confirmations < self.funding .minimum_depth.unwrap_or(0) as i64 {
8096
+ if funding_tx_confirmations < self.context .minimum_depth.unwrap_or(0) as i64 {
8107
8097
return None;
8108
8098
}
8109
8099
@@ -8229,9 +8219,9 @@ impl<SP: Deref> FundedChannel<SP> where
8229
8219
// If this is a coinbase transaction and not a 0-conf channel
8230
8220
// we should update our min_depth to 100 to handle coinbase maturity
8231
8221
if tx.is_coinbase() &&
8232
- self.funding .minimum_depth.unwrap_or(0) > 0 &&
8233
- self.funding .minimum_depth.unwrap_or(0) < COINBASE_MATURITY {
8234
- self.funding .minimum_depth = Some(COINBASE_MATURITY);
8222
+ self.context .minimum_depth.unwrap_or(0) > 0 &&
8223
+ self.context .minimum_depth.unwrap_or(0) < COINBASE_MATURITY {
8224
+ self.context .minimum_depth = Some(COINBASE_MATURITY);
8235
8225
}
8236
8226
}
8237
8227
// If we allow 1-conf funding, we may need to check for channel_ready here and
@@ -8332,7 +8322,7 @@ impl<SP: Deref> FundedChannel<SP> where
8332
8322
// to.
8333
8323
if funding_tx_confirmations == 0 && self.funding.funding_tx_confirmed_in.is_some() {
8334
8324
let err_reason = format!("Funding transaction was un-confirmed. Locked at {} confs, now have {} confs.",
8335
- self.funding .minimum_depth.unwrap(), funding_tx_confirmations);
8325
+ self.context .minimum_depth.unwrap(), funding_tx_confirmations);
8336
8326
return Err(ClosureReason::ProcessingError { err: err_reason });
8337
8327
}
8338
8328
} else if !self.funding.is_outbound() && self.funding.funding_tx_confirmed_in.is_none() &&
@@ -9618,9 +9608,9 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
9618
9608
// If the funding transaction is a coinbase transaction, we need to set the minimum depth to 100.
9619
9609
// We can skip this if it is a zero-conf channel.
9620
9610
if funding_transaction.is_coinbase() &&
9621
- self.funding .minimum_depth.unwrap_or(0) > 0 &&
9622
- self.funding .minimum_depth.unwrap_or(0) < COINBASE_MATURITY {
9623
- self.funding .minimum_depth = Some(COINBASE_MATURITY);
9611
+ self.context .minimum_depth.unwrap_or(0) > 0 &&
9612
+ self.context .minimum_depth.unwrap_or(0) < COINBASE_MATURITY {
9613
+ self.context .minimum_depth = Some(COINBASE_MATURITY);
9624
9614
}
9625
9615
9626
9616
debug_assert!(self.funding.funding_transaction.is_none());
@@ -9949,7 +9939,7 @@ impl<SP: Deref> InboundV1Channel<SP> where SP::Target: SignerProvider {
9949
9939
dust_limit_satoshis: self.context.holder_dust_limit_satoshis,
9950
9940
max_htlc_value_in_flight_msat: self.context.holder_max_htlc_value_in_flight_msat,
9951
9941
htlc_minimum_msat: self.context.holder_htlc_minimum_msat,
9952
- minimum_depth: self.funding .minimum_depth.unwrap(),
9942
+ minimum_depth: self.context .minimum_depth.unwrap(),
9953
9943
to_self_delay: self.funding.get_holder_selected_contest_delay(),
9954
9944
max_accepted_htlcs: self.context.holder_max_accepted_htlcs,
9955
9945
funding_pubkey: keys.funding_pubkey,
@@ -10361,7 +10351,7 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
10361
10351
dust_limit_satoshis: self.context.holder_dust_limit_satoshis,
10362
10352
max_htlc_value_in_flight_msat: self.context.holder_max_htlc_value_in_flight_msat,
10363
10353
htlc_minimum_msat: self.context.holder_htlc_minimum_msat,
10364
- minimum_depth: self.funding .minimum_depth.unwrap(),
10354
+ minimum_depth: self.context .minimum_depth.unwrap(),
10365
10355
to_self_delay: self.funding.get_holder_selected_contest_delay(),
10366
10356
max_accepted_htlcs: self.context.holder_max_accepted_htlcs,
10367
10357
funding_pubkey: keys.funding_pubkey,
@@ -10729,7 +10719,7 @@ impl<SP: Deref> Writeable for FundedChannel<SP> where SP::Target: SignerProvider
10729
10719
self.context.counterparty_max_accepted_htlcs.write(writer)?;
10730
10720
10731
10721
// Note that this field is ignored by 0.0.99+ as the TLV Optional variant is used instead.
10732
- self.context.negotiated_minimum_depth .unwrap_or(0).write(writer)?;
10722
+ self.context.minimum_depth .unwrap_or(0).write(writer)?;
10733
10723
10734
10724
match &self.context.counterparty_forwarding_info {
10735
10725
Some(info) => {
@@ -10804,7 +10794,7 @@ impl<SP: Deref> Writeable for FundedChannel<SP> where SP::Target: SignerProvider
10804
10794
// here. On the read side, old versions will simply ignore the odd-type entries here,
10805
10795
// and new versions map the default values to None and allow the TLV entries here to
10806
10796
// override that.
10807
- (1, self.funding .minimum_depth, option),
10797
+ (1, self.context .minimum_depth, option),
10808
10798
(2, chan_type, option),
10809
10799
(3, self.funding.counterparty_selected_channel_reserve_satoshis, option),
10810
10800
(4, serialized_holder_selected_reserve, option),
@@ -10840,7 +10830,6 @@ impl<SP: Deref> Writeable for FundedChannel<SP> where SP::Target: SignerProvider
10840
10830
(54, self.pending_funding, optional_vec), // Added in 0.2
10841
10831
(55, removed_htlc_failure_attribution_data, optional_vec), // Added in 0.2
10842
10832
(57, holding_cell_failure_attribution_data, optional_vec), // Added in 0.2
10843
- (59, self.context.negotiated_minimum_depth, option), // Added in 0.2
10844
10833
});
10845
10834
10846
10835
Ok(())
@@ -11139,7 +11128,6 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, &'c Channel
11139
11128
let mut is_manual_broadcast = None;
11140
11129
11141
11130
let mut pending_funding = Some(Vec::new());
11142
- let mut negotiated_minimum_depth: Option<u32> = None;
11143
11131
11144
11132
read_tlv_fields!(reader, {
11145
11133
(0, announcement_sigs, option),
@@ -11179,7 +11167,6 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, &'c Channel
11179
11167
(54, pending_funding, optional_vec), // Added in 0.2
11180
11168
(55, removed_htlc_failure_attribution_data, optional_vec),
11181
11169
(57, holding_cell_failure_attribution_data, optional_vec),
11182
- (59, negotiated_minimum_depth, option), // Added in 0.2
11183
11170
});
11184
11171
11185
11172
let holder_signer = signer_provider.derive_channel_signer(channel_keys_id);
@@ -11355,7 +11342,6 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, &'c Channel
11355
11342
funding_tx_confirmed_in,
11356
11343
funding_tx_confirmation_height,
11357
11344
short_channel_id,
11358
- minimum_depth,
11359
11345
},
11360
11346
pending_funding: pending_funding.unwrap(),
11361
11347
context: ChannelContext {
@@ -11428,8 +11414,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, &'c Channel
11428
11414
counterparty_htlc_minimum_msat,
11429
11415
holder_htlc_minimum_msat,
11430
11416
counterparty_max_accepted_htlcs,
11431
- // TODO: But what if minimum_depth (TLV 1) had been overridden with COINBASE_MATURITY?
11432
- negotiated_minimum_depth: negotiated_minimum_depth.or(minimum_depth),
11417
+ minimum_depth,
11433
11418
11434
11419
counterparty_forwarding_info,
11435
11420
0 commit comments