Skip to content

Commit 2a76bfe

Browse files
committed
Check pending funding when validating update_fee
If there are any pending splices when an update_fee message is received, it must be validated against each pending FundingScope. Otherwise, it may be invalid once the splice is locked.
1 parent df46875 commit 2a76bfe

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

lightning/src/ln/channel.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7036,13 +7036,29 @@ impl<SP: Deref> FundedChannel<SP> where
70367036
if self.context.channel_state.is_remote_stfu_sent() || self.context.channel_state.is_quiescent() {
70377037
return Err(ChannelError::WarnAndDisconnect("Got fee update message while quiescent".to_owned()));
70387038
}
7039-
FundedChannel::<SP>::check_remote_fee(self.funding.get_channel_type(), fee_estimator, msg.feerate_per_kw, Some(self.context.feerate_per_kw), logger)?;
7039+
7040+
core::iter::once(&self.funding)
7041+
.chain(self.pending_funding.iter())
7042+
.try_for_each(|funding| FundedChannel::<SP>::check_remote_fee(funding.get_channel_type(), fee_estimator, msg.feerate_per_kw, Some(self.context.feerate_per_kw), logger))?;
70407043

70417044
self.context.pending_update_fee = Some((msg.feerate_per_kw, FeeUpdateState::RemoteAnnounced));
70427045
self.context.update_time_counter += 1;
7046+
7047+
core::iter::once(&self.funding)
7048+
.chain(self.pending_funding.iter())
7049+
.try_for_each(|funding| self.validate_update_fee(funding, fee_estimator, msg))
7050+
}
7051+
7052+
fn validate_update_fee<F: Deref>(
7053+
&self, funding: &FundingScope, fee_estimator: &LowerBoundedFeeEstimator<F>,
7054+
msg: &msgs::UpdateFee,
7055+
) -> Result<(), ChannelError>
7056+
where
7057+
F::Target: FeeEstimator,
7058+
{
70437059
// Check that we won't be pushed over our dust exposure limit by the feerate increase.
70447060
let dust_exposure_limiting_feerate = self.context.get_dust_exposure_limiting_feerate(&fee_estimator);
7045-
let htlc_stats = self.context.get_pending_htlc_stats(&self.funding, None, dust_exposure_limiting_feerate);
7061+
let htlc_stats = self.context.get_pending_htlc_stats(funding, None, dust_exposure_limiting_feerate);
70467062
let max_dust_htlc_exposure_msat = self.context.get_max_dust_htlc_exposure_msat(dust_exposure_limiting_feerate);
70477063
if htlc_stats.on_holder_tx_dust_exposure_msat > max_dust_htlc_exposure_msat {
70487064
return Err(ChannelError::close(format!("Peer sent update_fee with a feerate ({}) which may over-expose us to dust-in-flight on our own transactions (totaling {} msat)",

0 commit comments

Comments
 (0)