Skip to content

Commit c973cdb

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 d98adeb commit c973cdb

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

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