Skip to content

Commit 41dfa0f

Browse files
committed
f Adjust confirmation targets and resulting fee rates
1 parent 19f8455 commit 41dfa0f

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

src/event.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -581,8 +581,9 @@ where
581581
});
582582

583583
let output_descriptors = &outputs.iter().collect::<Vec<_>>();
584-
let tx_feerate =
585-
self.wallet.get_est_sat_per_1000_weight(ConfirmationTarget::OnChainSweep);
584+
let tx_feerate = self
585+
.wallet
586+
.get_est_sat_per_1000_weight(ConfirmationTarget::NonAnchorChannelFee);
586587

587588
// We set nLockTime to the current height to discourage fee sniping.
588589
let cur_height = self.channel_manager.current_best_block().height();

src/wallet.rs

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,25 +126,38 @@ where
126126
];
127127
for target in confirmation_targets {
128128
let num_blocks = match target {
129-
ConfirmationTarget::OnChainSweep => 3,
129+
ConfirmationTarget::OnChainSweep => 6,
130130
ConfirmationTarget::MaxAllowedNonAnchorChannelRemoteFee => 1,
131131
ConfirmationTarget::MinAllowedAnchorChannelRemoteFee => 1008,
132-
ConfirmationTarget::MinAllowedNonAnchorChannelRemoteFee => 12,
133-
ConfirmationTarget::AnchorChannelFee => 12,
134-
ConfirmationTarget::NonAnchorChannelFee => 6,
135-
ConfirmationTarget::ChannelCloseMinimum => 12,
132+
ConfirmationTarget::MinAllowedNonAnchorChannelRemoteFee => 144,
133+
ConfirmationTarget::AnchorChannelFee => 1008,
134+
ConfirmationTarget::NonAnchorChannelFee => 12,
135+
ConfirmationTarget::ChannelCloseMinimum => 144,
136136
};
137137

138138
let est_fee_rate = self.blockchain.estimate_fee(num_blocks).await;
139139

140140
match est_fee_rate {
141141
Ok(rate) => {
142-
locked_fee_rate_cache.insert(target, rate);
142+
// LDK 0.0.118 introduced changes to the `ConfirmationTarget` semantics that
143+
// require some post-estimation adjustments to the fee rates, which we do here.
144+
let adjusted_fee_rate = match target {
145+
ConfirmationTarget::MaxAllowedNonAnchorChannelRemoteFee => {
146+
let really_high_prio = rate.as_sat_per_vb() * 10.0;
147+
FeeRate::from_sat_per_vb(really_high_prio)
148+
}
149+
ConfirmationTarget::MinAllowedNonAnchorChannelRemoteFee => {
150+
let slightly_less_than_background = rate.fee_wu(1000) - 250;
151+
FeeRate::from_sat_per_kwu(slightly_less_than_background as f32)
152+
}
153+
_ => rate,
154+
};
155+
locked_fee_rate_cache.insert(target, adjusted_fee_rate);
143156
log_trace!(
144157
self.logger,
145158
"Fee rate estimation updated for {:?}: {} sats/kwu",
146159
target,
147-
rate.fee_wu(1000)
160+
adjusted_fee_rate.fee_wu(1000)
148161
);
149162
}
150163
Err(e) => {

0 commit comments

Comments
 (0)