Skip to content

Commit 06a9c8f

Browse files
committed
Allow configuring different max fee rate from peer
We've run into issues a few times where channels will get force closed because CLN's fee estimator isn't as good as ours so the fee rate will be too high, resulting in a force close. It'd be nice if we'd have the ability to be able to increase this limit because generally this isn't malicious, just different views of the mempool.
1 parent 20f287f commit 06a9c8f

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

lightning/src/chain/chaininterface.rs

+4
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ pub enum ConfirmationTarget {
6363
Normal,
6464
/// We'd like a transaction to confirm in the next few blocks.
6565
HighPriority,
66+
/// The maximum value we are willing to accept from our channel counterparties.
67+
/// LDK will accept up to 25 sat/vByte or 10x our fee estimator's "High Priority" fee.
68+
/// This can be used to further increase that limit.
69+
Max,
6670
}
6771

6872
/// A trait which should be implemented to provide feerate information on a number of time

lightning/src/ln/channel.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -2157,8 +2157,9 @@ impl<SP: Deref> Channel<SP> where
21572157
if !channel_type.supports_anchors_zero_fee_htlc_tx() {
21582158
let upper_limit = cmp::max(250 * 25,
21592159
fee_estimator.bounded_sat_per_1000_weight(ConfirmationTarget::HighPriority) as u64 * 10);
2160-
if feerate_per_kw as u64 > upper_limit {
2161-
return Err(ChannelError::Close(format!("Peer's feerate much too high. Actual: {}. Our expected upper limit: {}", feerate_per_kw, upper_limit)));
2160+
let user_upper_limit = cmp::max(upper_limit, fee_estimator.bounded_sat_per_1000_weight(ConfirmationTarget::Max) as u64);
2161+
if feerate_per_kw as u64 > user_upper_limit {
2162+
return Err(ChannelError::Close(format!("Peer's feerate much too high. Actual: {}. Our expected upper limit: {}", feerate_per_kw, user_upper_limit)));
21622163
}
21632164
}
21642165

0 commit comments

Comments
 (0)