Skip to content

Commit 7715481

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 811da64 commit 7715481

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

lightning/src/ln/channel.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5272,14 +5272,21 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
52725272
}
52735273

52745274
fn check_funding_meets_minimum_depth(&self, funding: &FundingScope, height: u32) -> bool {
5275-
let minimum_depth = funding.minimum_depth_override.or(self.minimum_depth);
5275+
let minimum_depth = funding.minimum_depth_override
5276+
.or(self.minimum_depth)
5277+
.expect("ChannelContext::minimum_depth should be set for FundedChannel");
52765278

5277-
if funding.funding_tx_confirmation_height == 0 && minimum_depth != Some(0) {
5279+
// Zero-conf channels always meet the minimum depth.
5280+
if minimum_depth == 0 {
5281+
return true;
5282+
}
5283+
5284+
if funding.funding_tx_confirmation_height == 0 {
52785285
return false;
52795286
}
52805287

52815288
let funding_tx_confirmations = height as i64 - funding.funding_tx_confirmation_height as i64 + 1;
5282-
if funding_tx_confirmations < minimum_depth.unwrap_or(0) as i64 {
5289+
if funding_tx_confirmations < minimum_depth as i64 {
52835290
return false;
52845291
}
52855292

0 commit comments

Comments
 (0)