Skip to content

Commit 1ac2f4c

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 9ddbe9f commit 1ac2f4c

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
@@ -7037,13 +7037,31 @@ impl<SP: Deref> FundedChannel<SP> where
70377037
if self.context.channel_state.is_remote_stfu_sent() || self.context.channel_state.is_quiescent() {
70387038
return Err(ChannelError::WarnAndDisconnect("Got fee update message while quiescent".to_owned()));
70397039
}
7040-
FundedChannel::<SP>::check_remote_fee(self.funding.get_channel_type(), fee_estimator, msg.feerate_per_kw, Some(self.context.feerate_per_kw), logger)?;
7040+
7041+
core::iter::once(&self.funding)
7042+
.chain(self.pending_funding.iter())
7043+
.map(|funding| FundedChannel::<SP>::check_remote_fee(funding.get_channel_type(), fee_estimator, msg.feerate_per_kw, Some(self.context.feerate_per_kw), logger))
7044+
.collect::<Result<(), ChannelError>>()?;
70417045

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