Skip to content

Commit a4e0de3

Browse files
committed
f - can_send_update_fee
1 parent b1018d1 commit a4e0de3

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

lightning/src/ln/channel.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6738,11 +6738,13 @@ impl<SP: Deref> FundedChannel<SP> where
67386738
panic!("Cannot update fee while peer is disconnected/we're awaiting a monitor update (ChannelManager should have caught this)");
67396739
}
67406740

6741-
core::iter::once(&self.funding)
6741+
let can_send_update_fee = core::iter::once(&self.funding)
67426742
.chain(self.pending_funding.iter())
6743-
.map(|funding| self.validate_send_update_fee(funding, feerate_per_kw, fee_estimator, logger))
6744-
.collect::<Result<(), ()>>()
6745-
.ok()?;
6743+
.map(|funding| self.can_send_update_fee(funding, feerate_per_kw, fee_estimator, logger))
6744+
.all(|can_send_update_fee| can_send_update_fee);
6745+
if !can_send_update_fee {
6746+
return None;
6747+
}
67466748

67476749
// Some of the checks of `can_generate_new_commitment` have already been done above, but
67486750
// it's much more brittle to not use it in favor of checking the remaining flags left, as it
@@ -6765,10 +6767,10 @@ impl<SP: Deref> FundedChannel<SP> where
67656767
})
67666768
}
67676769

6768-
fn validate_send_update_fee<F: Deref, L: Deref>(
6770+
fn can_send_update_fee<F: Deref, L: Deref>(
67696771
&self, funding: &FundingScope, feerate_per_kw: u32,
67706772
fee_estimator: &LowerBoundedFeeEstimator<F>, logger: &L,
6771-
) -> Result<(), ()>
6773+
) -> bool
67726774
where
67736775
F::Target: FeeEstimator,
67746776
L::Target: Logger,
@@ -6785,21 +6787,21 @@ impl<SP: Deref> FundedChannel<SP> where
67856787
if holder_balance_msat < buffer_fee_msat + commitment_data.stats.total_anchors_sat * 1000 + funding.counterparty_selected_channel_reserve_satoshis.unwrap() * 1000 {
67866788
//TODO: auto-close after a number of failures?
67876789
log_debug!(logger, "Cannot afford to send new feerate at {}", feerate_per_kw);
6788-
return Err(());
6790+
return false;
67896791
}
67906792

67916793
// Note, we evaluate pending htlc "preemptive" trimmed-to-dust threshold at the proposed `feerate_per_kw`.
67926794
let max_dust_htlc_exposure_msat = self.context.get_max_dust_htlc_exposure_msat(dust_exposure_limiting_feerate);
67936795
if htlc_stats.on_holder_tx_dust_exposure_msat > max_dust_htlc_exposure_msat {
67946796
log_debug!(logger, "Cannot afford to send new feerate at {} without infringing max dust htlc exposure", feerate_per_kw);
6795-
return Err(());
6797+
return false;
67966798
}
67976799
if htlc_stats.on_counterparty_tx_dust_exposure_msat > max_dust_htlc_exposure_msat {
67986800
log_debug!(logger, "Cannot afford to send new feerate at {} without infringing max dust htlc exposure", feerate_per_kw);
6799-
return Err(());
6801+
return false;
68006802
}
68016803

6802-
Ok(())
6804+
return true;
68036805
}
68046806

68056807
/// Removes any uncommitted inbound HTLCs and resets the state of uncommitted outbound HTLC

0 commit comments

Comments
 (0)