Skip to content

Commit 506c271

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 9707653 commit 506c271

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

lightning/src/ln/channel.rs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7036,13 +7036,31 @@ 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+
.map(|funding| FundedChannel::<SP>::check_remote_fee(funding.get_channel_type(), fee_estimator, msg.feerate_per_kw, Some(self.context.feerate_per_kw), logger))
7043+
.collect::<Result<(), ChannelError>>()?;
70407044

70417045
self.context.pending_update_fee = Some((msg.feerate_per_kw, FeeUpdateState::RemoteAnnounced));
70427046
self.context.update_time_counter += 1;
7047+
7048+
core::iter::once(&self.funding)
7049+
.chain(self.pending_funding.iter())
7050+
.map(|funding| self.validate_update_fee(funding, fee_estimator, msg))
7051+
.collect::<Result<(), ChannelError>>()
7052+
}
7053+
7054+
fn validate_update_fee<F: Deref>(
7055+
&self, funding: &FundingScope, fee_estimator: &LowerBoundedFeeEstimator<F>,
7056+
msg: &msgs::UpdateFee,
7057+
) -> Result<(), ChannelError>
7058+
where
7059+
F::Target: FeeEstimator,
7060+
{
70437061
// Check that we won't be pushed over our dust exposure limit by the feerate increase.
70447062
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);
7063+
let htlc_stats = self.context.get_pending_htlc_stats(funding, None, dust_exposure_limiting_feerate);
70467064
let max_dust_htlc_exposure_msat = self.context.get_max_dust_htlc_exposure_msat(dust_exposure_limiting_feerate);
70477065
if htlc_stats.on_holder_tx_dust_exposure_msat > max_dust_htlc_exposure_msat {
70487066
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)