Skip to content

Commit 744d16e

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 86a5630 commit 744d16e

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
@@ -5470,15 +5470,23 @@ where
54705470
}
54715471

54725472
fn check_funding_meets_minimum_depth(&self, funding: &FundingScope, height: u32) -> bool {
5473-
let minimum_depth = funding.minimum_depth_override.or(self.minimum_depth);
5473+
let minimum_depth = funding
5474+
.minimum_depth_override
5475+
.or(self.minimum_depth)
5476+
.expect("ChannelContext::minimum_depth should be set for FundedChannel");
54745477

5475-
if funding.funding_tx_confirmation_height == 0 && minimum_depth != Some(0) {
5478+
// Zero-conf channels always meet the minimum depth.
5479+
if minimum_depth == 0 {
5480+
return true;
5481+
}
5482+
5483+
if funding.funding_tx_confirmation_height == 0 {
54765484
return false;
54775485
}
54785486

54795487
let funding_tx_confirmations =
54805488
height as i64 - funding.funding_tx_confirmation_height as i64 + 1;
5481-
if funding_tx_confirmations < minimum_depth.unwrap_or(0) as i64 {
5489+
if funding_tx_confirmations < minimum_depth as i64 {
54825490
return false;
54835491
}
54845492

0 commit comments

Comments
 (0)