Skip to content

Commit 1482111

Browse files
committed
Special case 0-conf in check_funding_meets_minimum_depth
0-conf channels always meet the funding minimum depth once accepted. Special case this in check_funding_meets_minimum_depth such that it isn't implicit in later calculations. Since a minimum depth is always set when the channel is accepted, expect this to be the case in the method since it should only be called on a ChannelContext in a FundedChannel.
1 parent f9ad4a0 commit 1482111

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

lightning/src/ln/channel.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5482,15 +5482,23 @@ where
54825482
}
54835483

54845484
fn check_funding_meets_minimum_depth(&self, funding: &FundingScope, height: u32) -> bool {
5485-
let minimum_depth = funding.minimum_depth_override.or(self.minimum_depth);
5485+
let minimum_depth = funding
5486+
.minimum_depth_override
5487+
.or(self.minimum_depth)
5488+
.expect("ChannelContext::minimum_depth should be set for FundedChannel");
54865489

5487-
if funding.funding_tx_confirmation_height == 0 && minimum_depth != Some(0) {
5490+
// Zero-conf channels always meet the minimum depth.
5491+
if minimum_depth == 0 {
5492+
return true;
5493+
}
5494+
5495+
if funding.funding_tx_confirmation_height == 0 {
54885496
return false;
54895497
}
54905498

54915499
let funding_tx_confirmations =
54925500
height as i64 - funding.funding_tx_confirmation_height as i64 + 1;
5493-
if funding_tx_confirmations < minimum_depth.unwrap_or(0) as i64 {
5501+
if funding_tx_confirmations < minimum_depth as i64 {
54945502
return false;
54955503
}
54965504

0 commit comments

Comments
 (0)