Skip to content

Commit f64c46c

Browse files
author
Antoine Riard
committed
Start auto-close timer if inbound update_fee don't complete
1 parent b94d8ea commit f64c46c

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

lightning/src/ln/channelmanager.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -2970,13 +2970,23 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
29702970
}
29712971

29722972
fn update_channel_fee(&self, short_to_id: &mut HashMap<u64, [u8; 32]>, pending_msg_events: &mut Vec<events::MessageSendEvent>, chan_id: &[u8; 32], chan: &mut Channel<Signer>, new_feerate: u32) -> (bool, NotifyOption, Result<(), MsgHandleErrInternal>) {
2973-
if !chan.is_outbound() { return (true, NotifyOption::SkipPersist, Ok(())); }
29742973
// If the feerate has decreased by less than half, don't bother
29752974
if new_feerate <= chan.get_feerate() && new_feerate * 2 > chan.get_feerate() {
29762975
log_trace!(self.logger, "Channel {} does not qualify for a feerate change from {} to {}.",
29772976
log_bytes!(chan_id[..]), chan.get_feerate(), new_feerate);
29782977
return (true, NotifyOption::SkipPersist, Ok(()));
29792978
}
2979+
// If the channel is inbound and we detect a relevant feerate increase, we assume
2980+
// that our counterparty, reasonably implemented, should send us an `update_fee`
2981+
// soon. Monitoring this situation, we start an autoclose timer.
2982+
let background_feerate = self.fee_estimator.get_est_sat_per_1000_weight(ConfirmationTarget::Background);
2983+
if !chan.is_outbound() {
2984+
if chan.maybe_trigger_autoclose_timer(chan.get_feerate(), new_feerate, background_feerate) {
2985+
return (true, NotifyOption::DoPersist, Ok(()));
2986+
} else {
2987+
return (true, NotifyOption::SkipPersist, Ok(()));
2988+
}
2989+
}
29802990
if !chan.is_live() {
29812991
log_trace!(self.logger, "Channel {} does not qualify for a feerate change from {} to {} as it cannot currently be updated (probably the peer is disconnected).",
29822992
log_bytes!(chan_id[..]), chan.get_feerate(), new_feerate);

0 commit comments

Comments
 (0)